(Data Type | Data Structure) in Hive
Hive supports the following data types category:
Data Type - (Primitive|Native|Built-in) in Hive
Category | Type | Description |
---|---|---|
Integers | TINYINT | 1 byte integer |
Integers | SMALLINT | 2 byte integer |
Integers | INT | 4 byte integer |
Integers | BIGINT | 8 byte integer |
Boolean | BOOLEAN | TRUE/FALSE |
Floating point numbers | FLOAT | single precision |
Floating point numbers | DOUBLE | double precision |
Fixed point numbers | DECIMAL | a fixed point value of user defined scale and precision |
String | STRING | sequence of characters in a specified character set |
String | VARCHAR | sequence of characters in a specified character set with a maximum length |
String | CHAR | sequence of characters in a specified character set with a defined length |
Date and time | TIMESTAMP | a specific point in time, up to nanosecond precision |
Date and time | DATE | a date |
Binary | BINARY | a sequence of bytes |
Primitive Type > Number > DOUBLE > FLOAT > BIGINT > INT > SMALLINT > TINYINT
> STRING
> BOOLEAN
The hierarchy defines how the types are implicitly converted. Implicit conversion is allowed for types from child to an ancestor.
Note that the type hierarchy allows the implicit conversion of STRING to DOUBLE.
Data Type - Complex Data Type in Hive
Complex Types can be built up from primitive types and other composite types using:
Using the primitive types and the constructs for creating complex types, types with arbitrary levels of nesting can be created. For example, a type User may comprise of the following fields:
The typing system is closely tied to the SerDe (Serailization/Deserialization) and object inspector interfaces.
User can create their own types by implementing their own object inspectors, and using these object inspectors they can create their own SerDes to serialize and deserialize their data into HDFS files.
Builtin object inspectors:
The dotted notation is used to navigate nested types, for example a.b.c = 1 looks at field c of field b of type a and compares that with 1.