apache hive - Hive Data Types - hive tutorial - hadoop hive - hadoop hive - hiveql
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
What are Data types?
- Data types are referring to as the type and size of data associated with variables and functions.
- The data type reflects the kind of information stored in the field for data which is given
- Data types define what type of data a column can contain.
- Data types can be described as: numbers, booleans, characters, arrays, and structures.
learn hive - hive tutorial - hive sql datatypes - hive programs - hive examples
Data types in Hive
- Column Types
- Literals
- Null Values
- Complex Types
Column Types
- When defining columns types, we need to name the columns, define the type of data that will be included in those columns (called data types), and define the length of the data for each column in the table you are creating:
- Hence some of the column types are given as follows
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
Integral Types
- Integer type data can be given using integral data types, INT.
- When the data range is big in INT, we need to use BIGINT and hence if the data range is small in INT, we use SMALLINT.
- Hence it is declared that TINYINT is smaller than SMALLINT.
- Hence the table which is given below describes various INT data types:
Type | Postfix | Example |
---|---|---|
TINYINT | Y | 10Y |
SMALLINT | S | 10S |
INT | - | 10 |
BIGINT | L | 10L |
String Types
- A one-dimensional array whose component type is a character is called a string type.
- String type data types can be specified using single quotes (' ') or double quotes (" ").
- Hence, it contains two data types: VARCHAR and CHAR.
- The given table specifics various CHAR data types:
Data Type | Length |
---|---|
VARCHAR | 1 to 65355 |
CHAR | 255 |
Timestamp
- A timestamp is a sequence of characters or encoded information usually giving date and time of day, it is accurate to a small fraction of second.
- It supports traditional UNIX timestamp with optional nanosecond precision.
- Timestamp format is “YYYY-MM-DD and hence it is given as HH:MM:SS.fffffffff” and
- Another format of Timestamp is“yyyy-mm-dd and hence it can be given as hh:mm:ss.ffffffffff”.
Dates
- DATE values are described in year/month/day format in the form {{YYYY-MM-DD}}.
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
Decimals
- The DECIMAL type in Hive is as same as Big Decimal format of Java.
- It is used for representing immutable arbitrary precision
Syntax:
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
Union Types
- Union Types are some programming languages which support special data types and hence are used to describe values and variables.
- Union is a collection of heterogeneous data types. We can create an instance using create union.
Syntax:
Literals
- Literals are refer to as constants to fixed values that the program may not alter during its execution.
- Literals is refer to as fixed values
- Hence there are types of literals which are used in Hive:
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
Floating Point Types
- Floating point types are numbers with decimal points.
- Generally, this type of data is composed of DOUBLE data type and this type of data is of float type
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
Decimal Type
- Decimal type data is floating point value with higher range than DOUBLE data type.
- The range of decimal type is approximately -10-308 to 10308.
Null Value
- A NULL value is a value given in a table and also in a field appears to be blank.
- Missing values are represented by the special value NULL.
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
Complex Types
- A complex type is a type which is done for defining rich, structured properties on entity types
- Complex types can exist as properties on entity types or other complex types.
- Some of the complex data types are given and they are:
Arrays
- Arrays are collections of related items that are all the same scalar data type
Syntax:
Maps
- Maps in Hive which are given are similar to Java Maps.
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
Syntax:
Structs
- Structs in Hive which are used are given similar to complex data