hive在表格中的explode结果

hkmswyz6  于 2021-04-02  发布在  Hive
关注(0)|答案(1)|浏览(403)

谁能告诉我这段代码有什么问题? 如果我只运行select语句,那么它就会返回结果。
如果我删除其中一行 "location "或 "storeed as textfile",代码就能正常运行。另外,请告诉我是否可以指定 "分隔符"。

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;

谢谢

lokaqttq

lokaqttq1#

将 "stored as "和 "location "这两行调换一下,根据手册的规定,它们必须按照特定的顺序进行。

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;

相关问题