airflow.example_dags.plugins.custom_partition_mapper
Classes
A partition mapper that strips a fixed namespace prefix from upstream keys. |
|
Class used to define AirflowPlugin. |
Module Contents
- class airflow.example_dags.plugins.custom_partition_mapper.PrefixStripMapper(prefix, *, separator='::', max_downstream_keys=None)[source]
Bases:
airflow.partition_mappers.base.PartitionMapperA partition mapper that strips a fixed namespace prefix from upstream keys.
Upstream systems often qualify partition keys with a region or environment prefix — for example
"eu::daily-sales"or"us::daily-sales". A downstream asset that aggregates across regions only cares about the base key ("daily-sales").PrefixStripMapperstrips the given prefix (including a configurable separator) so that all upstream namespaces collapse to the same downstream partition key.If the upstream key does not start with the configured prefix the key is returned unchanged, which is deliberate: keys that already live in the target namespace pass through without modification.
This class demonstrates registering a custom
PartitionMappersubclass via theAirflowPlugin.partition_mappersregistry. Any plugin that lists it inpartition_mappers = [...]makes it available toPartitionedAssetTimetableandRollupMapperwithout modifying core Airflow.- Parameters:
- prefix[source]
- separator = '::'[source]
- to_downstream(key)[source]
Return the target key that the given source partition key maps to.
- serialize()[source]
- classmethod deserialize(data)[source]