Hive(31):将txt数据导入ORC格式表

一、实现功能

将txt或者csv数据加载到orc格式的hive中,因为不能直接创建orc类型数据,而直接将txt(csv)数据load进入orc表,会报错。所以,需要创建一个textfile格式中间表。

二、实例

1.创建textfile临时表:

create table if not exists people_orc_txt(
  name string,
  gender string
)
row format delimited
 fields terminated by ','
 stored as textfile;
 

 2.创建ORC表:

drop table people_orc;
create table if not exists people_orc(
  name string,
  gender string
)
row format delimited
 fields terminated by ','
 STORED AS ORC;

3.创建测试数据  

vi /opt/data/people.txt
zhangs,male
lisi,male
wangwu,male


4.将测试数据导入临时普通表:

load data local inpath '/opt/data/people.txt' into table people_orc_txt;

5.将临时普通表的数据插入到ORC表:

insert into table people_orc select * from people_orc_txt;

三、参考

1.Difference between 'Stored as InputFormat, OutputFormat' and 'Stored as' in Hive

2.Loading Data from a .txt file to Table Stored as ORC in Hive

  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值