首页 > 解决方案 > 如何更新配置单元中分区表中的某些行?

问题描述

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

标签: hadoophivebigdatahiveql

解决方案


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

推荐阅读