背景:
业务库表结构发生变更(新增或删除字段)
处理步骤:
1.把表移至tmp库:
alter table ods.table_name rename to tmp.table_name;
2.表移除之后,检查对应Hadoop目录是否已移除:
hadoop fs -du -h /user/hive/warehouse/ods.db | grep table_name
3.设置gzip压缩的参数,再把数据插入回原来的表:
set hive.exec.dynamic.partition.mode=nonstrict; set hive.exec.compress.output=true; set mapred.output.compression.codec=org.apache.hadoop.io.compress.GzipCodec; insert overwrite table ods.table_name partition(dt) select id, gmt_create, gmt_modified,dt from tmp.table_name;



