Hive Data Types
Column types
These are all the supported column types in Hive:
Primitive types:
TINYINT
SMALLINT
INT
BIGINT
BOOLEAN
FLOAT
DOUBLE
STRING
TIMESTAMP
(Note: Only available starting with Hive 0.8.0)
Complex types:
- arrays:
ARRAY<data_type>
- maps:
MAP<primitive_type, data_type>
structs:
STRUCT <col_name : data_type [COMMENT col_comment], ...>
Timestamps
Supports traditional UNIX timestamp with optional nanosecond precision.
Supported conversions:
- Integer numeric types: Interpreted as UNIX timestamp in seconds
- Floating point numeric types: Intepreted as UNIX timestamp in seconds with decimal precision
- Strings: JDBC compliant java.sql.Timestamp format "YYYY-MM-DD HH:MM:SS.fffffffff" (9 decimal place precision)
Timestamps are interpreted to be timezoneless and stored as an offset from the UNIX epoch. Convenience UDFs for conversion to and from timezones are provided (to_utc_timestamp, from_utc_timestamp).
All existing datetime UDFs (month, day, year, hour, etc.) work with the TIMESTAMP data type.
Literals
Integral types
Integral literals are assumed to be INT by default, unless the number exceeds the range of INT in which case it is interpreted as a BIGINT, or if one of the following postfixes is present on the number.
Type |
Postfix |
Example |
---|---|---|
TINYINT |
Y |
100Y |
SMALLINT |
S |
100S |
BIGINT |
L |
100L |
String types
String literals can be expressed with either single quotes (') or double quotes ("). Hive uses C-style escaping within the strings.
Floating point types
Floating point literals are assumed to be DOUBLE. Scientific notation is not yet supported.