uranusjr commented on code in PR #67716:
URL: https://github.com/apache/airflow/pull/67716#discussion_r3378455145
##########
task-sdk/src/airflow/sdk/definitions/partition_mappers/window.py:
##########
@@ -85,3 +88,41 @@ class YearWindow(Window):
"""Twelve consecutive monthly keys making up one calendar year."""
expected_decoded_type: ClassVar[type] = datetime
+
+
+class SegmentWindow(Window):
+ """
+ A fixed categorical set of string keys that constitute one downstream
period.
+
+ Authoring marker for the scheduler-side
+ :class:`airflow.partition_mappers.window.SegmentWindow`. Paired with
+
:class:`~airflow.sdk.definitions.partition_mappers.fixed_key.FixedKeyMapper`
inside a
+ :class:`~airflow.sdk.definitions.partition_mappers.base.RollupMapper` to
express a
+ categorical rollup.
+
+ Construction validates the segment list so Dag parse errors surface
+ immediately rather than deferring to scheduler deserialization.
+
+ :param segments: Non-empty iterable of non-empty string segment keys.
Duplicates
+ are silently de-duplicated.
+ :raises ValueError: if *segments* is empty, contains a non-``str``
element, or
+ contains an empty-string element.
+ """
+
+ expected_decoded_type: ClassVar[type] = str
+
+ def __init__(self, segments: Iterable[str]) -> None:
Review Comment:
I think this can be done a lot easier with attrs. It should also be kept in
sync with core checks.
--
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]