Data type
Type System
Hive supports primitive and complex data types, as described below. See Hive Data Types for additional information.
Hive supports both native and complex data types.
Primitive Types
Native data type
- Types is associated with the columns in the tables. The following Primitive types is supported:
- Integers
- TINYINT-1 byte integer
- SMALLINT-2 byte integer
- INT-4 byte integer
- BIGINT-8 byte integer
- Boolean type
- Floating point numbers
- Float-single Precision
- Double-double Precision
- String type
- String-sequence of characters in a specified character set
The Types is organized in the following hierarchy (where the parent was a super type of all the children instances):
Data type hierarchy Relationship:
This type hierarchy defines how the types is implicitly converted in the query language. Implicit conversion is allowed for types from child to an ancestor. So when a query expression expects type1 and the data are of type2, type2 is implicitly converted to Type1 if Type1 is An ancestor of type2 in the type hierarchy. Note that the type hierarchy allows the implicit conversion of STRING to DOUBLE.
Type conversions can be done in SQL, but only the child data type is converted to the ancestor data type. In addition, string types can also be converted to double types
Explicit type conversion can be do using the cast operator as shown in the #Built of Functions section below.
Complex Types
Complex data types
Complex Types can is built up from primitive Types and other composite Types using:
- Structs:the elements within the type can be accessed using the DOT (.) notation. For example, for a column C of type STRUCT {a INT; b int} The A field was accessed by the expression C.A
- Maps (Key-value tuples): The elements is accessed using [' element name '] notation. For example in a map M comprising of a mapping from ' group ', gid the GID value can be accessed using m[' group ']
- Arrays (indexable lists): The elements in the array has the to is in the same type. Elements can be accessed using the "n" notation where n is a index (zero-based) into the array. For example for an array A has the elements [' A ', ' B ', ' C '], a[1] retruns ' B '.
Complex data type support: Structs,maps,arrays three kinds. And can be used in a nested set.
Using the primitive types and the constructs for creating complex types, types with arbitrary levels of nesting can be CRE Ated. For example, a type User could comprise of the following fields:
- Gender-which is a STRING.
- Active-which is a BOOLEAN.
Https://cwiki.apache.org/confluence/display/Hive/Tutorial
[Hive-tutorial] Type System data type