zoukankan      html  css  js  c++  java
  • hive函数之~复合类型构建操作

    1、Map类型构建: map  ****

    语法: map (key1, value1, key2, value2, …)
    说明:根据输入的key和value对构建map类型

    hive> Create table mapTable as select map('100','tom','200','mary') as t from tableName;

    hive> describe mapTable;

    t       map<string ,string>

    hive> select t from tableName;

    {"100":"tom","200":"mary"}

    2、Struct类型构建: struct

    语法: struct(val1, val2, val3, …)
    说明:根据输入的参数构建结构体struct类型

    hive> create table struct_table as select struct('tom','mary','tim') as t from tableName;

    hive> describe struct_table;

    t       struct<col1:string ,col2:string,col3:string>

    hive> select t from tableName;

    {"col1":"tom","col2":"mary","col3":"tim"}

    3、array类型构建: array

    语法: array(val1, val2, …)
    说明:根据输入的参数构建数组array类型

    hive> create table arr_table as select array("tom","mary","tim") as t from tableName;

    hive> describe tableName;

    t       array<string>

    hive> select t from tableName;

    ["tom","mary","tim"]

  • 相关阅读:
    如何在百度文库里面免费下载东西
    CompareTo
    MySql常用日期函数(转载)
    Oracle之ORDER BY
    Spring之Ioc
    在使用与测绘有关软件中的困难
    HDOJ_1008_Elevator
    HDOJ_1005_Number Sequence
    HDOJ_1004_Let the Balloon Rise
    HDOJ_1003_MaxSum
  • 原文地址:https://www.cnblogs.com/lojun/p/13248499.html
Copyright © 2011-2022 走看看