You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when a DAG is triggered by asset events, Airflow's scheduler consumes all available asset events from the queue and creates a single DAG run that processes all these events together (code).
This feature request proposes adding a configurable parameter (eg. max_asset_events) that allows DAG developers to control how many asset events are consumed per DAG run.
Use case/motivation
This feature request is primarily motivated by the need to simplify migration from Airflow 2.x DAGs that were previously triggered by SQS queue events and designed to process one message at a time (as SqsSensor allowed to configure max_messages=1 parameter).
If this is something that you're looking to recreate only for SQS/other queue-based integrations, I would suggest doing so at the Trigger-level, rather than generalizing for all Assets. Just my thoughts, I'll leave it open for folks such as @cmarteepants or @dstandish to comment on as well.
@dabeeru Conceptually I'm pro having this kind of option, and I've wondered about how to do something like this, but from a different angle (guaranteeing that every asset event triggers a Dag Run).
Where I get stuck: If a dag is only scheduled against a single asset, this seems easy enough to achieve, but how do we deal with dags that are scheduled against more than one asset?
Not sure where the param should live in your design, but assuming this:
asset_1 = Asset(
"some_sqs_queue",
watchers=[AssetWatcher(name="sqs_watcher_some_queue", trigger=trigger)],
max_messages=1
)
asset_2 = Asset(
"another_sqs_queue",
watchers=[AssetWatcher(name="sqs_watcher_another_queue", trigger=trigger)]
max_messages=1
)
with DAG(
schedule=['asset_1, 'asset_2']. # DAG will only run when there is an asset even for `asset_1` and `asset_2`
) as dag:
# do something
How do we handle for example cases where asset_1 has 5 asset events before an asset even is finally created for asset_2?
(Happy to explain the scenario more deeply, not sure how clear it is).
Perhaps we do the dumb thing and have the param be at the dag-level, and only let you use this parameter if the dag is only scheduled against a single asset?
The next question is if this overlaps with partitions cc @uranusjr@dstandish
@cmarteepants I think we could introduce this parameter at the DAG level while still allowing it to be used in any scenario. Then max_asset_events parameter would just limit how many asset events can be polled for single DAG run, always assuming that we should prioritize polling the oldest items first.
So for example:
Timeline: DAG with max_asset_events=1, scheduled on Assets A, B, C
Time Asset A Queue Asset B Queue Asset C Queue DAG Action
----- ------------- ------------- ------------- ----------
10:00 [E1] [] [] Wait
10:05 [E1] [E1] [] Wait
10:10 [E1, E2] [E1] [] Wait
10:15 [E1, E2] [E1, E2] [] Wait
10:20 [E1, E2] [E1, E2] [E1] 🚀 TRIGGER!
Consumed Events: A-E1, B-E1, C-E1 (oldest from each)
10:20 [E2] [E2] [] Wait
10:25 [E2, E3] [E2] [E2] 🚀 TRIGGER!
Consumed Events: A-E2, B-E2, C-E2 (oldest from each)
10:25 [E3] [] [] Wait
10:30 [E3, E4] [E3] [] Wait
Not sure how much it would impact current implementation, but conceptually it makes sense for me. What do you think?
Is there a use case for values other than None (no limit, current behaviour) and 1? Maybe we could get away with just one flag to control if grouping happens or not. This would also make the multiple asset case easier to reason with.
Another thing is how would the behaviour be if different depended assets set this flag differently. (Maybe the flag should be on the depending dag instead?)
Hi,@uranusjr, I'd like to work on this, if this is still open.
On boolean vs integer, AssetDagRunQueue is keyed by (asset_id, target_dag_id) and deduplicates on insert, so it's a boolean signal, not an event counter. An integer limit would need the queue rearchitected to track individual events. Boolean "each event triggers its own run" vs "all grouped into one run" covers the use case and is simpler.
For where the flag lives, DAG-level feels right. Asset has no scheduling parameters, and two DAGs depending on the same asset might want different grouping. Something like DAG(schedule=[asset], group_asset_events=False) defaulting to True for backward compat.
Re partitions, these use separate infrastructure (AssetPartitionDagRun + PartitionedAssetKeyLog vs AssetDagRunQueue), and partitioned DAGs are excluded from the regular asset-triggered path. They shouldn't conflict.
Would like to put my vote in for this feature. Our intended use case: we have a backfill DAG that iterates over files in an S3 bucket and emits an Asset event per file in a time window and emits an Asset event per file. A downstream pipeline DAG grabs these, but is written to handle only one file (Asset event) per dagrun - it throws if it gets more than 1 Asset event and we mostly manage to achieve that by throttling the Asset emission rate on the backfill DAG (with sleep/queues). It's a bit hacky, but the approach mostly works. Still, it would be nice to have this not be a variable at all. (Happy to hear alternative approaches; to be clear - it's not really practical for us to make the downstream pipeline .expand() over multiple files.)
Activity
jroachgolf84 commentedon Sep 22, 2025
If this is something that you're looking to recreate only for SQS/other queue-based integrations, I would suggest doing so at the Trigger-level, rather than generalizing for all Assets. Just my thoughts, I'll leave it open for folks such as @cmarteepants or @dstandish to comment on as well.
cmarteepants commentedon Sep 23, 2025
@dabeeru Conceptually I'm pro having this kind of option, and I've wondered about how to do something like this, but from a different angle (guaranteeing that every asset event triggers a Dag Run).
Where I get stuck: If a dag is only scheduled against a single asset, this seems easy enough to achieve, but how do we deal with dags that are scheduled against more than one asset?
Not sure where the param should live in your design, but assuming this:
How do we handle for example cases where
asset_1has 5 asset events before an asset even is finally created forasset_2?(Happy to explain the scenario more deeply, not sure how clear it is).
cmarteepants commentedon Sep 23, 2025
Perhaps we do the dumb thing and have the param be at the dag-level, and only let you use this parameter if the dag is only scheduled against a single asset?
The next question is if this overlaps with partitions cc @uranusjr @dstandish
dabeeru commentedon Sep 24, 2025
@cmarteepants I think we could introduce this parameter at the DAG level while still allowing it to be used in any scenario. Then
max_asset_eventsparameter would just limit how many asset events can be polled for single DAG run, always assuming that we should prioritize polling the oldest items first.So for example:
Not sure how much it would impact current implementation, but conceptually it makes sense for me. What do you think?
uranusjr commentedon Nov 12, 2025
Is there a use case for values other than None (no limit, current behaviour) and 1? Maybe we could get away with just one flag to control if grouping happens or not. This would also make the multiple asset case easier to reason with.
Another thing is how would the behaviour be if different depended assets set this flag differently. (Maybe the flag should be on the depending dag instead?)
anishgirianish commentedon Feb 21, 2026
Hi,@uranusjr, I'd like to work on this, if this is still open.
On boolean vs integer, AssetDagRunQueue is keyed by (asset_id, target_dag_id) and deduplicates on insert, so it's a boolean signal, not an event counter. An integer limit would need the queue rearchitected to track individual events. Boolean "each event triggers its own run" vs "all grouped into one run" covers the use case and is simpler.
For where the flag lives, DAG-level feels right. Asset has no scheduling parameters, and two DAGs depending on the same asset might want different grouping. Something like DAG(schedule=[asset], group_asset_events=False) defaulting to True for backward compat.
Re partitions, these use separate infrastructure (AssetPartitionDagRun + PartitionedAssetKeyLog vs AssetDagRunQueue), and partitioned DAGs are excluded from the regular asset-triggered path. They shouldn't conflict.
Let me know if this direction makes sense.
dshemetov commentedon Jul 31, 2026
Would like to put my vote in for this feature. Our intended use case: we have a backfill DAG that iterates over files in an S3 bucket and emits an Asset event per file in a time window and emits an Asset event per file. A downstream pipeline DAG grabs these, but is written to handle only one file (Asset event) per dagrun - it throws if it gets more than 1 Asset event and we mostly manage to achieve that by throttling the Asset emission rate on the backfill DAG (with sleep/queues). It's a bit hacky, but the approach mostly works. Still, it would be nice to have this not be a variable at all. (Happy to hear alternative approaches; to be clear - it's not really practical for us to make the downstream pipeline .expand() over multiple files.)
raphaelauv commentedon Nov 9, 2026
done by #68517 and release with 3.4.0
@dabeeru could you close the issue, thanks