Registry / workflow / apache-airflow-providers-apache-druid

apache-airflow-providers-apache-druid

JSON →
library4.5.2pypypi✓ verified 85d ago

The Apache Airflow Druid Provider enables Airflow to interact with Apache Druid, a high-performance, real-time analytics database. It includes hooks and operators for executing Druid queries and loading data. The current version is 4.5.2, and Airflow providers generally follow Airflow's release cadence, with updates for new features and bug fixes.

pip install apache-airflow-providers-apache-druid
INSTALL
IMPORT
SIG · APACHE-AIRFLOW-PRO
A
apache-airflow-providers-apache-druid
workflowpythonv4.5.2
Install
23.9s avg
Import
5201ms
Disk
251MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.5.2 · 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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 5.416s · 252MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 23.9s · import 4.986s · 250MB
251MB installed
● package 251MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DruidHook
from airflow.providers.apache.druid.hooks.druid import DruidHook
from airflow.contrib.hooks.druid_hook import DruidHook
Old import path from Airflow 1.x / contrib, not compatible with Airflow 2.x providers.
DruidOperator
from airflow.providers.apache.druid.operators.druid import DruidOperator
from airflow.contrib.operators.druid_operator import DruidOperator
Old import path from Airflow 1.x / contrib, not compatible with Airflow 2.x providers.
DruidToS3Operator
from airflow.providers.apache.druid.operators.druid_to_s3 import DruidToS3Operator

This quickstart demonstrates how to create an Airflow DAG that uses the `DruidOperator` to execute both SQL and native JSON queries against a Druid cluster. It assumes a Druid connection named `druid_default` is configured in Airflow. The examples show querying a 'wikipedia' datasource.

import os from datetime import datetime from airflow.models.dag import DAG from airflow.providers.apache.druid.operators.druid import DruidOperator # Ensure you have an Airflow connection named 'druid_default' # Or set one up: airflow connections add --conn-id druid_default --conn-type Druid --conn-host localhost --conn-port 8082 # For local testing, Druid usually runs on localhost:8082 by default DRUID_CONN_ID = os.environ.get('AIRFLOW_DRUID_CONN_ID', 'druid_default') with DAG( dag_id='druid_example_dag', start_date=datetime(2023, 1, 1), schedule=None, catchup=False, tags=['druid', 'example'], ) as dag: # Example of a simple Druid SQL query run_druid_sql_query = DruidOperator( task_id='run_druid_sql_query', druid_conn_id=DRUID_CONN_ID, sql_query="SELECT COUNT(*) FROM wikipedia WHERE __time >= CURRENT_TIMESTAMP - INTERVAL '1' DAY", ) # Example of a more complex Druid JSON query # This assumes a 'wikipedia' datasource exists run_druid_json_query = DruidOperator( task_id='run_druid_json_query', druid_conn_id=DRUID_CONN_ID, json_query={ "queryType": "timeseries", "dataSource": "wikipedia", "granularity": "day", "intervals": ["2016-06-01T00:00:00.000Z/2016-06-02T00:00:00.000Z"], "aggregations": [ {"type": "count", "name": "total_events"} ] }, ) run_druid_sql_query >> run_druid_json_query
Debug
Known issues
breakingMigration from Airflow 1.x to 2.x requires installing providers separately and updating import paths.
fix
Install `apache-airflow-providers-apache-druid` explicitly (`pip install ...`) and update all imports from `airflow.contrib.*` to `airflow.providers.apache.druid.*`.
affects: <2.0.0 (Airflow core) / <1.0.0 (provider)
gotchaDruidOperator supports both `sql_query` and `json_query`. Ensure you use only one and provide the correct query format.
fix
Use either `sql_query='SELECT ...'` for SQL or `json_query={...}` for native Druid queries, but not both simultaneously. Validate your JSON query structure against Druid's API documentation.
affects: All versions
gotchaThe `druid_conn_id` must reference a correctly configured Airflow connection of type 'Druid'. Misconfigured connections lead to errors.
fix
Verify your Airflow connection: `Admin -> Connections`. Ensure 'Conn Id' matches `druid_conn_id`, 'Conn Type' is 'Druid', and 'Host' and 'Port' are correct for your Druid router/broker.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'airflow.contrib.operators.druid_operator'
Using an old import path from Airflow 1.x or before the provider was separated.
fix
Install the provider (`pip install apache-airflow-providers-apache-druid`) and update your import statement to `from airflow.providers.apache.druid.operators.druid import DruidOperator`.
AirflowException: The Druid connection with conn_id 'my_druid_conn' is not found.
The specified `druid_conn_id` does not exist in your Airflow connections.
fix
Create an Airflow connection with the matching `conn_id` (e.g., 'my_druid_conn') and 'Conn Type' set to 'Druid' via the Airflow UI (Admin -> Connections) or CLI.
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The `json_query` parameter in `DruidOperator` was provided with an invalid JSON string or object.
fix
Ensure the `json_query` argument is a valid Python dictionary representing the Druid native query structure, or a properly formatted JSON string. If using `sql_query`, do not provide `json_query`.
Upgrade
Version history
4.5.2latest on PyPI · released Apr 12, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
43 hits · last 30 days
node
38
OpenAI (training)
1
Resources
apache-airflow-providers-apache-druid — pip install apache-airflow-providers-apache-druid · libregistry