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



##########
File path: airflow/models/dag.py
##########
@@ -1050,7 +1109,113 @@ def get_task_instances(self, start_date=None, 
end_date=None, state=None, session
                         )
                 else:
                     tis = tis.filter(TaskInstance.state.in_(state))
-        tis = tis.order_by(TaskInstance.execution_date).all()
+
+        # Next, get any of them from our parent DAG (if there is one)
+        if include_parentdag and self.is_subdag and self.parent_dag is not 
None:
+            p_dag = self.parent_dag.partial_subset(
+                task_ids_or_regex=r"^{}$".format(self.dag_id.split('.')[1]),
+                include_upstream=False,
+                include_downstream=True,
+            )
+            result.update(
+                p_dag.get_task_instances(
+                    task_ids=task_ids,
+                    start_date=start_date,
+                    end_date=end_date,
+                    state=state,
+                    include_subdags=include_subdags,
+                    include_parentdag=False,
+                    as_pk_tuple=True,
+                    session=session,
+                    dag_bag=dag_bag,
+                    recursion_depth=recursion_depth,
+                    max_recursion_depth=max_recursion_depth,
+                    visited_external_tis=visited_external_tis,
+                )
+            )
+
+        if include_subdags:

Review comment:
       Yes, messed this up in rebasing it




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to