onlyarnav opened a new pull request, #69177:
URL: https://github.com/apache/airflow/pull/69177
Fix airflow db clean failure with DAG filtering on joined tables
closes: #69030
### Description
When running `airflow db clean` with `--dag-ids` or `--exclude-dag-ids`, the
command previously failed with a `RuntimeError` on the `asset_event`,
`deadline`, and `task_reschedule` tables.
This occurred because the `_TableConfig` for these tables incorrectly
declared `dag_id_column_name="dag_id"`, but these tables either do not have a
`dag_id` column or require a JOIN to resolve it.
**Changes made in this PR:**
* **`asset_event`**: Mapped the correct column by changing it to
`dag_id_column_name="source_dag_id"`.
* **`deadline`**: Removed the `dag_id` column mapping and added
`dag_id_join_info` to JOIN the `dag_run` table and filter by `dag_run.dag_id`.
* **`task_reschedule`**: Removed the `dag_id` column mapping and added
`dag_id_join_info` to JOIN the `task_instance` table and filter by
`task_instance.dag_id`.
* Added a new unit test
`test_cleanup_with_dag_id_filtering_for_joined_tables` to explicitly verify the
SQL generation and JOIN logic for these tables.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
`Claude Code (Opus 4.8)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]