viiccwen commented on code in PR #69849:
URL: https://github.com/apache/airflow/pull/69849#discussion_r3579815470
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2619,27 +2642,21 @@ def _create_dag_runs_asset_triggered(
)
event_window_floor.append(date.min)
- asset_events = list(
- session.scalars(
- select(AssetEvent)
- .where(
- or_(
- AssetEvent.asset_id.in_(
-
select(DagScheduleAssetReference.asset_id).where(
- DagScheduleAssetReference.dag_id ==
dag.dag_id
- )
- ),
- AssetEvent.source_aliases.any(
- AssetAliasModel.scheduled_dags.any(
- DagScheduleAssetAliasReference.dag_id ==
dag.dag_id
- )
- ),
+ asset_event_ids = select(AssetEvent.id.label("event_id")).where(
+ or_(
+ AssetEvent.asset_id.in_(
+ select(DagScheduleAssetReference.asset_id).where(
+ DagScheduleAssetReference.dag_id == dag.dag_id
),
- AssetEvent.timestamp <= triggered_date,
- AssetEvent.timestamp >
func.coalesce(*event_window_floor),
- )
- .order_by(AssetEvent.timestamp.asc(), AssetEvent.id.asc())
- )
+ ),
+ AssetEvent.source_aliases.any(
+ AssetAliasModel.scheduled_dags.any(
+ DagScheduleAssetAliasReference.dag_id == dag.dag_id
+ )
+ ),
+ ),
+ AssetEvent.timestamp <= triggered_date,
+ AssetEvent.timestamp > func.coalesce(*event_window_floor),
Review Comment:
Oh, I missed it. But `INSERT ... SELECT` doesn't persist relationship order,
simply restoring the source query’s `ORDER BY` would not be sufficient after
the relationship is expired and reloaded.
I’ll preserve the ordering at the relationship level and add a regression
test with event_ids created in a different order from their timestamps.
--
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]