Skip to content

feat(cli): add partitions clear to reset DagRun partition fields#66520

Open
Lee-W wants to merge 2 commits intoapache:mainfrom
astronomer:partitions-clear
Open

feat(cli): add partitions clear to reset DagRun partition fields#66520
Lee-W wants to merge 2 commits intoapache:mainfrom
astronomer:partitions-clear

Conversation

@Lee-W
Copy link
Copy Markdown
Member

@Lee-W Lee-W commented May 7, 2026

Introduce a new airflow partitions command group with a clear action that nulls out partition_key and partition_date on one or more DagRuns. Useful when migrating off a partitioned timetable or fixing a Dag run whose partition metadata was set incorrectly.

Targeting:

  • --dag-id (required)
  • --run-id for a single run, or
  • --start-date / --end-date to clear a partition_date range (the two modes are mutually exclusive)

Safety:

  • --dry-run previews matching runs without writing
  • Prints the existing partition_key / partition_date before clearing each run, and skips runs already cleared

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Claude] following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@Lee-W Lee-W force-pushed the partitions-clear branch 3 times, most recently from 9a71e26 to 1b72e83 Compare May 8, 2026 08:42
Introduce a new `airflow partitions` command group with a `clear`
action that nulls out `partition_key` and `partition_date` on one or
more DagRuns. Useful when migrating off a partitioned timetable or
fixing a Dag run whose partition metadata was set incorrectly.

Targeting:
- `--dag-id` (required)
- `--run-id` for a single run, or
- `--start-date` / `--end-date` to clear a `partition_date` range
(the two modes are mutually exclusive)

Safety:
- `--dry-run` previews matching runs without writing
- Prints the existing `partition_key` / `partition_date` before
clearing each run, and skips runs already cleared
@Lee-W Lee-W force-pushed the partitions-clear branch from 1b72e83 to f4a47d7 Compare May 8, 2026 12:54
Augment `airflow partitions clear` with `--clear-task-instances`:
in addition to nulling `partition_key` / `partition_date`, clear
the matched DagRuns' task instances so finished runs go back to
QUEUED and re-execute. Useful after fixing partition metadata when
the runs themselves should also re-run against the corrected logic.

Behavior:
- Default behavior is unchanged — only partition fields are nulled.
- With `--clear-task-instances`, runs whose partition fields are
already None are no longer skipped (their TIs are still cleared).
- `--dry-run` reports both projected actions without writing.
@Lee-W Lee-W force-pushed the partitions-clear branch from f4a47d7 to af063ea Compare May 8, 2026 13:06
@Lee-W Lee-W marked this pull request as ready for review May 8, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant