hdfs orc格式_hive中orc格式表的数据导入
Hive系列文章
hive創建orc格式表不能像textfile格式一樣直接load數據到表中,需要創建臨時textfile表,然后通過insert into 或者insert overwrite到orc存儲格式表中。
如果你直接load數據到orc格式表中,這個步驟可以成功,但是會發現select * from table limit 1;這個語句都會報錯,也就是說直接load數據是不可行的。對于hive中orc格式表可以參見:大數據:Hive - ORC 文件存儲格式
1)、創建表
需要創建臨時表和數據表。
臨時表
create table if not exists db.tmp
(
name string,
age int
)
partitioned by (dt string, hour string, msgtype string, action string)
row format delimited fields terminated by '\t';
數據表
create external table if not exists db.people
(
name string,
age int
)
partitioned by (dt string, hour string, msgtype string, action string)
row format delimited fields terminated by '\t'
stored as orc;
2)、 導入數據
需要先用load命令將數據導入textfile格式表,然后再通過insert into插入orc格式表。
(1) 導入數據到textfile
load data inpath 'hdfs://path' into table db.tmp partition(dt="2018-06-22",hour="00",msgtype="web", action="click");
(2)查詢數據插入orc格式表
insert into db.people partition(dt="2018-06-22",hour="00",msgtype="web", action="click")
select name,age
from db.tmp where dt = "2018-06-22" and hour = "00"
and msgtype = "web" and action = "click";
關注公眾號:Java大數據與數據倉庫,學習大數據技術。
喜歡 (0)or分享 (0)
總結
以上是生活随笔為你收集整理的hdfs orc格式_hive中orc格式表的数据导入的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【计算机毕业设计】医院预约挂号系统
- 下一篇: ssm项目会议管理系统