首页 > 解决方案 > 表中的 Hive 爆炸结果

问题描述

有人可以告诉我这段代码有什么问题吗?如果我只运行 select 语句,那么它会返回结果。

如果我删除“位置”或“存储为文本文件”这一行,代码就可以工作。如果我也可以指定“分隔符”,请告诉我。

create table exploderesults 
location '/user/cloudera/sometest'
stored as textfile
as
select id,ph as phone, ct as city from explodetest
lateral view explode(phone)p as ph
lateral view explode(city)c as ct;

谢谢

标签: hivehiveql

解决方案


交换两行stored aslocation根据手册,它们必须按特定顺序排列

create table exploderesults 
stored as textfile
location '/user/cloudera/sometest'
as
select id,ph as phone, ct as city from explodetest
lateral view explode(phone)p as ph
lateral view explode(city)c as ct;

如果要指定分隔符,

create table exploderesults 
row format delimited fields terminated by ','
stored as textfile
location '/user/cloudera/sometest'
as
select id,ph as phone, ct as city from explodetest
lateral view explode(phone)p as ph
lateral view explode(city)c as ct;

推荐阅读