• hive(2)数据类型和文件格式


    基本的数据类型

    Hive支持关系型数据中大多数基本的数据类型,同时也支持关系型数据库中很少出现的三种集合数据类型。

    集合数据类型

    Hive中的列支持使用struct、map、array集合数据类型,下表中的语法示例是调用的内置函数。

    例如:创建表:

    hive>create table emp(name string, salary float, subordinates array<string>, deductions map<string,float>, address struct<stree:string, city:string, state:string, zip:int>);

    文本文件数据编码

    下图表示Hive中默认的记录和字段分隔符

    例如:创建表的时候,指定分隔符(示例中的分隔符都是默认的分隔符,如果想要指定其他的分隔符,可以重新设置。)

    hive> create table emp(name string, salary float, subordinates array<string>, deductions map<string,float>, address struct<stree:string, city:string, state:string, zip:int>)
    row format delimited
       fields terminated by '01'
    collection items terminated by '02'
    map keys terminated by '03'
    lines terminated by ' '
    stored as textfile;



    说明:

    row format delimited(行格式化分隔符)关键字需要在其他字句(除stored as...)之前
    fields terminated by:字段终止,指定字段的分隔符
    collection items terminated by:集合元素间的分隔符
    map keys terminated by:map键值之间的分隔符
    lines terminated by:指定行分隔符
    lines terminated by和stored as 不需要row format delimited关键字。
  • 相关阅读:
    js get set访问器及日期扩展?
    js中加“var”和不加“var”的区别
    面试题
    ajax复习
    artTemplate使用
    Angular2组件开发—属性与事件(一)
    Angular2组件开发—为模板应用样式(三)
    Angular2组件开发—为模板应用样式(二)
    Angular2组件开发—为模板应用样式(一)
    Angular2组件开发—模板的逻辑控制(三)
  • 原文地址:https://www.cnblogs.com/yjt1993/p/11059286.html
Copyright © 2020-2023  润新知