Lee-W commented on code in PR #68702:
URL: https://github.com/apache/airflow/pull/68702#discussion_r3453564357


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/dag_run.py:
##########
@@ -241,3 +274,61 @@ class DAGRunsBatchBody(StrictBaseModel):
     duration_lt: float | None = None
 
     conf_contains: str | None = None
+
+
+class ClearPartitionsBody(StrictBaseModel):
+    """Request body for the clearPartitions endpoint (column-reset: set 
partition fields to None)."""
+
+    run_id: str | None = Field(
+        default=None,
+        description="Select runs by exact run_id. Mutually exclusive with 
``partition_key`` and partition date window.",
+    )
+    partition_key: str | None = Field(
+        default=None,
+        description="Select runs by exact partition key match. Mutually 
exclusive with ``run_id`` and partition date window.",
+    )
+    partition_date_start: datetime | None = Field(
+        default=None,
+        description="Inclusive start of the partition date window 
(calendar-day granular). Mutually exclusive with ``run_id`` and 
``partition_key``.",
+    )
+    partition_date_end: datetime | None = Field(
+        default=None,
+        description="Inclusive end of the partition date window (calendar-day 
granular). Mutually exclusive with ``run_id`` and ``partition_key``.",
+    )
+    clear_task_instances: bool = Field(
+        default=False,
+        description="Also clear task instances on the matched runs.",
+    )
+    dry_run: bool = Field(
+        default=True,
+        description="If True, compute counts without writing any changes.",
+    )
+
+    @model_validator(mode="after")
+    def validate_exactly_one_selector(self) -> ClearPartitionsBody:
+        has_run_id = self.run_id is not None
+        has_partition_key = self.partition_key is not None
+        has_partition_date_window = (
+            self.partition_date_start is not None or self.partition_date_end 
is not None
+        )
+        selectors_active = sum([has_run_id, has_partition_key, 
has_partition_date_window])
+        if selectors_active != 1:
+            raise ValueError(
+                "Exactly one of run_id, partition_key, or a partition date 
window "
+                "(partition_date_start / partition_date_end) must be provided."
+            )
+        if (
+            self.partition_date_start is not None
+            and self.partition_date_end is not None
+            and self.partition_date_start > self.partition_date_end
+        ):
+            raise ValueError("partition_date_start must be on or before 
partition_date_end.")
+        return self

Review Comment:
   Yep, now moved shared fields + date-order check to `PartitionSelectorMixin`.



-- 
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]

Reply via email to