uranusjr commented on code in PR #66520: URL: https://github.com/apache/airflow/pull/66520#discussion_r3272954545
########## airflow-core/src/airflow/cli/commands/partition_command.py: ########## @@ -0,0 +1,104 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Partitions sub-commands.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from sqlalchemy import or_, select + +from airflow.models.dagrun import DagRun +from airflow.models.taskinstance import clear_task_instances +from airflow.utils import cli as cli_utils +from airflow.utils.providers_configuration_loader import providers_configuration_loaded +from airflow.utils.session import NEW_SESSION, provide_session + +if TYPE_CHECKING: + from sqlalchemy.orm import Session + + +@cli_utils.action_cli +@providers_configuration_loaded +@provide_session +def clear(args, *, session: Session = NEW_SESSION) -> None: + """Clear the partition_key and partition_date of matching DagRuns.""" + has_range = args.start_date is not None or args.end_date is not None + if not args.run_id and not has_range: + raise SystemExit( + "Specify either --run-id for a single DagRun, or a partition_date range " + "via --start-date and/or --end-date." + ) + if args.run_id and has_range: + raise SystemExit( + "--run-id cannot be combined with a partition_date range (--start-date / --end-date)." + ) Review Comment: I wonder if we should allow clearing by partition_key (and or partition_date?) -- 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]
