uranusjr commented on code in PR #62501:
URL: https://github.com/apache/airflow/pull/62501#discussion_r3425207396
##########
airflow-core/src/airflow/assets/manager.py:
##########
@@ -717,14 +758,20 @@ def _get_or_create_apdr(
@classmethod
def _queue_dagruns_nonpartitioned_slow_path(
- cls, asset_id: int, dags_to_queue: set[DagModel], session: Session
+ cls, asset_id: int, dags_to_queue: set[DagModel], event: AssetEvent,
session: Session
) -> None:
def _queue_dagrun_if_needed(dag: DagModel) -> str | None:
- item = AssetDagRunQueue(target_dag_id=dag.dag_id,
asset_id=asset_id)
+ item = AssetDagRunQueue(target_dag_id=dag.dag_id,
asset_id=asset_id, created_at=event.timestamp)
# Don't error whole transaction when a single RunQueue item
conflicts.
#
https://docs.sqlalchemy.org/en/14/orm/session_transaction.html#using-savepoint
try:
with session.begin_nested():
+ existing = session.get(
+ AssetDagRunQueue, {"target_dag_id": dag.dag_id,
"asset_id": asset_id}
+ )
Review Comment:
Let’s use a `session.scalar` or `session.scalars().one()` call here instead.
`session.get()` with a composite pk is difficult to maintain if we want to
change the schema in the future.
--
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]