最近某业务hive表新增字段(只更新了表字段,没有更新分区字段),重新导入全量数据进入历史分区,查询新增字段值与数据库相同,第二天合并新增修改数据放入新分区,发现新增字段值不对比数据库少了。原因就是历史分区没有新增字段,导致查询值为null,这也跟orc 存储格式在cdh支持有关。接下来通过orc , parquet两种格式来对比说明这个问题。
新建orc格式的表,插入,查询数据 正常:
drop table test.student1;
create table if not exists test.student1(
id string
,user_name string
,age int
)
partitioned by(dt string
)stored as orc ;
insert overwrite table test.student1 partition (dt='20220803') select '1', 'test2',9 from nginx_log limit 10;
select * from test.student1 where dt='20220803';

新增字段class,重新生成数据到20220803分区,加上了class:
alter table test.student1 add columns(class string);
insert overwrit

在CDH集群环境下,当Hive表仅更新字段但未更新分区字段时,通过ORC存储的数据在查询时可能出现新增字段值缺失的情况。这与ORC格式在CDH中的支持有关。相比之下,Parquet格式则不受此问题影响。解决办法包括禁用hive.vectorized.execution.enabled或避免使用ORC格式。
最低0.47元/天 解锁文章
595

被折叠的 条评论
为什么被折叠?



