码迷,mamicode.com
首页 > 编程语言 > 详细

Hive中创建结构体、数组以及map

时间:2017-02-15 14:51:10      阅读:1550      评论:0      收藏:0      [点我收藏+]

标签:miss   min   path   ems   from   ssi   str   limit   value   

ROW FORMAT DELIMITED 分隔符设置开始语句

FIELDS TERMINATED BY:设置字段与字段之间的分隔符

COLLECTION ITEMS TERMINATED BY:设置一个复杂类型(array,struct)字段的各个item之间的分隔符

MAP KEYS TERMINATED BY:设置一个复杂类型(Map)字段的key value之间的分隔符

LINES TERMINATED BY:设置行与行之间的分隔符

例:

Hive> create table t(id struct<id1:int,id2:int,id3:int>,name array<string>,xx map<int,string>)
    > row format delimited
    > fields terminated by ‘\t‘
    > collection items terminated by ‘,‘
    > map keys terminated by ‘:‘
    > lines terminated by ‘\n‘;
OK
Time taken: 0.287 seconds

ROW FORMAT DELIMITED 必须在其它分隔设置之前,也就是分隔符设置语句的最前

LINES TERMINATED BY必须在其它分隔设置之后,也就是分隔符设置语句的最后,否则会报错

hive> create table t (id struct<id1:int,id2:int,id3:int>,name array<string>,xx map<int,string>) 
    > row format delimited
    > fields terminated by ‘\t‘
    > lines terminated by ‘\n‘
    > collection items terminated by ‘,‘
    > map keys terminated by ‘:‘;
FAILED: ParseException line 5:0 missing EOF at ‘collection‘ near ‘‘\n‘‘

 

for example:

编辑本地文件:f.txt 内容为:1,2     1,2,3,4,5       1:value_1,2:value_2

导入本地文件:load data local inpath ‘/f.txt‘ into table t;

查询表数据:select * from t;

{"id1":1,"id2":2}       ["1","2","3","4","5"]   {1:"value_1",2:"value_2"}

 

参考链接:

http://blog.csdn.net/lichao23jordan/article/details/50378144

 

Hive中创建结构体、数组以及map

标签:miss   min   path   ems   from   ssi   str   limit   value   

原文地址:http://www.cnblogs.com/xiohao/p/6401198.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!