hive orc格式的表,使用注意事项
测试表
create table orc_part_tb(id int, name string) partitioned by (dt string) stored as orc;
insert into orc_part_tb (dt = '01') select 1,'xiaoming' union all select 2,'xiaohong' union all select 3,'xiaozhang';
使用orc格式的表可以使用alter table orc_part_tb add columns(age int);
进行添加字段,字段会添加到末尾,查询也没有问题。
但是不能调整字段的位置,
执行alter table orc_part_tb change age age int after id;
, 报错信息如下:
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Reordering columns is not supported for table orc_db.orc_part_tb. SerDe may be incompatible
表orc_db.orc_part_tb不支持对列进行重新排序。
所以如果在数仓中,ods层的数据不建议使用orc格式,因为业务可能不断发生变化,业务表结构可能频繁变动。