Skip to content

Segment-based partitioning #57695

Closed
Closed

Description

@dstandish

Body

Support partitions keyed by a categorical dimension (per-tenant, per-region, per-variant) beyond the static AllowedKeyMapper shipped in #61931. Production use needs runtime-resolved sets, lifecycle handling, and a different notion of completeness than temporal partitions.

Related

#61931, #44146, #59294

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.

Activity

  1. added
    kind:metaHigh-level information important to the community
    on Nov 1, 2025
  2. moved this from Backlog to Todo in AIP-76 Asset Partitioningon Apr 23, 2026
  3. changed the title [-]Come up with plan for segment-based partitioning.[/-] [+]Segment-based partitioning[/+] on Apr 24, 2026
  4. Lee-W commented on Apr 24, 2026

    @Lee-W
    Member
    from airflow.sdk import Asset, AllowedKeyMapper, PartitionAtRuntime, asset
    
    region_raw_stats = Asset(
        uri="file://incoming/player-stats/by-region.csv",
        name="region_raw_stats",
    )
    
    # Must be a module-level function so the timetable is serialisable:
    # the scheduler stores its dotted path and re-imports at scheduling time.
    # Lambdas, closures, and bound methods are rejected at construction.
    def list_active_regions() -> list[str]:
        ...
    
    @asset(
        uri="file://analytics/player-stats/regional-breakdown.csv",
        schedule=PartitionAtRuntime(
            assets=region_raw_stats,
            default_partition_mapper=AllowedKeyMapper(list_active_regions),
        ),
    )
    def regional_stats_breakdown():
        ...

    This could be how it works, but will affect #44146 implemented

  5. anishgirianish commented on May 22, 2026

    @anishgirianish
    Contributor

    Hi, I am actively working on this. thanks

  6. moved this from Todo to In Progress in AIP-76 Asset Partitioningon May 29, 2026
  7. added this to the Airflow 3.3.0 milestone on Jun 5, 2026
  8. Lee-W commented on Jun 11, 2026

    @Lee-W
    Member

    dynamic segement based partition can be achieved by

    # Producer emits per-segment partitions (observability) + one completion signal:
    @asset(schedule=PartitionAtRuntime())
    def regional_sales(self, outlet_events):
        for region in active_regions():            # "what's active" = business logic, on the worker
            process(region)
            outlet_events[self].add_partitions(region)
        outlet_events[batch_done].add(...)          # emit a completion event when the loop ends
    
    # Downstream triggers on the completion signal — plain asset scheduling:
    with DAG("global_report", schedule=batch_done):
        ...

    and since we don't want to allow user code in scheduler, we won't add a new timetable or partition mapper for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:featureFeature Requestskind:metaHigh-level information important to the community

    Type

    No type

    Projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions