Hive built-in data type

Source: Internet
Author: User

The built-in data types of hive can be divided into two main categories: (1), underlying data type, (2), and complex data types. Among them, the underlying data types are: Tinyint,smallint,int,bigint,boolean,float,double,string,binary,timestamp,decimal,char,varchar,date. The following table lists the bytes of these underlying types and the versions from which these types are supported.

Data type Occupied bytes Start Support version
TINYINT 1byte,-128 ~ 127
SMALLINT 2byte,-32,768 ~ 32,767
Int 4byte,-2,147,483,648 ~ 2,147,483,647
BIGINT 8byte,-9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
BOOLEAN
FLOAT 4byte Single Precision
DOUBLE 8byte Double Precision
STRING
BINARY Support Starting from Hive0.8.0
TIMESTAMP Support Starting from Hive0.8.0
DECIMAL Support Starting from Hive0.11.0
CHAR Support Starting from Hive0.13.0
VARCHAR Support Starting from Hive0.12.0
DATE Support Starting from Hive0.12.0

Complex types include array,map,struct,union, which are composed of underlying types.

The Array:array type consists of a series of elements of the same data type that can be accessed by subscript. For example, there is an array type variable fruits, which is made up of [' Apple ', ' orange ', ' Mango '], then we can access the element orange by fruits[1], because the subscript of array type is starting from 0;
Map:map contains key->value key-value pairs that can be accessed by key. For example, "UserList" is a map type, where username is Key,password is value, then we can userlist[' username ' to get this user corresponding password;
Struct:struct can contain elements of different data types. These elements can be "point syntax" to get the required elements, such as user is a struct type, then you can get the address of the user through user.address.
Union:uniontype, he was supported from Hive 0.7.0.

Create a table that contains the type of replication as follows

CREATE TABLE Employees (      name STRING,      FLOAT,      subordinates ARRAY<STRING  >,      deductions MAP<FLOAT>,      address STRUCT<street:string, city:string, state:string, zip:INT>     by (country string, state string);  

Hive built-in data type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.