Registry /
workflow / apache-airflow-providers-apache-hive
Install & Compatibility
Where this runs
tested against v9.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.960 runs
installs and imports cleanly · install 0.0s · import 5.236s · 414.9MB
glibcpy 3.10–3.960 runs
installs and imports cleanly · install 32.3s · import 4.850s · 408MB
389MB installed
● package 389MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
HiveOperator
✓ from airflow.providers.apache.hive.operators.hive import HiveOperator
✗ from airflow.contrib.operators.hive_operator import HiveOperator
Old contrib import for Airflow 1.x
HiveCliOperator
✓ from airflow.providers.apache.hive.operators.hive_cli import HiveCliOperator
✗ from airflow.contrib.operators.hive_cli_operator import HiveCliOperator
Old contrib import for Airflow 1.x
HiveHook
✓ from airflow.providers.apache.hive.hooks.hive import HiveHook
✗ from airflow.contrib.hooks.hive_hook import HiveHook
Old contrib import for Airflow 1.x
HiveCliHook
✓ from airflow.providers.apache.hive.hooks.hive_cli import HiveCliHook
✗ from airflow.contrib.hooks.hive_cli_hook import HiveCliHook
Old contrib import for Airflow 1.x
HivePartitionSensor
✓ from airflow.providers.apache.hive.sensors.hive_partition import HivePartitionSensor
✗ from airflow.contrib.sensors.hive_partition_sensor import HivePartitionSensor
Old contrib import for Airflow 1.x
This quickstart demonstrates a basic DAG using `HiveOperator` to execute HQL (Hive Query Language). It uses `hive_cli_conn_id='hive_cli_default'` which typically relies on the `hive` CLI being available in the Airflow worker's environment. For connecting to HiveServer2, configure a Hive connection in Airflow UI (e.g., `hive_default`) and use `hive_conn_id='hive_default'` in the operator, ensuring `pyhive` is installed.
from __future__ import annotations
import pendulum
from airflow.models.dag import DAG
from airflow.providers.apache.hive.operators.hive import HiveOperator
with DAG(
dag_id='hive_example_dag',
start_date=pendulum.datetime(2023, 1, 1, tz="UTC"),
catchup=False,
schedule=None,
tags=['hive', 'example'],
) as dag:
# Example of running a Hive query via HiveServer2 (requires 'hive_conn_id' and PyHive)
run_hive_query = HiveOperator(
task_id='run_hive_query',
hive_cli_conn_id='hive_cli_default', # Or 'hive_default' for HiveServer2 connection
hql='''
CREATE TABLE IF NOT EXISTS my_test_table (
id INT,
name STRING
);
INSERT INTO TABLE my_test_table VALUES (1, 'Alice');
SELECT COUNT(*) FROM my_test_table;
''',
# schema='default' # Optional: Specify the target schema
)
Debug
Known issues
breakingAirflow 1.x `contrib` operators/hooks were moved to provider packages in Airflow 2.x. Direct imports from `airflow.contrib` will fail.fixUpdate all imports from `airflow.contrib.operators.hive_operator` or similar to `airflow.providers.apache.hive.operators.hive` and corresponding paths for hooks and sensors.
affects: Airflow 2.0.0 and newer, apache-airflow-providers-apache-hive versions 1.0.0 and newer.
gotchaDistinction between `HiveCliOperator` (or `HiveOperator` with `hive_cli_conn_id`) and `HiveOperator` (with `hive_conn_id`). They use different underlying mechanisms and require different connection configurations.fix`HiveCliOperator` (and `HiveOperator` using `hive_cli_conn_id`) expects the `hive` command-line tool to be available on the Airflow worker and configured correctly. `HiveOperator` using `hive_conn_id` (HiveServer2) requires a DBAPI driver like `pyhive` and a proper HiveServer2 connection setup in Airflow UI.
affects: All versions of `apache-airflow-providers-apache-hive`.
gotchaMissing required underlying Python libraries for HiveServer2 connections (e.g., `pyhive`, `thrift-sasl`).fixInstall the necessary extras or packages: `pip install apache-airflow-providers-apache-hive[kerberos]` or manually `pip install pyhive thrift-sasl`. The specific requirements depend on the connection type (e.g., Kerberos, LDAP).
affects: All versions where `HiveHook` (used by `HiveOperator` with `hive_conn_id`) is used.
gotchaComplexities with Kerberos authentication for Hive connections.fixEnsure Kerberos client (`kinit`) is properly configured on the Airflow worker, keytabs are accessible, and `KRB5_KTNAME` environment variable is set if using a non-default keytab path. Also, install `apache-airflow-providers-apache-hive[kerberos]` and configure the Hive connection in Airflow UI with the 'Auth Mechanism' set to 'Kerberos'.
affects: All versions.
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyhive'
The `HiveHook` (used for HiveServer2 connections) requires the `pyhive` library, which is not a direct dependency of the provider package.
fixInstall `pyhive` along with the provider: `pip install apache-airflow-providers-apache-hive[kerberos]` (if using Kerberos) or `pip install pyhive` if not using any specific extras.
airflow.exceptions.AirflowException: Could not find `hive` command in the PATH. Please ensure Hive CLI is installed and configured.
The `HiveCliOperator` or `HiveOperator` configured to use `hive_cli_conn_id` cannot locate the `hive` command-line interface on the Airflow worker.
fixInstall Apache Hive client utilities on the Airflow worker machine and ensure the `hive` executable is in the system's PATH environment variable. Alternatively, switch to using `hive_conn_id` and `HiveOperator` with a HiveServer2 connection and `pyhive`.
pyhive.exc.OperationalError: TTransportException: Could not connect to ...
The `HiveHook` failed to establish a connection to HiveServer2. This can be due to incorrect host/port, network issues, or an inaccessible HiveServer2.
fixVerify the Hive connection details (host, port, schema) in the Airflow UI. Ensure HiveServer2 is running and accessible from the Airflow worker. Check firewall rules and network connectivity. Enable debug logging for `pyhive` for more detailed connection errors.
sqlalchemy.exc.DBAPIError: (pyhive.exc.OperationalError) TTransportException: GSS-API (or Kerberos) authentication failed
Kerberos authentication failed when `HiveHook` tried to connect to HiveServer2. This is often due to misconfigured keytab, principal, or client environment.
fixEnsure the Kerberos keytab is valid and accessible, the principal matches the service principal, and the `kinit` command can successfully obtain a ticket. Verify the Hive connection in Airflow UI has 'Auth Mechanism' set to 'Kerberos' and 'Principal' and 'Keytab Path' are correct. Install `apache-airflow-providers-apache-hive[kerberos]`.
Upgrade
Version history
9.5.0latest on PyPI · released May 23, 2026
Audit
Dependencies
apache-airflowrequiredCore Apache Airflow framework is required for all providers.
pyhiveoptionalRequired for `HiveHook` to connect to HiveServer2 via Thrift. Not a direct provider dependency, but an underlying requirement for common use cases.
thrift-sasloptionalRequired for SASL authentication, often used with Kerberos for `HiveHook`.