Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stray order_by(TaskInstance.execution_date) #21705

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions airflow/models/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,18 +1208,18 @@ def get_task_instances(
end_date: Optional[datetime] = None,
session: Session = NEW_SESSION,
) -> 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