Search This Blog

Monday, 2 March 2026

load sample data in to hive

 

Step 1: Create Sample Delimited Text File

We’ll create a simple employee dataset.

📄 Create a text file in Linux

vi employee.txt

Add sample data (Comma Delimited)

1,John,IT,50000
2,Anita,HR,45000
3,Ravi,Finance,60000
4,Meena,IT,55000
5,Kiran,Sales,40000

Save and exit.


✅ Step 2: Move File to HDFS

Create HDFS directory

hadoop fs -mkdir -p /user/hive/employee_data

Upload file to HDFS

hadoop fs -put employee.txt /user/hive/employee_data/

Verify

hadoop fs -ls /user/hive/employee_data

✅ Step 3: Start Hive

hive

✅ Step 4: Create Hive Database (Optional)

CREATE DATABASE company;
USE company;

✅ Step 5: Create Hive Table (Row Formatted Delimited)

CREATE TABLE employee (
id INT,
name STRING,
department STRING,
salary INT
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE;

✅ Step 6: Load Data from HDFS into Hive Table

LOAD DATA INPATH '/user/hive/employee_data/employee.txt'
INTO TABLE employee;

✅ Step 7: Verify Data

SELECT * FROM employee;

No comments:

Post a Comment

Hadoop Analytics

AI & DS PIG EXPERIMENT

 first create these files in your terminal using cat command cat > employees.csv      1, John Doe, 101, 50000      2, Jane Smith, 102...