Hive常用输入和压缩建表语句

Text 普通文本

create table `cp_api_log`(`line` string)
partitioned by (`date` string)
row format delimited fields terminated by '\t' lines terminated by '\n'
stored as textfile

-- 或 stored as 直接指定输入输出格式
-- stored as 
-- inputformat 'org.apache.hadoop.mapred.TextInputFormat'
-- outputformat 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'

ORC / parquet 列式存储

create external table `cp_api_log`(`line` string)
partitioned by (`date` string)
row format delimited fields terminated by '\t'
stored as orc
-- stored as parquet
location 'hdfs://hdfs://BigdataCluster/user/hive/warehouse/sm_data.db/ods/ods_cp_api'

ORC + Snappy

create external table `cp_api_log`(`line` string)
partitioned by (`date` string)
row format delimited fields terminated by '\t'
stored as orc tblproperties("orc.compress"="SNAPPY")
location 'hdfs://hdfs://BigdataCluster/user/hive/warehouse/sm_data.db/ods/ods_cp_api'

根据已有Orc表创建 Orc + Snappy 表

create table 压缩表 like 原表 tblproperties("orc.compress"="snappy");
insert overwrite table 压缩表 select * from 原表; 

根据非压缩表创建 Orc + Snappy 表并导入数据

create table 压缩表
stored as orc tblproperties("orc.compression"="snappy")
as select * from 原表; 

Parquet  + Snappy

create external table `cp_api_log`(`line` string)
partitioned by (`date` string)
row format delimited fields terminated by '\t'
stored as parquet tblproperties("parquet.compress"="SNAPPY")
location 'hdfs://hdfs://BigdataCluster/user/hive/warehouse/sm_data.db/ods/ods_cp_api'

JSON 类型输入 + Snappy压缩

create external table `cp_api_log`(`line` string)
partitioned by (`date` string)
row format serde 'com.cloudera.hive.serde.JSONSerDe' 
stored as orc tblproperties ("orc.compress"="SNAPPY")
location 'hdfs://hdfs://BigdataCluster/user/hive/warehouse/sm_data.db/ods/ods_cp_api'

LZO

create external table `cp_api_log`(`line` string)
partitioned by (`date` string)
stored as INPUTFORMAT 'com.hadoop.mapred.DeprecatedLzoTextInputFormat' 
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' 
location 'hdfs://hdfs://BigdataCluster/user/hive/warehouse/sm_data.db/ods/ods_cp_api'

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

訾零

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值