[英]Hive modify partitioned table data
问题:一列值为空。 应该是'ab'。 不幸的是,我写了 '' 而不是 'ab'。
我的表是分区表。 有什么办法可以改变吗?
我找到了以下方法。 但它似乎效率低下。
我正在寻找类似更新分区和 msck 的解决方案。 有什么办法吗?
一种可能的解决方案是对表执行update
,前提是该列既不是分区列也不是分桶列。
UPDATE tablename SET column = (CASE WHEN column = '' THEN 'ab' else column END) [WHERE expr if any];
更新:支持 Hive 上的 ACID 操作
SET hive.support.concurrency=true;
SET hive.enforce.bucketing=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
SET hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
SET hive.compactor.initiator.on=true;
SET hive.compactor.worker.threads=1;
注意:仅当 Hive >= 0.14 时才有效
您可以通过这种方式覆盖单个分区:
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite target_table partition (part_col)
select
case when column ='' then 'ab' else column end as column ,
col2, --select all the columns in the same order
col3,
part_col --partition column is the last one
from target_table where part_col='your_partition_value';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.