zoukankan      html  css  js  c++  java
  • Hive中创建结构体、数组以及map

    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 ' '
        > collection items terminated by ','
        > map keys terminated by ':'
        > lines terminated by ' ';
    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 ' '
        > lines terminated by ' '
        > collection items terminated by ','
        > map keys terminated by ':';
    FAILED: ParseException line 5:0 missing EOF at 'collection' near '' ''

    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

  • 相关阅读:
    perl 安装Net::ZooKeeper
    严重: WSSERVLET11: failed to parse runtime descriptor: The serviceName cannot be retrieved from an int
    最新版FusionCharts2D面积图
    select自定义属性值
    thinkphp 常用的查询
    ThinkPHP 3.1.2 模板中的基本语法
    perl post 带上请求头
    商业智能让营销更精确
    su: cannot set user id: Resource temporarily unavailable
    java.security.KeyException
  • 原文地址:https://www.cnblogs.com/xiohao/p/6401198.html
Copyright © 2011-2022 走看看