Summary -

In this topic, we described about the below sections -

HCatalog supports the same datatypes as HCatalog. In HCatalog, the below Data types are normally used to declare a column of the table. There are two types of data types available in HCatalog.

  1. Primitive
  2. Complex

Let’s discuss about each type in detail.

Primitive Data Types -

These are the basic data types. These data types are directly associated with columns in the table. Primitive data types are normally 4 types at high level.

  • Integer
  • Boolean
  • Floating Point
  • String
Primitive TypeSub data TypeDescriptionLengthRange
Integers
TINYINTSigned Integer1 Byte-128 to 127
SMALLINTSigned Integer2 Byte-32768 to 32767
INTSigned Integer4 Byte-2147483648 .. 2147483647
BIGINTSigned Integer8 Byte9223372036854775808 .. 9223372036854775807
Boolean TypeBOOLEANTrue /FalseTRUE/ FLASE
Floating point
FLOATSingle Precision floating point number4 Byte1.40129846432481707e-45 .. 3.40282346638528860e+38
DOUBLEDouble Precision floating point number8 Byte4.94065645841246544e-324d .. 1.79769313486231570e+308
StringSTRINGsequence of characters in a specified character setMax 2GB32,767
BinaryBinaryVariable length binary data
TIMESTAMPTimestampTimestamp with no second precision1400-01-01 to 9999-12-31

Below are the declarations of Primitive data types.

Data TypeDeclaration
TINYINTColumn_name TINYINT
SMALLINTColumn_name SMALLINT
INTColumn_name INT
BIGINTColumn_name BIGINT
BOOLEANCondition1 AND/OR/NOT/&&/||/! Condition2
FLOATColumn_name FLOAT
DOUBLEColumn_name DOUBLE
STRINGColumn_name STRING
BinaryColumn_name BINARY
TimestampColumn_name TIMESTAMP

Below is conversion table for all primitive data types.

Data types
  • “Y” Represents the data type can convert from source to destination.
  • “N” represents the data type can’t be converted from source to destination.

Complex data types -

Complex data types can be built up from Primitive data types. Complex data types permit an arbitrary level of nesting. Complex declarations must specify the data type in the field’s collection. Complex types are mainly of 3 types.

  • Arrays (indexable lists)
  • Maps (key-value tuples)
  • Structs
Complex TypeDescription
ArrayAn order collection of fields.All fields in array must be of same type.Elements can be access by [n] and n is an index of the array.
MapAn ordered collection of key-value pairs.Elements can be accessed through [‘element name’] notation.Key must be primitive’s type. Values can be of any type (either primitive or complex).A single map should contain all keys same type and all values must be same type.
StructsA collection of name fields.The elements within the type can be accessed through (.) notation.May have different data types.

Below are the declarations of Primitive data types.

Data TypeDeclaration
ArrayARRAY<data_type>
MapMAP<primitive_type, data_type>
StructsSTRUCT<col_name: data_type [COMMENT col_comment], col_name: data_type...>

Below is conversion table for all primitive data types.

ArrayMapStructs
ArrayYNN
MapNYN
StructsYNN
  • “Y” Represents the data type can convert from source to destination.
  • “N” represents the data type can’t be converted from source to destination.