SlideShare a Scribd company logo
1 of 19
Hive Data Types – Primitive and
Complex Data Types in Hive
 Hive Data Types are the most fundamental thing
you must know before working with Hive
Queries.
 Data Types in Hive specifies the column type in Hive
tables. The article describes the two categories of
Hive Data types that are primitive data
type and complex data type along with their
example.
Data Types in Hive specifies the column/field type in the Hive table. It
specifies the type of values that can be inserted into the specified column.
Primitive Type
 Numeric
 Date/time
 String
 Miscellaneous
1. Numeric Type
 The Numeric data type in Hive is categorized into
 Integral data type
 Floating data type
1.1 Integral data type
a. TINYINT – (1-byte signed integer ranging from -128
to 127)
b. SMALLINT – (2-byte signed integer ranging from -
32, 768 to 32, 767)
c. INTEGER – (4-byte signed integer ranging from -2,
147, 483, 648 to 2, 147, 483, 647)
d. BIGINT – (8-byte signed integer ranging from -9,
223, 372, 036, 854, 775, 808 to 9, 223, 372, 036,
854, 775, 807)
In Hive, Integral literals are assumed to be INTEGER
by default unless they cross the range of INTEGER
values. If we want to use a low integral value like
100 to be treated as TINYINT, SMALLINT, or BIGINT,
then we will use the following postfixes (shown in the
below table) with the number.
Type Postfix Example
TINYINT Y 100Y
SMALLINT S 100S
BIGINT L 100L
1.2 Floating data type
a. FLOAT
 It is a 4-byte single-precision floating-point number.
b. DOUBLE
 It is an 8-byte double-precision floating-point number.
c. DOUBLE PRECISION
 It is an alias for DOUBLE. It is only available starting with
Hive 2.2.0
d. DECIMAL
 It was introduced in Hive 0.11.0. It is based on Java’s
BigDecimal. DECIMAL types support both scientific and
non-scientific notations.
 In Hive 0.11.0 and 0.12, the precision of the DECIMAL
type is fixed and limited to 38 digits.
 As of Hive 0.13, user can specify the scale and precision
during table creation using the syntax:
DECIMAL(precision, scale)
 If precision is not specified, then by default, it is
equal to 10.
 If the scale is not specified, then by default, it is
equal to 0.
 DECIMAL provides more precise values and greater
range than DOUBLE.
e. NUMERIC
It started with Hive 3.0.0. The NUMERIC data type is the same as the
DECIMAL type.
2. Date/Time data type:
a. TIMESTAMP
 Timestamps were introduced in Hive 0.8.0. It
supports traditional UNIX timestamp with the
optional nanosecond precision.
 The supported Timestamps format is yyyy-mm-dd
hh:mm:ss[.f…] in the text files.
 If they are in any other format, declare them as the
appropriate type and use UDF(User Defined
Function) to convert them to timestamps.
b. DATE
 Dates were introduced in Hive 0.12.0. DATE value
describes a particular year/month/day in the form of
YYYY-MM-DD.
 For example- DATE ‘2020-02-04’
 It does not have a time of day component. The range
of value supported for the DATE type is 0000-01-01
to 9999-12-31.
c. INTERVAL
 Hive Interval data types are available only after
starting with Hive version 1.2 or above.
 Hive accepts the interval syntax with unit
specifications. We have to specify the units along
with the interval value.
 For example, INTERVAL ‘1’ DAY refers to the day
3. String data type
a. STRING
 In Hive, String literals are represented either with the single
quotes(‘ ’) or with double-quotes(“ ”).
 Hive uses C-style escaping.
b. VARCHAR
 In Hive, VARCHAR data types are of different lengths, but we
have to specify the maximum number of characters allowed in
the character string.
 If the string value assigned to the varchar is less than the
maximum length, then the remaining space will be freed out.
 Also, if the string value assigned is more than the maximum
length, then the string is silently truncated.
 The length of the varchar is between(1 to 65535).
 Trailing whitespace is important in varchar and will affect the
comparison results.
c. CHAR
 CHAR data types are fixed-length.
 The values shorter than the specified length are padded
with the spaces.
 Unlike VARCHAR, trailing spaces are not significant in
CHAR types during comparisons.
 The maximum length of CHAR is fixed at 255.
 4. Miscellaneous data type
a. BOOLEAN
 Boolean types in Hive store either true or false.
b. BINARY
 BINARY type in Hive is an array of bytes.
 This is all about Hive Primitive Data Types. Let us now
study Hive Complex Data Types.
Hive Complex Data Type
1. arrays
Array in Hive is an ordered sequence of similar type elements that are indexable using the zero-based integers.
Arrays in Hive are similar to the arrays in JAVA.
array<datatype>
Example: array(‘Data’,’Flair’). The second element is accessed as array[1].
2. maps
Map in Hive is a collection of key-value pairs, where the fields are accessed using array notations of keys (e.g., [‘key’]).
map<primitive_type, data_type>
Example: ‘first’ -> ‘John’, ‘last’ -> ‘Deo’, represented as map(‘first’, ‘John’, ‘last’, ‘Deo’). Now ‘John’ can be accessed with map[‘first’].
3. structs
STRUCT in Hive is similar to the STRUCT in C language. It is a record type that encapsulates a set of named fields, which can be any primitive
data type.
We can access the elements in STRUCT type using DOT (.) notation.
STRUCT <col_name : data_type [ COMMENT col_comment], ...>
Example: For a column c3 of type STRUCT {c1 INTEGER; c2 INTEGER}, the c1 field is accessed by the expression c3.c1.
4. union
UNION type in Hive is similar to the UNION in C. UNION types at any point of time can hold exactly one data type from its specified data types.
The full support for UNIONTYPE data type in Hive is still incomplete.
UNIONTYPE<data_type, data_type, ...>
Handling of NULL Values
In Hive data types, the missing values are represented by the special value NULL.
So, this was all in Hive Data Types. Hope you like our explanation.
Types of Hive Built-in Operators
Operator Operand Types Description
A=B All primitive types
TRUE if expression A is equal to expression
B. Otherwise FALSE.
A!=B All primitive types
TRUE if expression A is not equal to
expression B. Otherwise FALSE.
A<B All primitive types
TRUE if expression A is less than expression
B. Otherwise FALSE.
A <= B All primitive types
TRUE if expression A is less than or equal to
expression B. Otherwise FALSE.
A > B All primitive types
TRUE if expression A is greater than
expression B. Otherwise FALSE.
A >= B All primitive types
TRUE if expression A is greater than or
equal to expression B. Otherwise FALSE.
A IS NULL All types
TRUE if expression A evaluates to NULL.
Otherwise FALSE.
A IS NOT NULL All types
FALSE if expression A evaluates to NULL.
Otherwise FALSE.
A LIKE B String
TRUE if string pattern A matches to B.
Otherwise FALSE.
A REGEXP B String
Operator Operand types Description
A+B All number types Gives the result of adding A and B
A-B All number types Gives the result of subtracting B from A
A*B All number types Gives the result of multiplying A and
A/B All number types Gives the result of dividing A by B
A % B All number types
Gives the remainder resulting from dividing A
by B
A & B All number types Gives the result of bitwise AND of A and B
A | B All number types Gives the result of bitwise OR of A and B
A ^ B All number types Gives the result of bitwise XOR of A and B
~A All number types Gives the result of bitwise NOT of A.
Operator
Operand
types
Description
A AND B Boolean
TRUE if both A and B are
TRUE. Otherwise FALSE.
NULL if A or B is NULL.
A OR B Boolean
RUE if either A or B or both are
TRUE, FALSE OR NULL is
NULL. Otherwise FALSE.
NOT A Boolean
TRUE if A is FALSE or NULL if
A is NULL. Otherwise FALSE.
! A Boolean Same as NOT A.
Operator
Operand
types
Description
A || B strings
Concatenates the operands –
shorthand for concat(A,B)
Operator
Operand
types
Description
A[n]
A is an Array
and n is an int
Returns the nth element in the
array A. The first element has
index 0
M[key]
M is a Map<K,
V> and key
has type K
Returns the value corresponding
to the key in the map
S.x S is a struct Returns the x field of S.

More Related Content

What's hot

Computational learning theory
Computational learning theoryComputational learning theory
Computational learning theoryswapnac12
 
R data-import, data-export
R data-import, data-exportR data-import, data-export
R data-import, data-exportFAO
 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.pptvenkatapranaykumarGa
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logicAmey Kerkar
 
Module 4: Model Selection and Evaluation
Module 4: Model Selection and EvaluationModule 4: Model Selection and Evaluation
Module 4: Model Selection and EvaluationSara Hooker
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representationSravanthi Emani
 
Captcha as graphical password
Captcha as graphical passwordCaptcha as graphical password
Captcha as graphical passwordGopinath Ramanna
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overviewamudha arul
 
Binary Class and Multi Class Strategies for Machine Learning
Binary Class and Multi Class Strategies for Machine LearningBinary Class and Multi Class Strategies for Machine Learning
Binary Class and Multi Class Strategies for Machine LearningPaxcel Technologies
 
Fine tune and deploy Hugging Face NLP models
Fine tune and deploy Hugging Face NLP modelsFine tune and deploy Hugging Face NLP models
Fine tune and deploy Hugging Face NLP modelsOVHcloud
 
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Simplilearn
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRRiazul Islam
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dhrumil Panchal
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Fuzzy rules and fuzzy reasoning
Fuzzy rules and fuzzy reasoningFuzzy rules and fuzzy reasoning
Fuzzy rules and fuzzy reasoningVeni7
 

What's hot (20)

Computational learning theory
Computational learning theoryComputational learning theory
Computational learning theory
 
R data-import, data-export
R data-import, data-exportR data-import, data-export
R data-import, data-export
 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
 
Prolog
PrologProlog
Prolog
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
 
Module 4: Model Selection and Evaluation
Module 4: Model Selection and EvaluationModule 4: Model Selection and Evaluation
Module 4: Model Selection and Evaluation
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representation
 
Captcha as graphical password
Captcha as graphical passwordCaptcha as graphical password
Captcha as graphical password
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overview
 
Binary Class and Multi Class Strategies for Machine Learning
Binary Class and Multi Class Strategies for Machine LearningBinary Class and Multi Class Strategies for Machine Learning
Binary Class and Multi Class Strategies for Machine Learning
 
Numpy
NumpyNumpy
Numpy
 
Fine tune and deploy Hugging Face NLP models
Fine tune and deploy Hugging Face NLP modelsFine tune and deploy Hugging Face NLP models
Fine tune and deploy Hugging Face NLP models
 
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
Recurrent Neural Network (RNN) | RNN LSTM Tutorial | Deep Learning Course | S...
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
 
AD3251-Data Structures Design-Notes-Searching-Hashing.pdf
AD3251-Data Structures  Design-Notes-Searching-Hashing.pdfAD3251-Data Structures  Design-Notes-Searching-Hashing.pdf
AD3251-Data Structures Design-Notes-Searching-Hashing.pdf
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Fuzzy rules and fuzzy reasoning
Fuzzy rules and fuzzy reasoningFuzzy rules and fuzzy reasoning
Fuzzy rules and fuzzy reasoning
 

Similar to Unit 5-hive data types – primitive and complex data

cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfYRABHI
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programmingHarshita Yadav
 
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1Vahid Farahmandian
 
datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxNaniBhai3
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiSowmyaJyothi3
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.pptAqeelAbbas94
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++Neeru Mittal
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsatifmugheesv
 
c++ arrays and pointers grade 9 STEP curriculum.pptx
c++ arrays and pointers grade 9 STEP curriculum.pptxc++ arrays and pointers grade 9 STEP curriculum.pptx
c++ arrays and pointers grade 9 STEP curriculum.pptxJanineCallangan
 
Simple Queriebhjjnhhbbbbnnnnjjs In SQL.pdf
Simple Queriebhjjnhhbbbbnnnnjjs In SQL.pdfSimple Queriebhjjnhhbbbbnnnnjjs In SQL.pdf
Simple Queriebhjjnhhbbbbnnnnjjs In SQL.pdfManojVishwakarma91
 

Similar to Unit 5-hive data types – primitive and complex data (20)

DBMS
DBMSDBMS
DBMS
 
C++ data types
C++ data typesC++ data types
C++ data types
 
Data Handling
Data HandlingData Handling
Data Handling
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1
 
datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptx
 
C#
C#C#
C#
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
 
c++ arrays and pointers grade 9 STEP curriculum.pptx
c++ arrays and pointers grade 9 STEP curriculum.pptxc++ arrays and pointers grade 9 STEP curriculum.pptx
c++ arrays and pointers grade 9 STEP curriculum.pptx
 
Data type
Data typeData type
Data type
 
Access
AccessAccess
Access
 
2017 biological databasespart2
2017 biological databasespart22017 biological databasespart2
2017 biological databasespart2
 
Data types
Data typesData types
Data types
 
Simple Queriebhjjnhhbbbbnnnnjjs In SQL.pdf
Simple Queriebhjjnhhbbbbnnnnjjs In SQL.pdfSimple Queriebhjjnhhbbbbnnnnjjs In SQL.pdf
Simple Queriebhjjnhhbbbbnnnnjjs In SQL.pdf
 
Ansi
AnsiAnsi
Ansi
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 

More from vishal choudhary (20)

SE-Lecture1.ppt
SE-Lecture1.pptSE-Lecture1.ppt
SE-Lecture1.ppt
 
SE-Testing.ppt
SE-Testing.pptSE-Testing.ppt
SE-Testing.ppt
 
SE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.pptSE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.ppt
 
SE-Lecture-7.pptx
SE-Lecture-7.pptxSE-Lecture-7.pptx
SE-Lecture-7.pptx
 
Se-Lecture-6.ppt
Se-Lecture-6.pptSe-Lecture-6.ppt
Se-Lecture-6.ppt
 
SE-Lecture-5.pptx
SE-Lecture-5.pptxSE-Lecture-5.pptx
SE-Lecture-5.pptx
 
XML.pptx
XML.pptxXML.pptx
XML.pptx
 
SE-Lecture-8.pptx
SE-Lecture-8.pptxSE-Lecture-8.pptx
SE-Lecture-8.pptx
 
SE-coupling and cohesion.ppt
SE-coupling and cohesion.pptSE-coupling and cohesion.ppt
SE-coupling and cohesion.ppt
 
SE-Lecture-2.pptx
SE-Lecture-2.pptxSE-Lecture-2.pptx
SE-Lecture-2.pptx
 
SE-software design.ppt
SE-software design.pptSE-software design.ppt
SE-software design.ppt
 
SE1.ppt
SE1.pptSE1.ppt
SE1.ppt
 
SE-Lecture-4.pptx
SE-Lecture-4.pptxSE-Lecture-4.pptx
SE-Lecture-4.pptx
 
SE-Lecture=3.pptx
SE-Lecture=3.pptxSE-Lecture=3.pptx
SE-Lecture=3.pptx
 
Multimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptxMultimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptx
 
MultimediaLecture5.pptx
MultimediaLecture5.pptxMultimediaLecture5.pptx
MultimediaLecture5.pptx
 
Multimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptxMultimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptx
 
MultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptxMultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptx
 
Multimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptxMultimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptx
 
Multimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptxMultimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptx
 

Recently uploaded

办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfBoston Institute of Analytics
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxBoston Institute of Analytics
 

Recently uploaded (20)

办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 

Unit 5-hive data types – primitive and complex data

  • 1. Hive Data Types – Primitive and Complex Data Types in Hive
  • 2.  Hive Data Types are the most fundamental thing you must know before working with Hive Queries.  Data Types in Hive specifies the column type in Hive tables. The article describes the two categories of Hive Data types that are primitive data type and complex data type along with their example.
  • 3. Data Types in Hive specifies the column/field type in the Hive table. It specifies the type of values that can be inserted into the specified column.
  • 4. Primitive Type  Numeric  Date/time  String  Miscellaneous
  • 5. 1. Numeric Type  The Numeric data type in Hive is categorized into  Integral data type  Floating data type 1.1 Integral data type a. TINYINT – (1-byte signed integer ranging from -128 to 127) b. SMALLINT – (2-byte signed integer ranging from - 32, 768 to 32, 767) c. INTEGER – (4-byte signed integer ranging from -2, 147, 483, 648 to 2, 147, 483, 647)
  • 6. d. BIGINT – (8-byte signed integer ranging from -9, 223, 372, 036, 854, 775, 808 to 9, 223, 372, 036, 854, 775, 807) In Hive, Integral literals are assumed to be INTEGER by default unless they cross the range of INTEGER values. If we want to use a low integral value like 100 to be treated as TINYINT, SMALLINT, or BIGINT, then we will use the following postfixes (shown in the below table) with the number.
  • 7. Type Postfix Example TINYINT Y 100Y SMALLINT S 100S BIGINT L 100L
  • 8. 1.2 Floating data type a. FLOAT  It is a 4-byte single-precision floating-point number. b. DOUBLE  It is an 8-byte double-precision floating-point number. c. DOUBLE PRECISION  It is an alias for DOUBLE. It is only available starting with Hive 2.2.0 d. DECIMAL  It was introduced in Hive 0.11.0. It is based on Java’s BigDecimal. DECIMAL types support both scientific and non-scientific notations.  In Hive 0.11.0 and 0.12, the precision of the DECIMAL type is fixed and limited to 38 digits.  As of Hive 0.13, user can specify the scale and precision during table creation using the syntax: DECIMAL(precision, scale)
  • 9.  If precision is not specified, then by default, it is equal to 10.  If the scale is not specified, then by default, it is equal to 0.  DECIMAL provides more precise values and greater range than DOUBLE. e. NUMERIC It started with Hive 3.0.0. The NUMERIC data type is the same as the DECIMAL type.
  • 10. 2. Date/Time data type: a. TIMESTAMP  Timestamps were introduced in Hive 0.8.0. It supports traditional UNIX timestamp with the optional nanosecond precision.  The supported Timestamps format is yyyy-mm-dd hh:mm:ss[.f…] in the text files.  If they are in any other format, declare them as the appropriate type and use UDF(User Defined Function) to convert them to timestamps.
  • 11. b. DATE  Dates were introduced in Hive 0.12.0. DATE value describes a particular year/month/day in the form of YYYY-MM-DD.  For example- DATE ‘2020-02-04’  It does not have a time of day component. The range of value supported for the DATE type is 0000-01-01 to 9999-12-31. c. INTERVAL  Hive Interval data types are available only after starting with Hive version 1.2 or above.  Hive accepts the interval syntax with unit specifications. We have to specify the units along with the interval value.  For example, INTERVAL ‘1’ DAY refers to the day
  • 12. 3. String data type a. STRING  In Hive, String literals are represented either with the single quotes(‘ ’) or with double-quotes(“ ”).  Hive uses C-style escaping. b. VARCHAR  In Hive, VARCHAR data types are of different lengths, but we have to specify the maximum number of characters allowed in the character string.  If the string value assigned to the varchar is less than the maximum length, then the remaining space will be freed out.  Also, if the string value assigned is more than the maximum length, then the string is silently truncated.  The length of the varchar is between(1 to 65535).  Trailing whitespace is important in varchar and will affect the comparison results.
  • 13. c. CHAR  CHAR data types are fixed-length.  The values shorter than the specified length are padded with the spaces.  Unlike VARCHAR, trailing spaces are not significant in CHAR types during comparisons.  The maximum length of CHAR is fixed at 255.  4. Miscellaneous data type a. BOOLEAN  Boolean types in Hive store either true or false. b. BINARY  BINARY type in Hive is an array of bytes.  This is all about Hive Primitive Data Types. Let us now study Hive Complex Data Types.
  • 15. 1. arrays Array in Hive is an ordered sequence of similar type elements that are indexable using the zero-based integers. Arrays in Hive are similar to the arrays in JAVA. array<datatype> Example: array(‘Data’,’Flair’). The second element is accessed as array[1]. 2. maps Map in Hive is a collection of key-value pairs, where the fields are accessed using array notations of keys (e.g., [‘key’]). map<primitive_type, data_type> Example: ‘first’ -> ‘John’, ‘last’ -> ‘Deo’, represented as map(‘first’, ‘John’, ‘last’, ‘Deo’). Now ‘John’ can be accessed with map[‘first’]. 3. structs STRUCT in Hive is similar to the STRUCT in C language. It is a record type that encapsulates a set of named fields, which can be any primitive data type. We can access the elements in STRUCT type using DOT (.) notation. STRUCT <col_name : data_type [ COMMENT col_comment], ...> Example: For a column c3 of type STRUCT {c1 INTEGER; c2 INTEGER}, the c1 field is accessed by the expression c3.c1. 4. union UNION type in Hive is similar to the UNION in C. UNION types at any point of time can hold exactly one data type from its specified data types. The full support for UNIONTYPE data type in Hive is still incomplete. UNIONTYPE<data_type, data_type, ...> Handling of NULL Values In Hive data types, the missing values are represented by the special value NULL. So, this was all in Hive Data Types. Hope you like our explanation.
  • 16. Types of Hive Built-in Operators Operator Operand Types Description A=B All primitive types TRUE if expression A is equal to expression B. Otherwise FALSE. A!=B All primitive types TRUE if expression A is not equal to expression B. Otherwise FALSE. A<B All primitive types TRUE if expression A is less than expression B. Otherwise FALSE. A <= B All primitive types TRUE if expression A is less than or equal to expression B. Otherwise FALSE. A > B All primitive types TRUE if expression A is greater than expression B. Otherwise FALSE. A >= B All primitive types TRUE if expression A is greater than or equal to expression B. Otherwise FALSE. A IS NULL All types TRUE if expression A evaluates to NULL. Otherwise FALSE. A IS NOT NULL All types FALSE if expression A evaluates to NULL. Otherwise FALSE. A LIKE B String TRUE if string pattern A matches to B. Otherwise FALSE. A REGEXP B String
  • 17. Operator Operand types Description A+B All number types Gives the result of adding A and B A-B All number types Gives the result of subtracting B from A A*B All number types Gives the result of multiplying A and A/B All number types Gives the result of dividing A by B A % B All number types Gives the remainder resulting from dividing A by B A & B All number types Gives the result of bitwise AND of A and B A | B All number types Gives the result of bitwise OR of A and B A ^ B All number types Gives the result of bitwise XOR of A and B ~A All number types Gives the result of bitwise NOT of A.
  • 18. Operator Operand types Description A AND B Boolean TRUE if both A and B are TRUE. Otherwise FALSE. NULL if A or B is NULL. A OR B Boolean RUE if either A or B or both are TRUE, FALSE OR NULL is NULL. Otherwise FALSE. NOT A Boolean TRUE if A is FALSE or NULL if A is NULL. Otherwise FALSE. ! A Boolean Same as NOT A.
  • 19. Operator Operand types Description A || B strings Concatenates the operands – shorthand for concat(A,B) Operator Operand types Description A[n] A is an Array and n is an int Returns the nth element in the array A. The first element has index 0 M[key] M is a Map<K, V> and key has type K Returns the value corresponding to the key in the map S.x S is a struct Returns the x field of S.