하이브는 다음과 같은 기본 데이터 유형 (primitive type) 과 복잡한 데이터 유형 (complex type)을 지원합니다. 이러한 데이터 유형은 테이블의 열(columns)과 연관이 있습니다.

data_type
  : primitive_type
  | array_type
  | map_type
  | struct_type
  | union_type  -- (Note: Available in Hive 0.7.0 and later)
 
primitive_type
  : TINYINT
  | SMALLINT
  | INT
  | BIGINT
  | BOOLEAN
  | FLOAT
  | DOUBLE
  | DOUBLE PRECISION -- (Note: Available in Hive 2.2.0 and later)
  | STRING
  | BINARY      -- (Note: Available in Hive 0.8.0 and later)
  | TIMESTAMP   -- (Note: Available in Hive 0.8.0 and later)
  | DECIMAL     -- (Note: Available in Hive 0.11.0 and later)
  | DECIMAL(precision, scale)  -- (Note: Available in Hive 0.13.0 and later)
  | DATE        -- (Note: Available in Hive 0.12.0 and later)
  | VARCHAR     -- (Note: Available in Hive 0.12.0 and later)
  | CHAR        -- (Note: Available in Hive 0.13.0 and later)
 
array_type
  : ARRAY < data_type >
 
map_type
  : MAP < primitive_type, data_type >
 
struct_type
  : STRUCT < col_name : data_type [COMMENT col_comment], ...>
 
union_type
   : UNIONTYPE < data_type, data_type, ... >  -- (Note: Available in Hive 0.7.0 and later)

Hive Misc Types (Boolean & Binary)


MISC TYPESDESCRIPTION
BOOLEANAccepts TRUE/FALSE values
BINARYOnly available starting with Hive 0.8.0

Hive Numeric Types


NUMERIC TYPESDESCRIPTION
TINYINT1-byte signed integer, from -128 to 127
SMALLINT2-byte signed integer, from -32,768 to 32,767
INT/INTEGER4-byte signed integer, from -2,147,483,648 to 2,147,483,647
BIGINT8-byte signed integer, from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
FLOAT4-byte single precision floating point number
DOUBLE8-byte double precision floating point number
DOUBLE PRECISIO NAlias for DOUBLE, only available starting with Hive 2.2.0
DECIMALIt accepts a precision of 38 digits.
NUMERICSame as DECIMAL type.

Hive String Types


STRING TYPESDESCRIPTION
STRINGThe string is an unbounded type. Not required to specify the lenght. It can accept max up to 32,767 bytes.
VARCHARVariable length of characters. It is bounded meaning you still need to specify the length like VARCHAR(10).
CHARFixed length of Characters. if you define char(10) and assigning 5 chars, the remaining 5 characters space will be wasted.

Hive Date & Time Types


DATE/TIME TYPESDESCRIPTION
TIMESTAMPAccepts Both Date and Time
DATEAccepts just Date
INTERVALInterval

Hive Complex Types (Array, Map, Struct)


  • Spark와 마찬가지로 Hive는 Array, Map, Struct 및 union을 포함하는 복잡한 데이터 유형도 지원합니다.
    • Array는 list of elements 을 저장하는 데 사용됩니다.
    • Map은 key / value pair를 저장하는 데 사용됩니다.
    • Struct는 부모 및 자식 연결을위한 것 입니다.

COMPLEX TYPESDESCRIPTION
ArraysARRAY<data_type>
MapsMAP<primitive_type, data_type>
StructsSTRUCT<col_name : data_type [COMMENT col_comment], ...>
UnionUNIONTYPE<data_type, data_type, …>Note: Only available starting with Hive 0.7.0.

+ Recent posts