1

I am a newbie to Hadoop, before posting this question I have already searched on google and found all the crud operations example with only ORC files. So wanted to know if we can do the same with a text file or any changes are required in syntax. Thanks in advance.

Nandish B
  • 212
  • 1
  • 12

1 Answers1

0

Typical Templates for CRUD operations in non-ACID mode:

C: insert is the same (can be from select)

INSERT INTO TABLE table_name VALUES... or SELECT FROM ...

R: this is simple

SELECT * FROM TABLE table_name WHERE ...

U: Owerwrite the whole table or partition using select from itself (use joins to update with values from other table). Update columns using CASE statements.

INSERT OVERWRITE TABLE table_name [PARTITION(key=value)] 
SELECT --update columns using CASE
       case when col=some_value then some_other_value end as col,
       ...
       case when coln=some_value then some_other_value end as coln,
       col_x --not updated column
  FROM table_name [WHERE partition_key=value]
       JOIN...

D: This is the whole table or partition rewrite using select from itself with filter. Can be combined with update.

INSERT OVERWRITE TABLE table_name [PARTITION(key=value)] 
SELECT *
  FROM table_name [WHERE partition_key=value]
WHERE --Filter out records you want to delete

Also please read this answer about MERGE.

See the manual on Hive DML.

leftjoin
  • 36,950
  • 8
  • 57
  • 116