Skip to content
Advertisement

How to UPDATE a value in hive table?

I have a flag column in Hive table that I want to update after some processing. I have tried using hive and impala using the below query but it didn’t work, and got that it needs to be a kudu table while the table I have is a non-kudu table. Is there a way to update it like this query below ?

UPDATE table_name SET flag_col = 1
where [condition];

Advertisement

Answer

Overwrite the whole table with calculated values, all other columns as is:

insert overwrite table table_name 
select col1, col2, ..., coln, 
       case when [condition] then 1 else flag_col end as flag_col,
       colO, 
       colP...
  from table_name ;

Read documentation for more details on partitioned tables, etc: https://docs.cloudera.com/documentation/enterprise/5-8-x/topics/impala_insert.html

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement