Skip to content

Apache Airflow

Airflow 2 and 3 DAGs, runs, tasks, logs and assets as SQL tables

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/airflow/index.md to help me query Apache Airflow with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find paused workflows

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT dag_id, schedule, owners
FROM airflow.main.dags
WHERE is_paused AND is_active
ORDER BY dag_id

Quick start

Choose where to run Apache Airflow, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'airflow' AS airflow (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-airflow-worker'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

airflow credentials

Connection to one Airflow deployment's stable REST API: its base URL plus a bearer token, or a username and password (basic auth on Airflow 2, a /auth/token exchange on Airflow 3).

Get these credentials →
secret.sql
CREATE SECRET airflow (
    TYPE airflow,
    base_url    '<base_url>',  -- required
    token       '<AIRFLOW_TOKEN>',  -- secret
    username    '<username>',
    password    '<AIRFLOW_PASSWORD>',  -- secret
    auth        '<auth>',
    api_version '<api_version>',
    platform    '<platform>',
    page_size   '<page_size>',
    timeout     '<timeout>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT dag_id, schedule, owners
FROM airflow.main.dags
WHERE is_paused AND is_active
ORDER BY dag_id
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'airflow' AS airflow (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-airflow-worker'
);

Overview

Apache Airflow's stable REST API as SQL tables: DAGs, runs, task instances and their tries, task logs, XComs, assets, pools, variables, connections, import errors and the audit log, from Airflow 2 or 3.

Catalog

Everything airflow exposes once attached — read straight from the worker's released build.

airflow 2 schemas
main 12 tables · 2 functions

Airflow REST resources as tables: DAGs, runs, tasks, logs, assets, config and audit log.

Schema examples (14)
Examples (14)

Active DAGs that are paused

SELECT dag_id, schedule, owners
FROM airflow.main.dags
WHERE is_paused AND is_active
ORDER BY dag_id;

Failed runs of one DAG in November 2026 (dag_id, state and the date range are sent to the API)

SELECT run_id, logical_date, duration_seconds
FROM airflow.main.dag_runs
WHERE dag_id = 'etl_orders' AND state = 'failed' AND start_date >= TIMESTAMPTZ '2026-11-01'
ORDER BY logical_date;

Failed tasks of one DAG run

SELECT task_id, state, try_number, end_date
FROM airflow.main.task_instances
WHERE dag_id = 'flaky_report' AND run_id = 'manual_report_1' AND state IN ('failed', 'upstream_failed')
ORDER BY task_id;

Tasks that needed retries

SELECT dag_id, task_id, run_id, count(*) AS attempts
FROM airflow.main.task_instance_tries
WHERE dag_id = 'flaky_report'
GROUP BY ALL
HAVING count(*) > 1
ORDER BY attempts DESC;
10 more examples

XCom keys pushed in one DAG

SELECT task_id, key, count(*) AS entries
FROM airflow.main.xcom_entries
WHERE dag_id = 'etl_orders'
GROUP BY ALL
ORDER BY task_id;

Which tasks produce each asset and which DAGs consume it

SELECT uri, producing_tasks, consuming_dags
FROM airflow.main.assets
ORDER BY uri;

Asset updates per producing DAG and the runs they triggered

SELECT source_dag_id, count(*) AS updates,
  sum(len(created_runs)) AS triggered_runs
FROM airflow.main.asset_events
GROUP BY ALL
ORDER BY updates DESC;

Who triggered or paused DAGs

SELECT event_time, owner, event, dag_id
FROM airflow.main.event_logs
WHERE event IN ('trigger_dag_run', 'paused', 'patch_dag')
ORDER BY event_time DESC
LIMIT 20;

Broken DAG files

SELECT filename, timestamp, split_part(stack_trace, chr(10), -2) AS error
FROM airflow.main.import_errors
ORDER BY filename;

Pools that are nearly full

SELECT name, slots, open_slots
FROM airflow.main.pools
WHERE slots > 0 AND open_slots < slots * 0.1
ORDER BY name;

Variable keys and descriptions (values masked)

SELECT key, is_masked, description FROM airflow.main.variables ORDER BY key;

Connections per type

SELECT conn_type, count(*) AS n,
  list(connection_id ORDER BY connection_id) AS ids
FROM airflow.main.connections
GROUP BY conn_type
ORDER BY n DESC;

Error lines from every attempt of a failing task

SELECT try_number, timestamp, message
FROM airflow.main.task_logs('flaky_report', 'manual_report_1', 'render')
WHERE level = 'error'
ORDER BY try_number, line_number;

Non-secret variable values

SELECT key, value
FROM airflow.main.variable_values(reveal := true)
WHERE NOT is_masked
ORDER BY key;
Tables
asset_events 1 example11 cols

Asset (dataset) update events and the DAG runs they triggered.

Columns
event_idnot null BIGINT
Asset event identifier (integer assigned by Airflow).
asset_id BIGINT
Identifier (integer) of the asset (dataset) that was updated; joins assets.asset_id.
uri VARCHAR
Asset URI.
name VARCHAR
Asset name (Airflow 3; the URI on 2.x).
timestamp TIMESTAMP WITH TIME ZONE
When the event was emitted.
source_dag_id VARCHAR
DAG whose task emitted the event.
source_task_id VARCHAR
Task that emitted the event.
source_run_id VARCHAR
Run that emitted the event.
source_map_index BIGINT
Map index of the emitting task (-1 when not mapped).
extra JSON
Event extra (JSON).
created_runs STRUCT(dag_id VARCHAR, run_id VARCHAR)[]
DAG runs the event triggered.
ConstraintsPRIMARY KEY (event_id) · FOREIGN KEY (asset_id) REFERENCES assets(asset_id)
Example

Asset updates per producing DAG and the runs they triggered

SELECT source_dag_id, count(*) AS updates,
  sum(len(created_runs)) AS triggered_runs
FROM airflow.main.asset_events
GROUP BY ALL
ORDER BY updates DESC;
Link
assets 1 example9 cols

Airflow assets (Airflow 2 datasets) with producing tasks and consuming DAGs.

Columns
asset_idnot null BIGINT
Asset (2.x: dataset) identifier (integer assigned by Airflow).
name VARCHAR
Asset name (Airflow 3; the URI on 2.x).
uri VARCHAR
Asset URI, e.g. s3://bucket/key.
asset_group VARCHAR
Asset group (Airflow 3).
extra JSON
Extra metadata attached to the asset (JSON).
created_at TIMESTAMP WITH TIME ZONE
When the asset was first seen.
updated_at TIMESTAMP WITH TIME ZONE
When the asset was last updated.
consuming_dags VARCHAR[]
DAGs scheduled on this asset.
producing_tasks STRUCT(dag_id VARCHAR, task_id VARCHAR)[]
Tasks that list this asset as an outlet.
ConstraintsPRIMARY KEY (asset_id)
Example

Which tasks produce each asset and which DAGs consume it

SELECT uri, producing_tasks, consuming_dags
FROM airflow.main.assets
ORDER BY uri;
Link
connections 1 example9 cols

Airflow connections without passwords; secret-looking extra fields masked.

Columns
connection_idnot null VARCHAR
Name hooks and operators use to look the connection up, e.g. 'warehouse_pg'.
conn_type VARCHAR
Connection type, e.g. postgres, http, aws.
description VARCHAR
Connection description.
host VARCHAR
Server host name or base URL the connection points at.
port BIGINT
TCP port number (index 1-65535), when set.
login VARCHAR
Login / user name.
schema VARCHAR
Schema or database.
has_password BOOLEAN
True when a password is set (Airflow 3; NULL on 2.x).
extra JSON
Extra JSON with secret-looking keys replaced by '***'.
ConstraintsPRIMARY KEY (connection_id)
Example

Connections per type

SELECT conn_type, count(*) AS n,
  list(connection_id ORDER BY connection_id) AS ids
FROM airflow.main.connections
GROUP BY conn_type
ORDER BY n DESC;
Link
dag_runs 2 examples17 cols

Airflow DAG runs with state, run type, logical date and timings.

Columns
dag_idnot null VARCHAR
DAG the run belongs to.
run_idnot null VARCHAR
Run identifier, unique within the DAG.
state VARCHAR
Run state: queued, running, success or failed.
run_type VARCHAR
manual, scheduled, backfill, asset_triggered (3.x) or dataset_triggered (2.x).
triggered_by VARCHAR
What triggered the run, e.g. rest_api, ui, cli, timetable, asset (3.x).
logical_date TIMESTAMP WITH TIME ZONE
Logical date (Airflow 2 execution_date); NULL for some 3.x asset/manual runs.
queued_at TIMESTAMP WITH TIME ZONE
When the run was queued.
start_date TIMESTAMP WITH TIME ZONE
When the run started.
end_date TIMESTAMP WITH TIME ZONE
When the run finished.
duration_seconds DOUBLE
end_date - start_date in seconds.
data_interval_start TIMESTAMP WITH TIME ZONE
Start of the data interval.
data_interval_end TIMESTAMP WITH TIME ZONE
End of the data interval.
run_after TIMESTAMP WITH TIME ZONE
Earliest time the run could start (Airflow 3).
last_scheduling_decision TIMESTAMP WITH TIME ZONE
Last time the scheduler evaluated the run.
conf JSON
Run configuration (JSON).
note VARCHAR
User note on the run.
triggering_user_name VARCHAR
User who triggered the run (Airflow 3).
ConstraintsPRIMARY KEY (dag_id, run_id) · FOREIGN KEY (dag_id) REFERENCES dags(dag_id)
Examples (2)

Failed runs of one DAG in November 2026 (dag_id, state and the date range are sent to the API)

SELECT run_id, logical_date, duration_seconds
FROM airflow.main.dag_runs
WHERE dag_id = 'etl_orders' AND state = 'failed' AND start_date >= TIMESTAMPTZ '2026-11-01'
ORDER BY logical_date;

Run outcomes and median duration per DAG

SELECT dag_id, state, count(*) AS runs, median(duration_seconds) AS median_s
FROM airflow.main.dag_runs
GROUP BY ALL
ORDER BY dag_id, state;
Link
dags 2 examples17 cols

Airflow DAGs: schedule, paused/active flags, owners, tags and next run.

Columns
dag_idnot null VARCHAR
DAG identifier.
dag_display_name VARCHAR
Display name shown in the UI.
description VARCHAR
DAG description.
is_paused BOOLEAN
True when the DAG is paused (no new scheduled runs).
is_active BOOLEAN
True when the DAG file still defines the DAG (Airflow 3: not stale).
has_import_errors BOOLEAN
True when the DAG's file currently fails to import.
schedule VARCHAR
Schedule expression, e.g. '0 0 * * *', '@daily' or an asset condition.
timetable_description VARCHAR
Human-readable schedule description.
owners VARCHAR[]
DAG owners.
tags VARCHAR[]
DAG tags.
fileloc VARCHAR
Absolute path of the file that defines the DAG.
bundle_name VARCHAR
DAG bundle the file comes from (Airflow 3; NULL on 2.x).
max_active_runs BIGINT
Maximum number of concurrent runs (count).
max_active_tasks BIGINT
Maximum number of concurrent task instances (count).
next_dagrun_logical_date TIMESTAMP WITH TIME ZONE
Logical date of the next scheduled run.
next_dagrun_run_after TIMESTAMP WITH TIME ZONE
Earliest time the next scheduled run is created.
last_parsed_time TIMESTAMP WITH TIME ZONE
When the DAG file was last parsed.
ConstraintsPRIMARY KEY (dag_id)
Examples (2)

Active DAGs that are paused

SELECT dag_id, schedule, owners
FROM airflow.main.dags
WHERE is_paused AND is_active
ORDER BY dag_id;

DAG count per tag

SELECT tag, count(*) AS dags
FROM (SELECT unnest(tags) AS tag FROM airflow.main.dags)
GROUP BY tag
ORDER BY dags DESC;
Link
event_logs 1 example11 cols

The Airflow audit log: who did what to which DAG, run or task, and when.

Columns
event_log_idnot null BIGINT
Audit log entry identifier (integer, increasing in time).
event_time TIMESTAMP WITH TIME ZONE
When the event happened (Airflow's `when`).
event VARCHAR
Event name, e.g. cli_scheduler, trigger_dag_run, failed, running.
owner VARCHAR
User or system that caused the event.
dag_id VARCHAR
DAG involved, when any.
task_id VARCHAR
Task involved, when any.
run_id VARCHAR
Run involved, when any.
map_index BIGINT
Map index of the task involved (-1 when not mapped), when any.
try_number BIGINT
Attempt number (count from 1) of the task involved, when any.
logical_date TIMESTAMP WITH TIME ZONE
Logical date of the run, when any.
extra JSON
Detail recorded with the event (JSON; free text is stored as a JSON string).
ConstraintsPRIMARY KEY (event_log_id)
Example

Who triggered or paused DAGs

SELECT event_time, owner, event, dag_id
FROM airflow.main.event_logs
WHERE event IN ('trigger_dag_run', 'paused', 'patch_dag')
ORDER BY event_time DESC
LIMIT 20;
Link
import_errors 1 example5 cols

DAG files that currently fail to import, with their stack traces.

Columns
import_error_idnot null BIGINT
Identifier (integer) Airflow assigns to the failing file's error record.
timestamp TIMESTAMP WITH TIME ZONE
When the file last failed to import.
filename VARCHAR
DAG file that failed (relative to its bundle on Airflow 3).
bundle_name VARCHAR
DAG bundle (Airflow 3).
stack_trace VARCHAR
Python traceback of the failure.
ConstraintsPRIMARY KEY (import_error_id)
Example

Broken DAG files

SELECT filename, timestamp, split_part(stack_trace, chr(10), -2) AS error
FROM airflow.main.import_errors
ORDER BY filename;
Link
pools 1 example10 cols

Airflow pools and their slot usage.

Columns
namenot null VARCHAR
Pool name.
slots BIGINT
Total number of slots (count; -1 means unlimited).
occupied_slots BIGINT
Number of slots in use (count: running + queued, plus deferred when counted).
running_slots BIGINT
Number of slots used by running tasks (count).
queued_slots BIGINT
Number of slots used by queued tasks (count).
scheduled_slots BIGINT
Number of slots used by scheduled tasks (count).
deferred_slots BIGINT
Number of slots used by deferred tasks (count).
open_slots BIGINT
Number of free slots (count).
include_deferred BOOLEAN
Whether deferred tasks count against the pool.
description VARCHAR
Pool description.
ConstraintsPRIMARY KEY (name)
Example

Pools that are nearly full

SELECT name, slots, open_slots
FROM airflow.main.pools
WHERE slots > 0 AND open_slots < slots * 0.1
ORDER BY name;
Link
task_instance_tries 1 example20 cols

Every attempt of every Airflow task instance (retries included).

Columns
dag_idnot null VARCHAR
DAG the task belongs to.
run_idnot null VARCHAR
DAG run the task instance belongs to.
task_idnot null VARCHAR
Task identifier within the DAG.
map_indexnot null BIGINT
Index of a mapped task instance; -1 when not mapped.
try_number BIGINT
Current (latest) try number; 0 when it never ran.
state VARCHAR
success, failed, upstream_failed, skipped, running, queued, scheduled, up_for_retry, deferred, removed, NULL.
operator VARCHAR
Operator class, e.g. PythonOperator or _PythonDecoratedOperator.
start_date TIMESTAMP WITH TIME ZONE
When the current try started.
end_date TIMESTAMP WITH TIME ZONE
When the current try finished.
duration_seconds DOUBLE
Duration of the current try in seconds.
queued_when TIMESTAMP WITH TIME ZONE
When the task instance was queued.
hostname VARCHAR
Worker host that ran the try.
pool VARCHAR
Pool the task runs in.
pool_slots BIGINT
Number of pool slots the task occupies (count).
queue VARCHAR
Executor queue.
priority_weight BIGINT
Scheduling priority weight (higher runs first; unitless score).
executor VARCHAR
Executor name, when set.
pid BIGINT
Operating-system process id (PID) of the try.
uuid VARCHAR
Airflow 3 UUID of this task instance try (NULL on 2.x).
max_tries BIGINT
Number of retries allowed at the time of the try (count).
ConstraintsPRIMARY KEY (dag_id, run_id, task_id, map_index, try_number) · FOREIGN KEY (dag_id, run_id, task_id, map_index) REFERENCES task_instances(dag_id, run_id, task_id, map_index)
Example

Tasks that needed retries

SELECT dag_id, task_id, run_id, count(*) AS attempts
FROM airflow.main.task_instance_tries
WHERE dag_id = 'flaky_report'
GROUP BY ALL
HAVING count(*) > 1
ORDER BY attempts DESC;
Link
task_instances 2 examples22 cols

Airflow task instances (latest try) with state, operator, timings and pool.

Columns
dag_idnot null VARCHAR
DAG the task belongs to.
run_idnot null VARCHAR
DAG run the task instance belongs to.
task_idnot null VARCHAR
Task identifier within the DAG.
map_indexnot null BIGINT
Index of a mapped task instance; -1 when not mapped.
try_number BIGINT
Current (latest) try number; 0 when it never ran.
max_tries BIGINT
Number of retries allowed (count).
state VARCHAR
success, failed, upstream_failed, skipped, running, queued, scheduled, up_for_retry, deferred, removed, NULL.
operator VARCHAR
Operator class, e.g. PythonOperator or _PythonDecoratedOperator.
logical_date TIMESTAMP WITH TIME ZONE
Logical date of the DAG run.
start_date TIMESTAMP WITH TIME ZONE
When the current try started.
end_date TIMESTAMP WITH TIME ZONE
When the current try finished.
duration_seconds DOUBLE
Duration of the current try in seconds.
queued_when TIMESTAMP WITH TIME ZONE
When the task instance was queued.
hostname VARCHAR
Worker host that ran the try.
pool VARCHAR
Pool the task runs in.
pool_slots BIGINT
Number of pool slots the task occupies (count).
queue VARCHAR
Executor queue.
priority_weight BIGINT
Scheduling priority weight (higher runs first; unitless score).
executor VARCHAR
Executor name, when set.
pid BIGINT
Operating-system process id (PID) of the try.
note VARCHAR
User note on the task instance.
uuid VARCHAR
Airflow 3 UUID of this task instance try (NULL on 2.x).
ConstraintsPRIMARY KEY (dag_id, run_id, task_id, map_index) · FOREIGN KEY (dag_id, run_id) REFERENCES dag_runs(dag_id, run_id)
Examples (2)

Failed tasks of one DAG run

SELECT task_id, state, try_number, end_date
FROM airflow.main.task_instances
WHERE dag_id = 'flaky_report' AND run_id = 'manual_report_1' AND state IN ('failed', 'upstream_failed')
ORDER BY task_id;

Slowest tasks across all runs

SELECT dag_id, task_id, max(duration_seconds) AS worst_s
FROM airflow.main.task_instances
WHERE state = 'success'
GROUP BY ALL
ORDER BY worst_s DESC
LIMIT 10;
Link
variables 1 example5 cols

Airflow variables with every value masked ('***').

Columns
keynot null VARCHAR
Variable key.
value VARCHAR
Value, or '***' when masked.
is_masked BOOLEAN
True when value is withheld.
description VARCHAR
Variable description.
is_encrypted BOOLEAN
Whether Airflow stores the value encrypted (Airflow 3).
ConstraintsPRIMARY KEY (key)
Example

Variable keys and descriptions (values masked)

SELECT key, is_masked, description FROM airflow.main.variables ORDER BY key;
Link
xcom_entries 1 example7 cols

XCom entries (keys, not values) pushed by Airflow tasks.

Columns
dag_idnot null VARCHAR
DAG of the task that pushed the XCom.
run_idnot null VARCHAR
DAG run (Airflow 2 omits it; the worker resolves it from the logical date).
task_idnot null VARCHAR
Task that pushed the XCom.
map_indexnot null BIGINT
Mapped task index; -1 when not mapped.
keynot null VARCHAR
XCom key, e.g. return_value.
timestamp TIMESTAMP WITH TIME ZONE
When the XCom was written.
logical_date TIMESTAMP WITH TIME ZONE
Logical date of the run.
ConstraintsPRIMARY KEY (dag_id, run_id, task_id, map_index, key) · FOREIGN KEY (dag_id, run_id, task_id, map_index) REFERENCES task_instances(dag_id, run_id, task_id, map_index)
Example

XCom keys pushed in one DAG

SELECT task_id, key, count(*) AS entries
FROM airflow.main.xcom_entries
WHERE dag_id = 'etl_orders'
GROUP BY ALL
ORDER BY task_id;
Link
Table functions
task_logs (dag_id VARCHAR, run_id VARCHAR, task_id VARCHAR, map_index := BIGINT, try_number := BIGINT) 2 examples

Log lines of one Airflow task instance, every attempt or one try_number

Positional arguments
dag_id VARCHAR
DAG id, e.g. 'etl_orders'.
run_id VARCHAR
DAG run id, e.g. 'manual__2026-11-15T00:00:00+00:00'.
task_id VARCHAR
Task id within the DAG, e.g. 'load'.
Named arguments
map_index := BIGINT
Mapped task index; -1 (default) for an unmapped task. · default -1
try_number := BIGINT
Attempt to read (1-based); NULL (default) reads every attempt. · default null
Returns columns
dag_id VARCHAR
DAG id.
run_id VARCHAR
DAG run id.
task_id VARCHAR
Task id.
map_index BIGINT
Mapped task index; -1 when not mapped.
try_number BIGINT
Attempt the line belongs to.
line_number BIGINT
1-based position of the line within the attempt's log.
timestamp TIMESTAMPTZ
Timestamp of the log record, when the line carries one.
level VARCHAR
Log level in lower case (info, warning, error, ...), when known.
logger VARCHAR
Logger (Airflow 3) or source file:line (Airflow 2), when known.
message VARCHAR
The log message (Airflow 3 event text; one raw text line on 2.x).
details JSON
Remaining structured fields of an Airflow 3 record, e.g. error_detail (JSON).
Examples (2)

Error lines from every attempt of a failing task

SELECT try_number, timestamp, message
FROM airflow.main.task_logs('flaky_report', 'manual_report_1', 'render')
WHERE level = 'error'
ORDER BY try_number, line_number;

Log volume per level for one attempt

SELECT level, count(*) AS lines
FROM airflow.main.task_logs('etl_orders', 'manual_orders_1', 'load', try_number := 1)
GROUP BY level
ORDER BY lines DESC;
Link
variable_values (reveal := BOOLEAN) 1 example

Airflow variables; reveal := true shows values whose key and value do not look secret

Named arguments
reveal := BOOLEAN
Show values whose key and value do not look secret. Default false: every value is '***'. · default false
Returns columns
key VARCHAR
Variable key.
value VARCHAR
Value, or '***' when masked.
is_masked BOOLEAN
True when value is withheld.
description VARCHAR
Variable description.
is_encrypted BOOLEAN
Whether Airflow stores the value encrypted (Airflow 3).
Example

Non-secret variable values

SELECT key, value
FROM airflow.main.variable_values(reveal := true)
WHERE NOT is_masked
ORDER BY key;
Link
unified 2 tables · 1 function

Runs and task runs in the cross-orchestrator shape shared by Query.Farm workers.

Schema examples (3)
Examples (3)

Runs per status

SELECT status, count(*) AS runs
FROM airflow.unified.runs
GROUP BY status
ORDER BY status;

Task outcomes joined to their runs

SELECT r.pipeline, t.status, count(*) AS tasks
FROM airflow.unified.task_runs t
JOIN airflow.unified.runs r USING (run_id)
GROUP BY ALL
ORDER BY r.pipeline, t.status;

Task instances per unified status

SELECT airflow.unified.unified_status(state) AS status, count(*) AS tasks
FROM airflow.main.task_instances
GROUP BY ALL
ORDER BY status;
Tables
runs 2 examples11 cols

Airflow DAG runs in the cross-orchestrator unified.runs shape.

Columns
orchestratornot null VARCHAR
Always 'airflow'.
run_idnot null VARCHAR
'<dag_id>/<dag_run_id>' (Airflow run ids are unique only per DAG).
pipeline VARCHAR
DAG id.
statusnot null VARCHAR
queued, running, success, failed, cancelled or skipped.
raw_status VARCHAR
Airflow's own DAG-run state.
trigger VARCHAR
schedule, manual, api, event or other.
queued_at TIMESTAMP WITH TIME ZONE
When the run was queued.
started_at TIMESTAMP WITH TIME ZONE
When the run started.
ended_at TIMESTAMP WITH TIME ZONE
When the run finished.
duration_seconds DOUBLE
ended_at - started_at in seconds.
url VARCHAR
Link to the run in the Airflow UI.
ConstraintsPRIMARY KEY (run_id)
Examples (2)

Runs per status

SELECT status, count(*) AS runs
FROM airflow.unified.runs
GROUP BY status
ORDER BY status;

Failure rate per pipeline since November

SELECT pipeline, avg((status = 'failed')::INT) AS failure_rate
FROM airflow.unified.runs
WHERE started_at >= TIMESTAMPTZ '2026-11-01'
GROUP BY pipeline
ORDER BY failure_rate DESC;
Link
task_runs 1 example11 cols

Airflow task instances in the cross-orchestrator unified.task_runs shape.

Columns
orchestratornot null VARCHAR
Always 'airflow'.
run_idnot null VARCHAR
'<dag_id>/<dag_run_id>', joins unified.runs.run_id.
task_run_idnot null VARCHAR
'<dag_id>/<dag_run_id>/<task_id>', plus '/<map_index>' for mapped tasks.
task_name VARCHAR
Task id.
statusnot null VARCHAR
queued, running, success, failed, cancelled or skipped.
raw_status VARCHAR
Airflow's own task-instance state.
attempt INTEGER
Try number of the latest attempt (0 = never ran).
started_at TIMESTAMP WITH TIME ZONE
When the latest attempt started.
ended_at TIMESTAMP WITH TIME ZONE
When the latest attempt finished.
duration_seconds DOUBLE
Duration of the latest attempt in seconds.
url VARCHAR
Link to the task instance in the Airflow UI.
ConstraintsPRIMARY KEY (task_run_id) · FOREIGN KEY (run_id) REFERENCES runs(run_id)
Example

Task outcomes joined to their runs

SELECT r.pipeline, t.status, count(*) AS tasks
FROM airflow.unified.task_runs t
JOIN airflow.unified.runs r USING (run_id)
GROUP BY ALL
ORDER BY r.pipeline, t.status;
Link
Scalar functions
unified_status (state VARCHAR) 3 examples

Map an Airflow DAG-run or task state onto queued/running/success/failed/cancelled/skipped

Arguments
state VARCHAR
An Airflow DAG-run or task-instance state string as the Airflow API reports it. NULL means the task was not yet scheduled.
ReturnsVARCHAR
Examples (3)

Task instances per unified status

SELECT airflow.unified.unified_status(state) AS status, count(*) AS tasks
FROM airflow.main.task_instances
GROUP BY ALL
ORDER BY status;
SELECT s AS state, airflow.unified.unified_status(s) AS status
FROM (VALUES ('success'), ('failed'), ('upstream_failed'), ('up_for_retry'), ('removed')) t(s)
ORDER BY s;
SELECT airflow.unified.unified_status(NULL::VARCHAR) AS status;
Link

Credentials

The secret type airflow declares, as reported by the worker itself.

airflow

How to get these credentials

Connection to one Airflow deployment's stable REST API: its base URL plus a bearer token, or a username and password (basic auth on Airflow 2, a /auth/token exchange on Airflow 3).

secret.sql
CREATE SECRET airflow (
    TYPE airflow,
    base_url    '<base_url>',  -- required
    token       '<AIRFLOW_TOKEN>',  -- secret
    username    '<username>',
    password    '<AIRFLOW_PASSWORD>',  -- secret
    auth        '<auth>',
    api_version '<api_version>',
    platform    '<platform>',
    page_size   '<page_size>',
    timeout     '<timeout>'
);
Key Type Required Description
base_url VARCHAR Yes Root URL of the Airflow webserver / API server, without /api/v1 or /api/v2, e.g. 'http://localhost:8080' or an Astronomer deployment URL.
token secret VARCHAR No Bearer token: an Airflow 3 JWT, an Astronomer deployment API token, or a Cloud Composer OAuth access token. Takes precedence over username/password.
username VARCHAR No Airflow username for basic auth (2.x) or the /auth/token exchange (3.x).
password secret VARCHAR No Password for `username`.
auth VARCHAR No How to authenticate: 'auto' (default; token if set, else basic on 2.x and /auth/token on 3.x), 'token', 'basic' or 'password' (force the Airflow 3 /auth/token exchange).
api_version VARCHAR No 'auto' (default; probe /api/v2/version), 'v1' (Airflow 2.x) or 'v2' (Airflow 3.x).
platform VARCHAR No Hosting flavour: 'airflow' (default, self-managed), 'astronomer' or 'composer' (both bearer token). 'mwaa' is reserved and not yet supported.
page_size BIGINT No Items requested per API page, 1 to 1000 (default 100).
timeout DOUBLE No Per-request timeout in seconds (default 30).

Needed by task_logsvariable_values

Create the secret in the same session, after attaching airflow — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

Failed runs of one DAG in November 2026 (dag_id, state and the date range are sent to the API)

SELECT run_id, logical_date, duration_seconds
FROM airflow.main.dag_runs
WHERE dag_id = 'etl_orders' AND state = 'failed' AND start_date >= TIMESTAMPTZ '2026-11-01'
ORDER BY logical_date

Uses dag_runs

Failed tasks of one DAG run

SELECT task_id, state, try_number, end_date
FROM airflow.main.task_instances
WHERE dag_id = 'flaky_report' AND run_id = 'manual_report_1' AND state IN ('failed', 'upstream_failed')
ORDER BY task_id

Uses task_instances

Tasks that needed retries

SELECT dag_id, task_id, run_id, count(*) AS attempts
FROM airflow.main.task_instance_tries
WHERE dag_id = 'flaky_report'
GROUP BY ALL
HAVING count(*) > 1
ORDER BY attempts DESC

Uses task_instance_tries

XCom keys pushed in one DAG

SELECT task_id, key, count(*) AS entries
FROM airflow.main.xcom_entries
WHERE dag_id = 'etl_orders'
GROUP BY ALL
ORDER BY task_id

Uses xcom_entries

Which tasks produce each asset and which DAGs consume it

SELECT uri, producing_tasks, consuming_dags
FROM airflow.main.assets
ORDER BY uri

Uses assets

Asset updates per producing DAG and the runs they triggered

SELECT source_dag_id, count(*) AS updates,
  sum(len(created_runs)) AS triggered_runs
FROM airflow.main.asset_events
GROUP BY ALL
ORDER BY updates DESC

Uses asset_events

17 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Using the airflow catalog, which DAG runs failed? Give the dag id and run id.
  • Using the airflow catalog, which task needed more than one attempt, and how many attempts?
  • Using the airflow catalog's unified schema, how many runs are there per status?
  • Using the airflow catalog, which DAG files fail to import?
  • Using the airflow catalog, which DAGs are tagged 'etl'?
  • Using the airflow catalog, list the task instances that never ran because an upstream task failed (dag id, run id, task id).

Apache Airflow is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.