siddharthvp commented on a change in pull request #17891:
URL: https://github.com/apache/airflow/pull/17891#discussion_r700544206



##########
File path: airflow/models/dagbag.py
##########
@@ -466,6 +467,34 @@ def _bag_dag(self, *, dag, root_dag, recursive):
                         del self.dags[subdag.dag_id]
             raise
 
+    @provide_session
+    def _check_if_duplicate(self, dag, session=None):
+        """
+        Checks if a DAG with the same ID already exists.
+        If present, returns the fileloc of the existing DAG.
+        """
+        from airflow.models.serialized_dag import SerializedDagModel  # Avoid 
circular import
+
+        other_dag = session.query(SerializedDagModel).filter(
+            SerializedDagModel.dag_id == dag.dag_id,
+            SerializedDagModel.fileloc_hash != 
DagCode.dag_fileloc_hash(dag.fileloc)
+        ).first()

Review comment:
       From the code, I believe that an alert will be raised for each 
collision. (If there are 3 DAGs with same ID, one gets parsed and the other 2 
raise errors.)




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