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

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:

DECIMAL(precision, scale)
decimal(10,0)
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:

UNIONTYPE<int, double, array<string>, struct<a:int,b:string>>

{0:1} 
{1:2.0} 
{2:["three","four"]} 
{3:{"a":5,"b":"five"}} 
{2:["six","seven"]} 
{3:{"a":8,"b":"eight"}} 
{0:9} 
{1:10.0}

Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team

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:

 ARRAY<data_type>
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team

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:

 MAP<primitive_type, data_type>
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team

Structs

  • Structs in Hive which are used are given similar to complex data

Syntax:

 STRUCT<col_name : data_type [COMMENT col_comment], ...>
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team


Wikitechy Apache Hive tutorials provides you the base of all the following topics . Enjoy learning on big data , hadoop , data analytics , big data analytics , mapreduce , hadoop tutorial , what is hadoop , big data hadoop , apache hadoop , apache hive , hadoop wiki , hadoop jobs , hadoop training , hive tutorial , hadoop big data , hadoop architecture , hadoop certification , hadoop ecosystem , hadoop fs , apache pig , hadoop cluster , cloudera hadoop , hadoop download , hadoop mapreduce , hadoop workflow , hive data types , hadoop hive , pig hadoop , hadoop administration , hadoop installation , hive hadoop , learn hadoop , hadoop for dummies , hadoop commands , hive definition , hiveql , learnhive , hive sql , hive database , hive date functions , hive query , apache hive tutorial , hive apache , hive wiki , what is a hive , hive big data , programming hive , what is hive in hadoop , hive documentation , how does hive work

Related Searches to Hive Data Types