You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/09/09 15:04:57 UTC

[GitHub] [airflow] dstandish commented on a diff in pull request #26257: Don't try to insert queue records if no downstream dag

dstandish commented on code in PR #26257:
URL: https://github.com/apache/airflow/pull/26257#discussion_r967179874


##########
airflow/datasets/manager.py:
##########
@@ -96,12 +96,11 @@ def _slow_path_queue_dagruns(self, dataset: DatasetModel, session: Session) -> N
     def _postgres_queue_dagruns(self, dataset: DatasetModel, session: Session) -> None:
         from sqlalchemy.dialects.postgresql import insert
 
-        stmt = insert(DatasetDagRunQueue).values(dataset_id=dataset.id).on_conflict_do_nothing()
-        session.execute(
-            stmt,
-            [{'target_dag_id': target_dag.dag_id} for target_dag in dataset.consuming_dags],
-        )
-        session.flush()
+        params = [{'target_dag_id': target_dag.dag_id} for target_dag in dataset.consuming_dags]
+        if params:
+            stmt = insert(DatasetDagRunQueue).values(dataset_id=dataset.id).on_conflict_do_nothing()
+            session.execute(stmt, params)
+            session.flush()

Review Comment:
   the other path wasn't susceptible to the issue



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org