Apache Hive Ultimate Tutorial For Beginners: Learn Hive from Scratch

Apache hive is an open-source data warehouse system built on top of Hadoop. It is used for querying and analyzing large datasets stored in Hadoop files. This Apache Hive tutorial will help you understand its basics, characteristics, and usage. 

In the digital age, about 2.5 quintillion bytes of data are generated every day. We need innovative technologies to contain this data explosion. And Hive is one such tool that processes structured and semi-structured data in the industry-leading Hadoop ecosystem. As more and more employers seek to leverage the capabilities of big data, they are looking for people who are well-versed with Hadoop tools. Therefore, a Hadoop Hive tutorial is an essential component of any big data course for beginners. 

What is Hive? Explain in simple terms.

Apache Hive allows developers to summarize data, run queries, and analyze large data sets. Built on top of the Hadoop Distributed File System (HDFS), it brings more structure to the data by organizing it into tables. Also, Hive uses its HiveQL or HQL language to perform SQL-like queries on the data.

While SQL is executed on traditional databases, HQL can automatically translate the queries into MapReduce jobs. Hive abstracts the complexity of Hadoop by converting SQL queries into a series of jobs to be executed on the Hadoop cluster. So, to master Apache Hive, you need a basic familiarity with SQL. But there is no need to learn Java. 

Moving on in our Apache Hive tutorial, let’s discuss its uses in the modern workplace environments.

Why do you need to use Hive?

Traditional database systems are not equipped to handle the large amount of data generated by big data applications today. And Hadoop is a framework that solves this problem. Various tools aid the Hadoop modules, Hive being one of them. With Apache Hive, you can perform the following tasks:

  • Tables can be portioned and bucketed, making it feasible to process data stored in the Hadoop Distributed File System (HDFS). Tables are defined directly in HDFS
  • JDBC/ODBC drivers are available for integration with traditional technologies
  • Provides schema flexibility and evolution along with data summarization, facilitating easier analyses
  • Saves you from writing complex Hadoop MapReduce jobs
  • The partition and bucket concept enables fast data retrieval
  • Very easy to learn and implement for SQL developers
  • Fast and scalable system
  • Hive supports different kinds of files, such as Text file, Sequence file, RC file, ORF file, Parquet file, and AVRO file

What are the major components of the Hive architecture?

1. User interface: Allows you to submit a query, process the instructions, and manage them. The Command Line Interface (CLI) and web UI allow external users to connect with Hive. 

2. Metastore: As the name suggests, the metastore holds the metadata of the database. It contains information about the scheme and location of tables. It also stores the partition metadata. Present on the traditional relational database, it allows you to monitor the distributed data in the cluster. It tracks the data, replicates it, and provides backup.

3. Driver: It is that part of the process engine that receives HiveQL statements. The driver creates sessions to execute the statement and monitors its lifecycle. It also stores the metadata generated during the statement’s execution. 

4. Compiler: This part of the HiveQL process engine converts the query into MapReduce inputs, such as Abstract Syntax Tree (AST) and Directed Acyclic Graph (DAG)

5. Optimizer: This component of the Hive architecture performs transformations in the execution plan to provide an optimized DAG. It splits the tasks for better performance. 

6. Executor: It schedules or pipelines the tasks to complete the execution process. For this, it interacts with the Hadoop job tracker.

Read: Hadoop Tutorial for Beginners

This Apache Hive tutorial cannot be complete without discussing how these Hive components interact with one another to carry out queries. So, we have listed the steps below.

Step 1: User enters a query into the CLI or Web UI, which forwards the query to the driver.

Step 2: The driver passes the query to the compiler for checking. The compiler ensures the accuracy of the syntax.

Step 3: The compiler requests the Metastore for the required metadata in order to proceed further.

Step 4: After receiving the metadata, the compiler re-sends the execution plan to the driver.

Step 5: The driver forwards this plan to the execution engine.

Step 6: The execution engine carries out the final stages. It sends the task to the JobTracker (Name node) within Hadoop’s MapReduce module.

Step 7: The JobTracker further assigns the task to the TaskTracker (Data node).

Step 8: The query is executed and sent back to the executor.

Step 9: The executor sends the results to the driver. 

Step 10: The driver forwards results to the user interface of Hive. 

Read: Hadoop Developer Salary in India

What do you know about Hive Shell?

Hive Shell allows users to run HQL queries. It is Hive’s command-line interface. You can run Hive Shell in two modes:

  • Non-interactive: Specify the location of the file containing HQL queries with the -f option. For example, hive -f my-script.q
  • Interactive: Go to the Hive Shell directly and submit queries manually to get the result. For example, $bin/hive, go to hive shell

List some limitations of Hive

  • It offers limited subquery support
  • Hive queries have high latency
  • Materialized views are not allowed in Apache Hive
  • It does not provide real-time queries, row-level updates, update and delete operations
  • Apache Hive is not suitable for online transitional process or OLTP

Summing up

In this Hadoop Hive tutorial, we covered different aspects of Hive, its usage, and architecture. We also delved into its working and discussed its limitations. All this information will help you start your Hive learning journey. After all, it is one of the most widely used and trusted big data frameworks! 

If you are interested to know more about Big Data, check out our PG Diploma in Software Development Specialization in Big Data program which is designed for working professionals and provides 7+ case studies & projects, covers 14 programming languages & tools, practical hands-on workshops, more than 400 hours of rigorous learning & job placement assistance with top firms.

Lead the Data Driven Technological Revolution

7 Case Studies & Projects. Job Assistance with Top Firms. Dedicated Student Mentor.
Learn More

Leave a comment

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

×
Aspire to be a Data Scientist
Download syllabus & join our Data Science Program and develop practical knowledge & skills.
Download syllabus
By clicking Download syllabus, I authorize upGrad and its representatives to contact me
via SMS / Email / Phone / WhatsApp / any other modes.
I agree to upGrad terms and conditions and our privacy policy.