Bird
Raised Fist0
Hadoopdata~10 mins

Hive architecture in Hadoop - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Hive architecture
User submits Hive query
↓
Hive Driver parses query
↓
Compiler converts query to execution plan
↓
Metastore provides metadata
↓
Execution Engine runs plan
↓
Hadoop executes MapReduce or Tez jobs
↓
Results returned to User
This flow shows how a Hive query moves from user input through parsing, planning, execution, and finally returning results using Hadoop components.
Execution Sample
Hadoop
User submits: SELECT * FROM sales WHERE year=2023;
Driver parses query
Compiler creates execution plan
Metastore provides table info
Execution Engine runs plan
Hadoop runs MapReduce job
Results returned
This example traces a simple Hive query execution from submission to result.
Execution Table
StepActionComponentDetailsOutput
1Submit queryUserSELECT * FROM sales WHERE year=2023;Query string
2Parse queryDriverCheck syntax and semanticsParsed query tree
3Compile queryCompilerCreate execution plan (logical and physical)Execution plan
4Fetch metadataMetastoreGet table schema and partitionsMetadata info
5Execute planExecution EngineRun MapReduce or Tez jobs on HadoopJob execution
6Process dataHadoopMap and Reduce tasks process dataIntermediate results
7Return resultsExecution EngineCollect and send results to userQuery results
8EndSystemQuery completedResults delivered
💡 Query execution ends after results are returned to the user.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5After Step 7Final
querySELECT * FROM sales WHERE year=2023;Parsed query treeExecution planMetadata infoJob execution startedResults collectedResults delivered
Key Moments - 3 Insights
Why does Hive need the Metastore during query execution?
The Metastore provides the schema and partition info needed to plan and run the query correctly, as shown in step 4 of the execution_table.
What happens if the query syntax is wrong?
The Driver fails at step 2 during parsing, so the query does not proceed to compilation or execution.
How does Hive execute the query on data?
Hive converts the query into MapReduce or Tez jobs run by Hadoop, as shown in steps 5 and 6.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does Hive get the table schema?
AStep 4
BStep 2
CStep 5
DStep 7
💡 Hint
Check the 'Fetch metadata' action in the execution_table at step 4.
According to variable_tracker, what is the state of 'query' after step 3?
ARaw query string
BExecution plan
CParsed query tree
DResults delivered
💡 Hint
Look at the 'After Step 3' column for 'query' in variable_tracker.
If the query syntax is incorrect, which step will fail according to execution_table?
AStep 1
BStep 5
CStep 2
DStep 7
💡 Hint
Parsing happens at step 2; syntax errors stop execution there.
Concept Snapshot
Hive architecture flow:
User submits query -> Driver parses -> Compiler plans -> Metastore provides metadata -> Execution Engine runs jobs on Hadoop -> Results returned.
Metastore is key for schema info.
Execution uses MapReduce or Tez.
Driver stops on syntax errors.
Full Transcript
Hive architecture starts when a user submits a query. The Driver parses the query to check syntax and semantics. Then the Compiler creates an execution plan. The Metastore provides metadata like table schema and partitions. The Execution Engine runs the plan by launching MapReduce or Tez jobs on Hadoop. These jobs process data and produce results. Finally, results are returned to the user. If the query has syntax errors, parsing fails and execution stops early. The Metastore is essential for providing table information needed to run queries correctly.

Practice

(1/5)
1. What is the main role of the Hive Metastore in Hive architecture?
easy
A. It stores the actual data files in HDFS
B. It executes the SQL queries on Hadoop data
C. It manages user authentication and security
D. It stores metadata about tables and partitions

Solution

  1. Step 1: Understand the components of Hive architecture

    Hive architecture includes Metastore, Driver, Compiler, Execution Engine, and HDFS storage.
  2. Step 2: Identify the role of Metastore

    The Metastore stores metadata like table definitions, schema, and partition info, not the actual data.
  3. Final Answer:

    It stores metadata about tables and partitions -> Option D
  4. Quick Check:

    Metastore = Metadata storage [OK]
Hint: Metastore always holds metadata, not data itself [OK]
Common Mistakes:
  • Confusing Metastore with data storage
  • Thinking Metastore runs queries
  • Mixing Metastore with security management
2. Which of the following is the correct sequence of components involved when a Hive query is executed?
easy
A. Driver -> Compiler -> Metastore -> Execution Engine
B. Compiler -> Driver -> Execution Engine -> Metastore
C. Driver -> Compiler -> Execution Engine -> Metastore
D. Metastore -> Driver -> Compiler -> Execution Engine

Solution

  1. Step 1: Recall the Hive query execution flow

    The Driver receives the query, then the Compiler parses and plans it.
  2. Step 2: Understand component order

    The Compiler consults the Metastore for metadata, then the Execution Engine runs the tasks.
  3. Final Answer:

    Driver -> Compiler -> Metastore -> Execution Engine -> Option A
  4. Quick Check:

    Execution flow = Driver, Compiler, Metastore, Execution Engine [OK]
Hint: Driver starts, Compiler plans, Metastore provides metadata, then Execution Engine runs [OK]
Common Mistakes:
  • Mixing order of Compiler and Driver
  • Placing Metastore after Execution Engine
  • Ignoring Metastore's role in query planning
3. Given the following Hive query execution steps, which component is responsible for converting the query into a directed acyclic graph (DAG) of tasks?
SELECT * FROM sales WHERE year = 2023;
medium
A. Driver
B. Metastore
C. Compiler
D. Execution Engine

Solution

  1. Step 1: Identify the role of Compiler in Hive

    The Compiler parses the query and creates a logical plan, then converts it into a DAG of tasks.
  2. Step 2: Differentiate from other components

    The Driver manages the session, Metastore stores metadata, and Execution Engine runs the DAG tasks.
  3. Final Answer:

    Compiler -> Option C
  4. Quick Check:

    Compiler creates DAG = C [OK]
Hint: Compiler turns query into task graph (DAG) [OK]
Common Mistakes:
  • Thinking Driver creates the DAG
  • Confusing Metastore with query planning
  • Assuming Execution Engine creates the DAG
4. A Hive query fails with an error saying metadata not found for a table. Which component is most likely causing this error?
medium
A. Metastore
B. Compiler
C. Driver
D. Execution Engine

Solution

  1. Step 1: Understand the error context

    Metadata not found means Hive cannot find table schema or info.
  2. Step 2: Identify responsible component

    The Metastore stores all metadata; if missing, it causes this error.
  3. Final Answer:

    Metastore -> Option A
  4. Quick Check:

    Metadata error = Metastore issue [OK]
Hint: Metadata errors point to Metastore problems [OK]
Common Mistakes:
  • Blaming Execution Engine for metadata errors
  • Confusing Driver with metadata storage
  • Assuming Compiler handles metadata retrieval
5. You want to optimize Hive query execution by reducing the number of MapReduce jobs. Which Hive architecture component should you focus on tuning or configuring?
hard
A. Metastore
B. Execution Engine
C. Driver
D. Compiler

Solution

  1. Step 1: Identify which component runs jobs

    The Execution Engine runs the MapReduce or Tez jobs generated by Hive.
  2. Step 2: Understand optimization target

    Reducing jobs means tuning Execution Engine settings or choosing efficient engines like Tez or Spark.
  3. Final Answer:

    Execution Engine -> Option B
  4. Quick Check:

    Job optimization = Execution Engine tuning [OK]
Hint: Tune Execution Engine to reduce jobs and improve speed [OK]
Common Mistakes:
  • Trying to optimize Metastore for job count
  • Confusing Driver with job execution
  • Ignoring Execution Engine's role in running jobs
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard