【问题标题】:How to update some rows in a partitioned table in hive?如何更新配置单元中分区表中的某些行?
【发布时间】:2020-01-23 04:31:44
【问题描述】:

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

【问题讨论】:

  • 您好,您与表格关联的文件类型:avro、parquet、orc?
  • 你如何识别这些行?

标签: hadoop hive bigdata hiveql


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-14
    • 2016-02-23
    相关资源
    最近更新 更多