如何在 hive 中更新分区表中的某些行?



我需要按日期更新分区表中的一些行,具有日期范围,但我不知道该怎么做?

使用动态分区,您可以覆盖更新所需的分区。使用 case 语句检查要修改的行并设置值,如以下模板所示:

set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table table_name partition (partition_column)
select col1, 
col2,
case when col1='record to be updated' then 'new value' else col3 end as col3,
...
colN,
partition_column --partition_column should be the last
from table_name 
where ...--partition predicate here

最新更新