Skip to content

Support schema-qualified table names in db clean - #70147

Merged
uranusjr merged 3 commits into
apache:mainfrom
seanmuth:db-cleanup-schema-qualified-tables
Jul 28, 2026
Merged

uranusjr merged 3 commits into
apache:mainfrom
seanmuth:db-cleanup-schema-qualified-tables

Conversation

@seanmuth

Copy link
Copy Markdown
Contributor

Celery result backends are commonly provisioned into their own database schema, separate from Airflow's metadata tables. airflow db clean has no way to reach celery_taskmeta / celery_tasksetmeta in that case, since it only ever looks in the connection's default schema, so those tables are silently skipped every time.

_TableConfig, reflect_tables, and the archive/export/drop machinery in db_cleanup.py now understand schema-qualified table names ("schema.table" dot notation). A new [celery] result_backend_schema config option lets a deployment point the built-in celery_taskmeta / celery_tasksetmeta configs at the schema they actually live in, without needing a fork or manual per-table config.

Verified end-to-end against a real Postgres instance: clean → archive (lands in the same schema as the source table) → export → drop, all schema-aware. New unit + integration tests cover schema parsing, the config-driven wiring, and the full cleanup cycle; existing test suite passes unmodified on both sqlite and Postgres.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Sonnet 5)

Generated-by: Claude Code (Sonnet 5) following the guidelines

Celery result backends are commonly provisioned into their own database
schema, separate from Airflow's metadata tables. airflow db clean has
no way to reach celery_taskmeta / celery_tasksetmeta in that case, since
it only ever looks in the connection's default schema, so those tables
are silently skipped every time.

_TableConfig, reflect_tables, and the archive/export/drop machinery in
db_cleanup.py now understand schema-qualified table names ("schema.table"
dot notation). A new [celery] result_backend_schema config option lets
a deployment point the built-in celery_taskmeta / celery_tasksetmeta
configs at the schema they actually live in, without needing a fork or
manual per-table config.
@uranusjr

Copy link
Copy Markdown
Member

I added a commit that removed the reading-provider-in-core part. This PR now only contains adding support for schema-qualified table names in db clean.

Once this is accepted, I will raise a second PR that implements the Celery table name cleanup with a cleaner approach.

We're going to do the provider support separately instead in a cleaner
way (providers should implement a hook point called in core).

This leaves the current branch with only adding support for dotted
(qualified) table name with a schema prefix, which is useful anyway. We
will actually use this feature in a different subsequent PR.
@uranusjr
uranusjr force-pushed the db-cleanup-schema-qualified-tables branch from b6727c7 to 8a0a406 Compare July 28, 2026 11:23
@eladkal

eladkal commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

I added a commit that removed the reading-provider-in-core part. This PR now only contains adding support for schema-qualified table names in db clean.

Once this is accepted, I will raise a second PR that implements the Celery table name cleanup with a cleaner approach.

LGTM then

@uranusjr
uranusjr merged commit 3050668 into apache:main Jul 28, 2026
155 checks passed
dabla pushed a commit to dabla/airflow that referenced this pull request Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants