Skip to content

Commit

Permalink
Fix stray order_by(TaskInstance.execution_date) (#21705)
Browse files Browse the repository at this point in the history
(cherry picked from commit bb577a9)
  • Loading branch information
uranusjr authored and ephraimbuddy committed Mar 19, 2022
1 parent 7b7782d commit 4fe1404
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions airflow/models/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,18 +1253,18 @@ def get_task_instances(
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()
)

Expand Down

0 comments on commit 4fe1404

Please sign in to comment.