问题描述
我在 Hive 表中有一个标志列,我想在一些处理后更新。我曾尝试使用以下查询使用 hive 和 impala,但它没有用,并且发现它需要是 kudu 表,而我拥有的表是非 kudu 表。有没有办法像下面的这个查询一样更新它?
UPDATE table_name SET flag_col = 1
where [condition];
解决方法
用计算值覆盖整个表,所有其他列保持原样:
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 ;
有关分区表等的更多详细信息,请阅读文档:https://docs.cloudera.com/documentation/enterprise/5-8-x/topics/impala_insert.html
,Hive 不支持更新(或删除),但它支持 INSERT INTO,因此可以向现有表中添加新行。
> insert overwrite table table_name
> select *,from table_name
//If you want to use you can add where// > where id <> 1;