ashb commented on a change in pull request #17630:
URL: https://github.com/apache/airflow/pull/17630#discussion_r689343499



##########
File path: airflow/api/common/experimental/delete_dag.py
##########
@@ -40,6 +41,11 @@ def delete_dag(dag_id: str, keep_records_in_log: bool = 
True, session=None) -> i
     :return count of deleted dags
     """
     log.info("Deleting DAG: %s", dag_id)
+    running_tis = (
+        
session.query(models.TaskInstance.state).filter(models.TaskInstance.state.in_(State.unfinished)).all()

Review comment:
       Additionally `.all()` is going to return all the rows. Better would be 
to use `.first()` (to only return a single row, or to use 
https://docs.sqlalchemy.org/en/13/orm/query.html?highlight=exists#sqlalchemy.orm.query.Query.exists
 (but note the caveat about mssql there)




-- 
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]


Reply via email to