带有多个SerDe的蜂巢表

时间:2018-01-31 18:07:20

标签: hive

我们有一个由date分区的HIVE表。它目前有Sequence文件格式,我想把它转换成Parquet Table。

我们是否有可能使用Parquet Serde进行新的分区,而使用序列格式更新,以便我不需要回填它?

1 个答案:

答案 0 :(得分:0)

  1. 使用默认serde(LazySimpleSerDe)和默认存储(文本文件)创建一个外部空表。

  2. 添加分区。

  3. 更改分区设置文件格式(或设置serde)。

Hive LanguageManual DDL

CREATE EXTERNAL TABLE test(ip string, localTime string ) 
PARTITIONED BY (partition__hive__ STRING)  location '/tmp/table/empty';

alter table test add partition (partition__hive__='p_0') location 'hdfs://hdfsTest/hive/table/test/2018/11/21/08';
alter table test partition (partition__hive__='p_0') SET FILEFORMAT parquet;

alter table test add partition (partition__hive__='p_1') location 'hdfs://hdfsTest/hive/table/test/2018/11/21/09'; 
alter table test partition (partition__hive__='p_1') SET SERDE  'org.apache.hive.hcatalog.data.JsonSerDe';