This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-2-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 4fe1404ce43a89b591ea552359e8b2192c869295 Author: Tzu-ping Chung <t...@astronomer.io> AuthorDate: Wed Feb 23 04:12:22 2022 +0800 Fix stray order_by(TaskInstance.execution_date) (#21705) (cherry picked from commit bb577a98494369b22ae252ac8d23fb8e95508a1c) --- airflow/models/baseoperator.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py index 9e4cedd..c758aeb 100644 --- a/airflow/models/baseoperator.py +++ b/airflow/models/baseoperator.py @@ -1253,18 +1253,18 @@ class BaseOperator(Operator, LoggingMixin, TaskMixin, metaclass=BaseOperatorMeta end_date: Optional[datetime] = None, session: Session = None, ) -> List[TaskInstance]: - """ - Get a set of task instance related to this task for a specific date - range. - """ + """Get task instances related to this task for a specific date range.""" + from airflow.models import DagRun + end_date = end_date or timezone.utcnow() return ( session.query(TaskInstance) + .join(TaskInstance.dag_run) .filter(TaskInstance.dag_id == self.dag_id) .filter(TaskInstance.task_id == self.task_id) - .filter(TaskInstance.execution_date >= start_date) - .filter(TaskInstance.execution_date <= end_date) - .order_by(TaskInstance.execution_date) + .filter(DagRun.execution_date >= start_date) + .filter(DagRun.execution_date <= end_date) + .order_by(DagRun.execution_date) .all() )