Understanding Apache Hive Architecture

Apache Hive is a data warehousing infrastructure built on top of Apache Hadoop. It provides a SQL-like interface to query and analyze data stored in Hadoop Distributed File System (HDFS) and other compatible file systems. Hive is widely used in the industry for its scalability and ease of use.

Introduction to Apache Hive

link to this section

Apache Hive allows users to query and manage large datasets stored in Hadoop through a familiar SQL-like language called HiveQL. It translates HiveQL queries into MapReduce, Tez, or Spark jobs, depending on the execution engine being used. This enables users without strong programming skills to analyze and process big data efficiently.

Components of Apache Hive

link to this section


The Metastore is a central repository that stores metadata about Hive tables, including their schema, partition information, and location in HDFS. It uses a relational database (such as MySQL, PostgreSQL, or Derby) to store this metadata. The Metastore provides APIs for managing table metadata and is accessed by the Hive execution engine during query execution.

Hive Execution Engine

Hive supports multiple execution engines, including MapReduce, Tez, and Spark. The execution engine is responsible for translating HiveQL queries into executable tasks and executing them on the underlying Hadoop cluster. It interacts with the Metastore to retrieve table metadata and with the storage layer (HDFS) to read and write data.

Query Compiler and Optimizer

The Query Compiler parses HiveQL queries, validates their syntax, and generates an execution plan. The Optimizer applies various optimization techniques to the execution plan to improve query performance. These optimizations include predicate pushdown, join reordering, and partition pruning.

Storage Handler

The Storage Handler defines how data is stored and accessed in Hive tables. Hive supports various storage formats, including text, ORC, Parquet, and Avro. Each storage format has its own storage handler, which manages data serialization, compression, and other storage-related operations.

User Interface

Hive provides a command-line interface (CLI) and a web-based user interface (Hive Web UI) for interacting with the system. These interfaces allow users to execute queries, manage tables, and monitor query progress.

Query Execution Flow

link to this section

When a HiveQL query is submitted, the following steps occur:

  1. Parsing : The Query Compiler parses the query and validates its syntax.
  2. Semantic Analysis : The Compiler performs semantic analysis to validate table and column names and resolves references to table metadata.
  3. Optimization : The Optimizer applies optimization rules to the execution plan generated from the query.
  4. Execution Plan Generation : The Compiler generates an execution plan consisting of a sequence of MapReduce, Tez, or Spark tasks.
  5. Job Submission : The execution engine submits the tasks to the Hadoop cluster for execution.
  6. Execution : The tasks are executed on the cluster, and the results are returned to the user.


link to this section

Apache Hive provides a powerful platform for querying and analyzing large datasets stored in Hadoop. Its architecture consists of several components working together to translate SQL-like queries into distributed computation tasks. Understanding the architecture of Hive is essential for optimizing query performance and managing Hive deployments effectively.