我是靠谱客的博主 高挑咖啡豆,这篇文章主要介绍Hive(31):将txt数据导入ORC格式表一、实现功能二、实例三、参考,现在分享给大家,希望可以做个参考。

一、实现功能

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

二、实例

1.创建textfile临时表:

复制代码
1
2
3
4
5
6
7
8
create table if not exists people_orc_txt( name string, gender string ) row format delimited fields terminated by ',' stored as textfile;

 2.创建ORC表:

复制代码
1
2
3
4
5
6
7
8
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.创建测试数据  

复制代码
1
2
3
4
vi /opt/data/people.txt zhangs,male lisi,male wangwu,male


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

复制代码
1
load data local inpath '/opt/data/people.txt' into table people_orc_txt;

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

复制代码
1
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

最后

以上就是高挑咖啡豆最近收集整理的关于Hive(31):将txt数据导入ORC格式表一、实现功能二、实例三、参考的全部内容,更多相关Hive(31)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(97)

评论列表共有 0 条评论

立即
投稿
返回
顶部