Failing DAGs

Start Timer

0:00:00

Upvote
0
Downvote
Save question
View comments

We’re given a dag_runs table with one row per Airflow DAG run. Write a query to find the DAGs whose latest runs are a streak of at least 3 failures in a row, and return the number of consecutive failures and when the streak started.

Note: state is success, failed, skipped, or running, and run_type is scheduled or manual.

Rules - Order runs by logical_date, not end_date. The streak start is the logical_date of the first failure in the streak. - Ignore runs that are still running. - A skipped or success run ends a streak. - Manual and scheduled runs both count. - Order by dag_id.

Example:

Input:

dag_runs table

Column Type
run_id VARCHAR
dag_id VARCHAR
run_type VARCHAR
logical_date DATETIME
start_date DATETIME
end_date DATETIME
state VARCHAR

Output:

Column Type
dag_id VARCHAR
consecutive_failures INTEGER
streak_start DATETIME
.
.
.
.
.


Comments

Loading comments