Lee-W commented on PR #64571:
URL: https://github.com/apache/airflow/pull/64571#issuecomment-4198266143
```python
from __future__ import annotations
from airflow.sdk import (
DAG,
Asset,
CronPartitionTimetable,
PartitionedAssetTimetable,
WeeklyRollupMapper,
task,
)
daily_sales = Asset(uri="file://incoming/sales/daily.csv",
name="daily_sales")
# Upstream Dag: produces one partition per day (key format:
"2024-01-15T00:00:00")
with DAG(
dag_id="ingest_daily_sales",
schedule=CronPartitionTimetable("0 0 * * *", timezone="UTC"),
):
@task(outlets=[daily_sales])
def ingest():
pass
ingest()
# Downstream Dag: runs once all 7 daily partitions for a week have arrived
with DAG(
dag_id="weekly_sales_report",
schedule=PartitionedAssetTimetable(
assets=daily_sales,
default_partition_mapper=WeeklyRollupMapper(),
),
catchup=False,
):
@task
def generate_report(dag_run=None):
# dag_run.partition_key will be the week key, e.g. "2024-01-15 (W03)"
print(dag_run.partition_key)
generate_report()
```
--
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]