TutorialsArena

Hive Data Types: A Comprehensive Guide

Explore the diverse data types supported by Hive, the data warehouse system built on Hadoop. This comprehensive guide helps you choose the right data type for efficient storage, processing, and query optimization.



Hive Data Types: A Comprehensive Guide

Hive, a data warehouse system built on top of Hadoop, supports various data types for storing and managing data. Choosing the right data type is very important for efficient data storage and processing. Understanding Hive's data types is crucial for effective data modeling and query optimization. This guide provides a detailed overview of Hive's data types.

Integer Types

Type Size (Bytes) Range
TINYINT 1 -128 to 127
SMALLINT 2 -32,768 to 32,767
INT 4 -2,147,483,648 to 2,147,483,647
BIGINT 8 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Decimal Types

Type Size (Bytes) Description
FLOAT 4 Single-precision floating-point number.
DOUBLE 8 Double-precision floating-point number.

Date and Time Types

Type Description
TIMESTAMP Unix timestamp (seconds since epoch), optionally with nanosecond precision. Can be stored as integer or floating-point numbers, or a string in the format "YYYY-MM-DD HH:MM:SS.fffffffff".
DATE Date (YYYY-MM-DD). Range: 0000-01-01 to 9999-12-31.

String Types

Type Description Size Limit
STRING Variable-length string. 65,535 characters
VARCHAR Variable-length string. 1 to 65,535 characters
CHAR Fixed-length string. 1 to 255 characters

Complex Types

Type Description Example
STRUCT Similar to a C struct or a JSON object. STRUCT('Alice', 'Smith')
MAP Key-value pairs. MAP('firstName', 'Alice', 'lastName', 'Smith')
ARRAY Ordered list of values of the same type. ARRAY('Alice', 'Bob', 'Charlie')