问题:一列值为空。它应该是'ab'。不幸的是我写了''而不是'ab'。
我的表是分区表。有没有办法改变它?
我发现了以下方式。但这似乎效率低下。
我正在寻找像更新分区和msck这样的解决方案。有什么办法吗?
答案 0 :(得分:0)
一种可能的解决方案是在表格上执行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
时有效答案 1 :(得分:0)
您可以这种方式覆盖单个分区:
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';