zoukankan      html  css  js  c++  java
  • [hive学习翻译]Hive

    This chapter takes you through the different data types in Hive, which are involved in the table creation. All the data types in Hive are classified into four types, given as follows:

    本章将介绍Hive中涉及表创建的不同数据类型。 Hive中的所有数据类型分为四种类型,如下所示:

    • Column Types:列类型,TINYINT,SMALLINT,INT,BIGINT,DATE,FLOAT,DOUBLE,DECIMAL,TIMESTAMP,BINARY,STRING,VARCHAR,CHAR
    • Literals:--- 不知道怎么翻译这个
    • Null Values:空值 默认NULL
    • Complex Types:复杂类型 ARRAY,MAP,STRUCT,UNION

    Column Types

    Column type are used as column data types of Hive. They are as follows:

    列类型用作Hive的列数据类型。 它们如下:

    Integral Types

    Integer type data can be specified using integral data types, INT. When the data range exceeds the range of INT, you need to use BIGINT and if the data range is smaller than the INT, you use SMALLINT. TINYINT is smaller than SMALLINT.

    可以使用积分数据类型INT指定整数类型数据。 当数据范围超出INT的范围时,需要使用BIGINT,如果数据范围小于INT,则使用SMALLINT。 TINYINT小于SMALLINT。

    The following table depicts various INT data types:

    TypePostfixExample
    TINYINT Y 10Y
    SMALLINT S 10S
    INT - 10
    BIGINT L 10L

    String Types

    String type data types can be specified using single quotes (' ') or double quotes (" "). It contains two data types: VARCHAR and CHAR. Hive follows C-types escape characters.

    The following table depicts various CHAR data types:

    Data TypeLength
    VARCHAR 1 to 65355
    CHAR 255

    Timestamp

    It supports traditional UNIX timestamp with optional nanosecond precision. It supports java.sql.Timestamp format “YYYY-MM-DD HH:MM:SS.fffffffff” and format “yyyy-mm-dd hh:mm:ss.ffffffffff”.

    Dates

    DATE values are described in year/month/day format in the form {{YYYY-MM-DD}}.

    Decimals

    The DECIMAL type in Hive is as same as Big Decimal format of Java. It is used for representing immutable arbitrary precision. The syntax and example is as follows:

    DECIMAL(precision, scale)
    decimal(10,0)

    Union Types

    Union is a collection of heterogeneous data types. You can create an instance using create union. The syntax and example is as follows:

    UNIONTYPE<int, double, array<string>, struct<a:int,b:string>>
    
    {0:1} 
    {1:2.0} 
    {2:["three","four"]} 
    {3:{"a":5,"b":"five"}} 
    {2:["six","seven"]} 
    {3:{"a":8,"b":"eight"}} 
    {0:9} 
    {1:10.0}

    Literals

    The following literals are used in Hive:

    Floating Point Types

    Floating point types are nothing but numbers with decimal points. Generally, this type of data is composed of DOUBLE data type.

    浮点类型只是带有小数点的数字。 一般来说,这种类型的数据由DOUBLE数据类型组成

    Decimal Type

    Decimal type data is nothing but floating point value with higher range than DOUBLE data type. The range of decimal type is approximately -10-308 to 10308.

    Decimal类型数据只是浮点值,其范围高于DOUBLE数据类型。DECIMAL 取值区间为-10-308 to 10308.

    Null Value

    Missing values are represented by the special value NULL.

    Complex Types

    The Hive complex data types are as follows:

    Arrays

    Arrays in Hive are used the same way they are used in Java.

    Syntax: ARRAY<data_type>

    Maps

    Maps in Hive are similar to Java Maps.

    Syntax: MAP<primitive_type, data_type>

    Structs

    Structs in Hive is similar to using complex data with comment.

    Syntax: STRUCT<col_name : data_type [COMMENT col_comment], ...>


    译注:目前还没有用到复杂类型的使用;只是使用到了基本类型的列。hive表按照txtfile 存储方式。

    ------------------
    英文地址:
    from:https://www.tutorialspoint.com/hive/hive_data_types.htm
  • 相关阅读:
    Ubuntu 只能用guest登录的问题修复
    Ubuntu下编译C语言程序(同时给编译生成的文件命名)
    设置PYTHONIOENCODING
    Ubuntu安装atom
    R语言中将数据框(data.frame)中字符型数据转化为数值型
    修改记事本默认编码为UTF-8
    Java虚拟机浅探
    制作宅基腐主页 && 制作个人简历--材料:BootStrap
    尝试用有限状态机解决一道算法题
    OOP,WEB开发实用小技巧
  • 原文地址:https://www.cnblogs.com/hager/p/6323109.html
Copyright © 2011-2022 走看看