HIVE Data Types
Hive data types are categorized in numeric types, string types, misc types, and complex types. A list of Hive data types is given below.
Integer Types
Type |
Size |
Range |
TINYINT |
1-byte signed integer |
-128 to 127 |
SMALLINT |
2-byte signed integer |
32,768 to 32,767 |
INT |
4-byte signed integer |
2,147,483,648 to 2,147,483,647 |
BIGINT |
8-byte signed integer |
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
Decimal Type
Type |
Size |
Range |
FLOAT |
4-byte |
Single precision floating point number |
DOUBLE |
8-byte |
Double precision floating point number |
Date/Time Types
TIMESTAMP
- It supports traditional UNIX timestamp with optional nanosecond precision.
- As Integer numeric type, it is interpreted as UNIX timestamp in seconds.
- As Floating point numeric type, it is interpreted as UNIX timestamp in seconds with decimal precision.
- As string, it follows java.sql.Timestamp format "YYYY-MM-DD HH:MM:SS.fffffffff" (9 decimal place precision)
DATES
The Date value is used to specify a particular year, month and day, in the form YYYY--MM--DD. However, it didn't provide the time of the day. The range of Date type lies between 0000--01--01 to 9999--12--31.
String Types
STRING
The string is a sequence of characters. It values can be enclosed within single quotes (') or double quotes (").
Varchar
The varchar is a variable length type whose range lies between 1 and 65535, which specifies that the maximum number of characters allowed in the character string.
CHAR
The char is a fixed-length type whose maximum length is fixed at 255.
Complex Type
Type |
Size |
Range |
Struct |
It is similar to C struct or an object where fields are accessed using the "dot" notation. |
struct('James','Roy') |
Map |
It contains the key-value tuples where the fields are accessed using array notation. |
map('first','James','last','Roy') |
Array |
It is a collection of similar type of values that indexable using zero-based integers. |
array('James','Roy') |
|