uranusjr commented on code in PR #65314:
URL: https://github.com/apache/airflow/pull/65314#discussion_r3711603483


##########
airflow-core/src/airflow/serialization/definitions/dag.py:
##########
@@ -1104,6 +1124,106 @@ def apply_state_filter(query):
         else:
             tis_full = apply_state_filter(tis_full)
 
+        if include_dependent_dags:
+            # Recursively find external tasks indicated by ExternalTaskMarker
+            from airflow.providers.standard.sensors.external_task import 
ExternalTaskMarker
+
+            # Build a full-object query for identifying ExternalTaskMarker TIs 
in the current set
+            if as_pk_tuple:
+                all_ti_rows = session.execute(tis_pk).all()
+                condition = TaskInstance.filter_for_tis(
+                    TaskInstanceKey(**cols._mapping) for cols in all_ti_rows
+                )
+                marker_query = select(TaskInstance).where(condition) if 
condition is not None else None
+            else:
+                marker_query = tis_full
+
+            if marker_query is not None:
+                if visited_external_tis is None:
+                    visited_external_tis = set()
+
+                external_marker_tis = session.scalars(
+                    marker_query.where(TaskInstance.operator == 
ExternalTaskMarker.__name__)
+                )

Review Comment:
   We need to do this better, long term importing provider in core needs to go 
away, so we shouldn’t add more things violating the boundary. _Maybe_ we 
introduce a flag to the serialized format that can be used to detect this? This 
would only work for future provider releases though.



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