EDUCBA

EDUCBA

MENUMENU
  • Blog
  • Free Courses
  • All Courses
  • All in One Bundle
  • Login
Home Data Science Data Science Tutorials Hive Tutorial HiveQL

HiveQL

By Priya PedamkarPriya Pedamkar

HiveQL

Introduction to HiveQL

Hive provides a CLI for the use of Hive query language to write Hive queries. HQL syntax is usually similar to the SQL syntax most data analysts know about. The SQL language of Hive distinguishes the user from the scope of the programming Map Reduce. It uses well-known concepts such as rows, tables, columns, and schemes from the relevant database environment to encourage learning. HiveQL’s syntax is generally similar to SQL, which is familiar to most data analysts. TEXT FILE, SEQUENCE FILE, ORC, and RCFILE (Column File Record) are four formats supported by Hive.

Working of HiveQL

Hive provides a SQL-like dialect for data manipulation, eliminating the need for us to write low-level MapReduce jobs to fetch data (through Mapper) and aggregate final results (through Reducer Modules).

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Executing Hive Query

Steps involved in executing a Hive query are:

  1. Hive interface (through CLI or Web UI) sends the query to Driver (which is JDBC, ODBC or Thrift Server) to compile, optimize and execute. It checks the query through a compiler for syntax and execution plan.
  2. Compiler sends a request to Metastore and receives Metadata as a response.
  3. The compiler communicates the execution plan back to the driver, which further sends it to the Execution engine.
  4. The execution engine interacts with the Job Tracker, which is the Name Node to get the job done.
  5. In parallel, an execution engine also executes Metadata operation.
  6. Name node gets the job done by Task tracker or Data nodes.
  7. Results that are shared with the execution engine, which then are displayed to the interface through the driver.

Optimization of Queries

Tuning HiveQL for better optimization of queries. Using the below-set commands, we can override the default configurations and enable faster query execution.

1. SET hive.execution.engine = tez

By default, the execution engine is set as Mapreduce, but we can explicitly set it to tez (for Hadoop 2 only) or Spark (for Hive 1.1. 0 onward).

2. SET hive.mapred.mode = unstrict

This is for dynamic partitioning, which helps load large data sets. However, static partitioning is set as default, which happens in “strict” mode.

3. SET hive.vectorized.execution = true

set hive.vectorized.execution.enabled = true

Vectorized query execution allows operation like –aggregates, filters or joins to happen in batches of 1024 rows instead of a single row at a time.

4. SET hive.auto.convert.join = true

While joining a large data set with a minimal data set, map joins are more efficient and can be set using the above command.

5. SET hive.exec.parallel = true

MapReduce jobs are executed in parallel in Hadoop. Sometimes, if queries are not dependent on one another, parallel execution can be favoured leading to better memory management.

6. SET hive.exec.compress.output=true

This enables the final output to be stored in HDFS in a compressed format.

7. SET hive.exec.compress.output = true

This enables the final output to be stored in HDFS in a compressed format.

Features of HiveQL

  1. Being a high-level language, Hive queries are implicitly converted to map-reduce jobs or complex DAGs (directed acyclic graphs). Using the ‘Explain’ keyword before the query, we can get the query plan.
  2. Faster query execution using Metadata storage in an RDMS format and replicates data, making retrieval easy in case of loss.
  3. Bitmap indexing is done to accelerate queries.
  4. Enhances performance by allowing partitioning of data.
  5. Hive can process different types of compressed files, thus saving disk space.
  6. To manipulate strings, integers or dates, HiveQL supports extending the user-defined functions (UDF), to solve problems not supported by built-in UDFs.
  7. It provides a range of additional APIs, to build a customized query engine.
  8. Different file formats are supported like Textfile, Sequencefile, ORC(Optimised Row Columnar), RCFile, Avro and Parquet. ORC file format is most suitable for improving query performance as it stores data in the most optimized way, leading to faster query execution.
  9. It is an efficient data analytics and ETL tool for large datasets 10. Easy to write queries as it is similar to SQL. DDL (Data definition language) commands in a hive are used to specify and change the database or tables’ structure in a hive. These commands are drop, create, truncate, alter, show or describe.

Limitations

  1. Hive queries have higher latency as Hadoop is a batch-oriented system.
  2. Nested or sub-queries are not supported.
  3. Update or delete or insert operation cannot be performed at a record level.
  4. Real-time data processing or querying is not offered through the Hive Scope of HQL.

With petabytes of data, ranging from billions to trillions of record, HiveQL has a large scope for big data professionals.

Scope of HiveQL

Below are how the scope of HiveQL widens and better serves to analyse humungous data generated by users every day.

Security: Along with processing large data, Hive provides data security. This task is complex for the distributed system, as multiple components are needed to communicate with each other. Kerberos authorization support allows authentication between client and server.

Locking: Traditionally, Hive lacks locking on rows, columns or queries. Hive can leverage Apache Zookeeper for locking support.

Workflow Management: Apache Oozie is a workflow scheduler to automate various HiveQL queries to execute sequentially or parallel.

Visualization: Zeppelin notebook is a web-based notebook, which enables interactive data analytics. It supports Hive and Sparks for data visualization and collaboration.

Conclusion

HiveQL is widely used across organizations to solve complex use cases. Keeping in mind the features and limitations offered by the language, Hive query language is used in telecommunications, healthcare, retail, banking, and financial services and even NASA’s Test Propulsion Laboratory’s Climate evaluation system. Ease of writing SQL like queries and commands accounts for wider acceptance. This field’s growing job opportunity lures fresher and professionals from different sectors to gain hands-on experience and knowledge about the field.

Recommended Articles

This is a guide to HiveQL. Here we discuss the Introduction to HiveQL, Optimizing Queries and its Limitations and Features. You can also go through our related articles to learn more –

  1. What is Hive Data Types?
  2. Hive Alternatives | Find out the Features
  3. Top Components of Hive Commands
  4. Top 10 Hive Interview Questions
  5. HQL | What is HQL?
  6. LIKE Query in SQL | How to Use?
SPSS Training Program
41+ Hours of HD Videos
14 Courses
5 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
MICROSOFT AZURE
97+ Hours of HD Videos
15 Courses
12 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
HADOOP Training Program
170+ Hours of HD Videos
32 Courses
4 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
INFORMATICA Training
69+ Hours of HD Videos
7 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Popular Course in this category
HIVE Training
 35+ Hours of HD Videos
7 Courses
Verifiable Certificate of Completion
  Lifetime Access
4.5
Price

View Course
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
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

ISO 10004:2018 & ISO 9001:2015 Certified

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

EDUCBA

*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
Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more