如何更新配置单元中分区 table 中的某些行?

How to update some rows in a partitioned table in hive?

我需要按日期更新分区 table 中的一些行,并且我不知道该怎么做?

使用动态分区,您可以覆盖更新所必需的分区。使用 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