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/01/09 21:57:57 UTC

[GitHub] [airflow] SamWheating commented on a change in pull request #20758: Avoid unintentional data loss when deleting DAGs

SamWheating commented on a change in pull request #20758:
URL: https://github.com/apache/airflow/pull/20758#discussion_r780836809



##########
File path: airflow/api/common/delete_dag.py
##########
@@ -54,6 +54,15 @@ def delete_dag(dag_id: str, keep_records_in_log: bool = True, session=None) -> i
     if dag is None:
         raise DagNotFound(f"Dag id {dag_id} not found")
 
+    # deleting a DAG should also all of its subdags
+    dags_to_delete = [
+        d[0]
+        for d in session.query(DagModel.dag_id)
+        .filter(and_(DagModel.dag_id.like(dag_id + ".%"), DagModel.is_subdag))
+        .all()
+    ]
+    dags_to_delete.append(dag_id)

Review comment:
       Yeah, I think so - would `dags_to_delete` be a list of string here, or a list of one-element tuples? I always get mixed up with the return types from SQLAlchemy queries 🤔  




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