Let's see how to update small Hive tables.
1. Create a table and load data (Assuming the data is placed in HDFS)
You can also refer Previous Post for creating hive tables.
CREATE EXTERNAL TABLEe Non_Parti(EmployeeID Int,FirstName String,Designation String,Salary Int,Department String) ROW FORMAT DELIMITED FIELDS TERMINATED BY "," LOCATION '/user/hdfs/Hive';
hive> select * from Non_Parti; OK 1 Anne Admin 50000 A 2 Gokul Admin 50000 B 3 Janet Sales 60000 A 4 Hari Admin 50000 C 5 Sanker Admin 50000 C 6 Margaret Tech 12000 A 7 Nirmal Tech 12000 B 8 jinju Engineer 45000 B 9 Nancy Admin 50000 A 10 Andrew Manager 40000 A 11 Arun Manager 40000 B 12 Harish Sales 60000 B 13 Robert Manager 40000 A 14 Laura Engineer 45000 A 15 Anju Ceo 100000 B 16 Aarathi Manager 40000 B 17 Parvathy Engineer 45000 B 18 Gopika Admin 50000 B 19 Steven Engineer 45000 A 20 Michael Ceo 100000 A Time taken: 0.233 seconds, Fetched: 20 row(s)
INSERT OVERWRITE TABLE Non_Parti SELECT employeeid,firstname,designation,salary, CASE WHEN employeeid=19 THEN 'C' ELSE department END AS department FROM Non_Parti;
hive> select * from Non_Parti;
OK
1 Anne Admin 50000 A
2 Gokul Admin 50000 B
3 Janet Sales 60000 A
4 Hari Admin 50000 C
5 Sanker Admin 50000 C
6 Margaret Tech 12000 A
7 Nirmal Tech 12000 B
8 jinju Engineer 45000 B
9 Nancy Admin 50000 A
10 Andrew Manager 40000 A
11 Arun Manager 40000 B
12 Harish Sales 60000 B
13 Robert Manager 40000 A
14 Laura Engineer 45000 A
15 Anju Ceo 100000 B
16 Aarathi Manager 40000 B
17 Parvathy Engineer 45000 B
18 Gopika Admin 50000 B
19 Steven Engineer 45000 C
20 Michael Ceo 100000 A
Time taken: 0.184 seconds, Fetched: 20 row(s)
Your Hive table is now updated. This can be done for small tables only.If you need to update large tables we need to partition Hive tables.
*In newer version of Hive update will be included.
*In newer version of Hive update will be included.
I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks!
ReplyDeleteSS Total Anova Calculator
Types of Angles
Interval Calculator
edublackboards