• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
EDUCBA

EDUCBA

MENUMENU
  • Resources
        • Data & Analytics Career

          • Big Data Analytics Jobs
          • Hadoop developer interview Questions
          • Big Data Vs Machine Learning
        • Data and Analytics Career
        • Interview Questions

          • Career in Cloud Computing Technology
          • Big Data interview questions
          • Data Scientist vs Machine Learning
        • Interview Questions
        • Machine Learning

          • What is Machine Learning
          • Machine Learning Tools
          • Neural Network Algorithms
        • Head to Head Differences
        • Others

          • Resources (A-Z)
          • Data and Analytics Basics
          • Business Analytics
          • View All
  • Free Courses
  • All Courses
        • Certification Courses

          Data Science Course
        • All in One Bundle

          All-in-One-Data-Science-Bundle
        • Machine Learning Course

          Machine-Learning-Training
        • Others

          • Hadoop Certification Training
          • Cloud Computing Training Course
          • R Programming Course
          • AWS Training Course
          • SAS Training Course
          • View All
  • 360+ Courses All in One Bundle
  • Login

Hive Data Types

Home » Data Science » Blog » Big Data » Hive Data Types

hive data type

What is a Hive?

Before understanding the Hive Data Types first we will study the hive. Hive is a data warehousing technique of Hadoop. Hadoop is the data storage and processing segment of Big data platform. Hive holds its position for sequel data processing techniques. Like other sequel environments hive can be reached through sequel queries. The major offerings by hive are data analysis, ad-hoc querying and summarize the stored data from a latency perspective, the queries go a greater amount.

Hive Data Types

Datatypes are classified into two types:

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

  • Primitive Data Types
  • Collective Data Types

1. Primitive Data Types

Primitive means were ancient and old. all datatypes listed as primitive are legacy ones. the important primitive datatypes areas listed below:

Type Size (byte) Example
TinyInt 1 20
SmallInt 2 20
Int 4 20
Bigint 8 20
Boolean Boolean true/False FALSE
Double 8 10.2222
Float 4 10.2222
String Sequence of characters ABCD
Timestamp Integer/float/string 2/3/2012 12:34:56:1234567
Date Integer/float/string 2/3/2019

Hive Data Types are Implemented using JAVA

Ex: Java Int is used for implementing the Int data type here.

  • Character arrays are not supported in HIVE.
  • Hive relies on delimiters to separate its fields, hive on coordinating with Hadoop allows to increase the write performance and read performance.
  • Specifying the length of each column is not expected in the hive database.
  • String literals can be articulated within either double quotes (“) single quotes (‘).
  • In a newer version of the hive, Varchar types are introduced and they form a span specifier of (amid 1 and 65535), So for a character string, this acts as the largest length of value which it can accommodate. When a value exceeding this length is inserted then the rightmost elements of that values are been truncated. Character length is resolution with the figure of code points controlled by the character string.
  • All integer literals (TINYINT, SMALLINT, BIGINT) are considered as INT datatypes basically, and only the length exceeds the actual int level it gets transmuted into a BIGINT or any other respective type.
  • Decimal literals afford defined values and superior collection for floating-point values when compared to the DOUBLE type. Here numeric values are stored on their exact form, but in the case of double, they are not stored exactly as numeric values.

Date Value Casting Process

Casting Performed Result
cast(date as date) Same date value
cast(timestamp as date) A local time zone is used to evaluate the Year/month/date values here and printed in the output.
cast(string as date)  A corresponding date value will be prompted as a result of this casting but we need to ensure the string is of the format ‘YYYY-MM-DD’ Null will be returned when the string value fails to make a valid match.
cast(date as timestamp) According to the current local timezone, a timestamp value will be created for this casting process
cast(date as string) YYYY-MM-DD is formed for the year/month/date value and the output will be of string format.

2. Collection Data Types

There are four collection datatypes in the hive they are also termed as complex data types.

  • ARRAY
  • MAP
  • STRUCT
  • UNIONTYPE

1. ARRAY: A sequence of elements of a common type that can be indexed and the index value starts from zero.

Code:

array (‘anand’, ‘balaa’, ‘praveeen’);

2. MAP: These are elements that are declared and retrieved using key-value pairs.

Popular Course in this category
Hadoop Certification Training (20 Courses, 14+ Projects) 20 Online Courses | 14 Hands-on Projects | 135+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (2,372 ratings)
Course Price

View Course

Related Courses
MapReduce Training (2 Courses, 4+ Projects)Splunk Training Certification (4 Courses, 7+ Projects)Apache Pig Training (2 Courses, 4+ Projects)

Code:

‘firstvalue’ -> ‘balakumaran’ , ‘lastvalue’ -> ‘pradeesh’ is represented as map(‘firstvalue’, ‘balakumaran’, ‘last’, ‘PG’). Now ‘balakumaran ‘ can be retrived with map[‘first’].

3. STRUCT: As in C, the struct is a datatype that accumulates a set of fields that are labeled and can be of any other data type.

Code:

For a column D of type STRUCT {Y INT; Z INT} the Y field can be retrieved by the expression D.Y

4. UNIONTYPE: Union can hold any one of the specified data types.

Code:

CREATE TABLE test(col1 UNIONTYPE<INT, DOUBLE, ARRAY<VARCHAR>>)

Output:

Hive Data Type1

Various Delimiters used in Complex Data Types are listed below,

Delimiter Code Description
\n \n Record or row delimiter
^A  (Ctrl+A) \001 Field delimiter
^B  (Ctrl+B) \002 STRUCTS and ARRAYS
^C  (Ctrl+C) \003 MAP’s

Complex Datatypes Example

Below are the examples of Complex Datatypes:

1. TABLE CREATION

Code:

create table store_complex_type (
emp_id int,
name string,
local_address STRUCT<street:string, city:string,country:string,zipcode:bigint>,
country_address MAP<STRING,STRING>,
job_history array<STRING>)
row format delimited fields terminated by ','
collection items terminated by ':'
map keys terminated by '_';

2. SAMPLE TABLE DATA

Code:

100 , Shan , 4th : CHN : IND : 600101 , CHENNAI_INDIA , SI : CSC
101 , Jai ,1th : THA : IND : 600096 , THANJAVUR_INDIA , HCL : TM
102 , Karthik , 5th : AP : IND : 600089 , RENIKUNDA_INDIA ,CTS : HCL

3. LOADING THE DATA

Code:

load data local inpath '/home/cloudera/Desktop/Hive_New/complex_type.txt' overwrite into table store_complex_type;

4. VIEWING THE DATA

Code:

select emp_id, name, local_address.city, local_address.zipcode, country_address['CHENNAI'], job_history[0] from store_complex_type where emp_id='100';

Conclusion – Hive Data Types

Being an on relational DB and yet a Sequel connects the HIVE offers all the key properties of usual SQL databases in a very sophisticated manner which makes this one among the more efficient structured data processing units in Hadoop.

Recommended Articles

This is a guide to Hive Data Type. Here we discuss two types in hive data types with proper examples. You can also go through our other related articles to learn more –

  1. What is a Hive?
  2. Hive Alternatives
  3. Hive Built-in Functions
  4. Hive Interview Questions
  5. PL/SQL Data Types
  6. Examples of Python Built-in Functions
  7. Different Types of SQL Data with Examples

All in One Data Science Bundle (360+ Courses, 50+ projects)

360+ Online Courses

50+ projects

1500+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Reader Interactions
Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar
Data Analytics Tutorials Tutorials
  • Big Data
    • Hive Data Types
    • Hadoop Schedulers
    • Azure IoT Edge
    • Cassandra Query Language
    • Hadoop Administrator
    • Hive Order By
    • Distributed Cache in Hadoop
    • Spark SQL Dataframe
    • Salesforce IoT Cloud
    • Cassandra Data Modeling
    • How MapReduce Works
    • Kafka Applications
    • Informatica ETL Tools
    • Cassandra Architecture
    • Docker Swarm Architecture
    • Hadoop FS Command List
    • Joins in Hive
    • Hadoop fs Commands
    • Hive Drop Table
    • Hive Alternatives
    • Advantages of Hadoop
    • HBase vs HDFS
    • AWS Firewall Manager
    • Applications of IoT
    • Data Warehouse Implementation
    • What is Git Fetch?
    • Spark Dataset
    • Ensemble Techniques
    • Kafka vs Spark
    • ETL vs ELT
    • Kubernetes Architecture
    • TensorFlow vs Spark
    • Ansible Architecture
    • Dimension Table
    • Talend Data Integration
    • Spark Stages
    • RDD in Spark
    • Spark Shell Commands
    • Install Hadoop
    • Data Lake vs Data Warehouse
    • Hadoop YARN Architecture
    • Spark DataFrame
    • HADOOP Framework
    • Big Data Architecture
    • Hive Architecture
    • Spark Streaming
    • What is Apache Tomcat?
    • Apache Hbase
    • The Most Critical Aspect of Big Data
    • Big data Concepts
    • Big Data Analytics in Hospitality Industry
    • HBase vs Cassandra
    • Apache Hadoop vs Apache Spark
    • Apache Hive vs Apache HBase
    • HADOOP vs RDBMS
    • Hadoop vs Hive
    • Big Data vs Data Science
    • MapReduce vs Spark
    • Hadoop vs Redshift
    • Small Data Vs Big Data
    • Big Data vs Apache Hadoop
    • Hadoop vs Elasticsearch
    • Apache Pig vs Apache Hive
    • Apache Storm vs Apache Spark
    • Hadoop vs HBase
    • Hadoop Vs SQL
    • Apache Storm vs Kafka
    • Apache Hadoop vs Apache Storm
    • HDFS vs Hbase
    • Hive vs HBase
    • Hive VS HUE
    • Apache Kafka vs Flume
    • Apache Spark vs Apache Flink
    • Apache Nifi vs Apache Spark
    • Big Data Vs Predictive Analytics
    • Apache Hive vs Apache Spark SQL
    • Hive vs Impala
    • Hadoop vs MapReduce
    • Business Intelligence vs Big Data
    • MapReduce vs Apache Spark
    • Hadoop vs Splunk
    • MapReduce vs Yarn
    • Hadoop vs Teradata
    • Pig vs Spark
    • Sqoop vs Flume
    • Hadoop vs Cassandra
    • Splunk vs Spark
    • PIG vs MapReduce
    • Splunk vs Elastic Search
    • Data Warehouse vs Hadoop
    • Is Big Data a Database
    • What is HDFS
    • Hadoop vs SQL Performance
    • Challenges of Big Data Analytics
    • Big Data Analytics Tools
    • Hadoop Administrator Jobs
    • Hadoop vs Apache Spark
    • Big Data vs Data Warehouse
    • Apache Spark Beginners
    • Hadoop vs Spark
    • Uses Of Splunk
    • Is Hadoop Open Source
    • Hive Function
    • Big Data Analytics Software
    • What is Big data analytics
    • Hive Commands
    • Sqoop Commands
    • Spark Commands
    • HBase Commands
    • Is Splunk Free
    • Introduction To Big Data
    • Splunk Alternatives
    • Big Data Analytics Examples
    • Hadoop Alternatives
    • How to Install Splunk
    • Pig Commands
    • What is Big data and Hadoop
    • What is Big Data Technology
    • What is Big Data
    • What is MapReduce
    • What is a Hive?
    • What is MapReduce in Hadoop
    • Splunk Commands
    • What is Apache Spark
    • Trends Of Big Data
    • Uses of Hadoop
    • YARN Package Manager
    • HDFS Architecture
    • Hadoop Components
    • Big Data Analytics
    • Hadoop Tools
    • What is HBase?
    • Hive String Functions
    • HBase Architecture
    • Hadoop Ecosystem Components
    • Hadoop Streaming
    • MapReduce Algorithms
    • Splunk vs Nagios
    • What is Splunk?
    • Hadoop Ecosystem
    • What is Kafka?
    • How to Install Kafka
    • What is Splunk Tool
    • Hadoop Database
    • What is Hadoop Cluster
    • Is Splunk Open Source
    • Hadoop Architecture
    • What is Pig
    • HDFS Commands
    • Big Data Confluence of Technology
  • Business Analytics (40+)
  • Cloud Computing (82+)
  • Data Analytics Basics (202+)
  • Data Analytics Careers (36+)
  • Data Mining (30+)
  • Data Visualization (88+)
  • Interview Questions (50+)
  • Machine Learning (141+)
  • Statistical Analysis (36+)
  • Data Commands (4+)
  • Power Bi (6+)
Data Analytics Tutorials Courses
  • Hadoop Certification Training
  • MapReduce Training
  • Splunk Training Certification
  • Apache Pig Training
Footer
About Us
  • Who is EDUCBA?
  • Sign Up
  •  
Free Courses
  • Free Course on Data Science
  • Free Course on Machine Learning
  • Free Coruse on Statistics
  • Free Course on Data Analytics
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course
  • Tableau Training
  • Azure Training Course
  • IoT Course
  • Minitab Training
  • SPSS Certification Course
  • Data Science with Python Course
Resources
  • Resources (A To Z)
  • Data & Analytics Career
  • Interview Questions
  • Data Visualization
  • Data and Analytics Basics
  • Cloud Computing
Apps
  • iPhone & iPad
  • Android
Support
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions

© 2019 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Let’s Get Started
Please provide your Email ID
Email ID is incorrect