Apache Hive
Apache Hive is a data warehouse system on top of Hadoop that lets you query files in HDFS or object storage with HiveQL, a SQL dialect, and compiles each query into distributed jobs. Facebook built it around 2008 so analysts could write SQL instead of Java MapReduce programs, and it became an Apache top-level project in 2010. Hive introduced two ideas the whole data lake world still runs on: tables defined over folders of files (with partitions as sub-folders) and a central Metastore that records those tables. In 2026 few teams start new projects on the Hive engine, but the Hive Metastore and the Hive table layout are everywhere.
Tables are folders, partitions are sub-folders
A Hive table is metadata pointing at a directory. A partitioned table adds one sub-directory per partition value, so the engine can skip whole directories based on the WHERE clause:
CREATE EXTERNAL TABLE orders (id BIGINT, city STRING, amount DECIMAL(10,2))
PARTITIONED BY (dt STRING)
STORED AS PARQUET
LOCATION 's3://lake/orders/';- The data: one folder per day, Parquet files inside. The Metastore knows the schema, format, location and the list of partitions.
- A query arrives. Before reading any data, the engine asks the Metastore about orders.
- The filter is on the partition column dt, so two of the three folders cannot match. They are pruned without being listed or opened.
- Only the files under dt=2026-11-16/ are read. On a table with three years of data this is 1 folder out of about 1,100.
- The Metastore is a shared service: Spark, Trino, Flink and Hive all resolve orders to the same files. That shared catalog is Hive's lasting legacy.
Architecture
- HiveServer2: accepts JDBC/ODBC connections (for example from
beelineor BI tools), with authentication and concurrency. - Driver and compiler: parse HiveQL, check it against the Metastore, optimize it with a cost-based optimizer (Apache Calcite), and produce a DAG of tasks.
- Execution engine: Apache Tez runs the DAG on YARN. MapReduce execution has been deprecated since Hive 2, and Hive on Spark was removed in Hive 4. LLAP (Live Long and Process) adds long-running daemons with caching for faster interactive queries.
- Hive Metastore (HMS): a Thrift service backed by a relational database (MySQL or PostgreSQL) that stores databases, tables, columns, partitions and statistics.
Where Hive stands in 2026
- Hive 4 (4.0 released in 2024) is the maintained line, with Iceberg table support, improved ACID tables and many fixes. The 2.x and 3.x lines are end-of-life.
- The engine is mostly found in existing Hadoop estates and Cloudera deployments. New lakehouse projects usually run Spark SQL for batch and Trino for interactive queries.
- The Metastore remains widely used as a catalog by Spark, Trino, Presto, Flink and Impala. AWS Glue Data Catalog speaks a Hive-Metastore-compatible API. New platforms increasingly use Iceberg REST catalogs (Apache Polaris, Unity Catalog, AWS Glue, Nessie) instead.
- The Hive table format (a table is just a folder) has known limits: no atomic multi-file commits, slow listing of many partitions on object storage, and schema changes that can break readers. Apache Iceberg, Delta Lake and Hudi were created largely to fix these. See Data Lakehouse.
Key concepts
| Concept | What it means |
|---|---|
| Managed vs external table | DROP TABLE on a managed table deletes the data; on an external table it deletes only the metadata. |
| Partitioning | One folder per value of a low-cardinality column (date, country). Enables pruning. |
| Bucketing | Hash rows into a fixed number of files by a column, to speed up joins and sampling. |
| Schema-on-read | The schema is applied when files are read, not checked when they are written. |
| SerDe | Serializer/deserializer that tells Hive how to read a file format (Parquet, ORC, JSON, CSV). |
MSCK REPAIR TABLE |
Scans the table location and registers partition folders that were written without telling the Metastore. |
Common mistakes
- Partitioning by a high-cardinality column (user id, timestamp to the second): millions of tiny folders and a Metastore that slows to a crawl.
- Writing files directly to S3 and forgetting to add the partition, so queries silently return no rows for the new day.
- Comparing the partition column with a function (
WHERE to_date(dt) = ...), which can prevent pruning. Filter on the raw partition value. - Treating the Metastore database as unimportant. It is a single point of failure for every engine that uses it; back it up and monitor it.
Learning Resources
- Apache Hive website and Hive Wiki: Language Manual
- Hive: A Warehousing Solution Over a Map-Reduce Framework (VLDB 2009): the original paper
- Apache Hive: From MapReduce to Enterprise-grade Big Data Warehousing (SIGMOD 2019)
- Trino Hive connector: using the Metastore from Trino
- Apache Hive Introduction and Architecture: video
- Programming Hive, Edward Capriolo, Dean Wampler and Jason Rutherglen (older, but the data model chapters still apply)