Query TaskReschedule only if task is UP_FOR_RESCHEDULE#9087
Query TaskReschedule only if task is UP_FOR_RESCHEDULE#9087turbaszek merged 6 commits intoapache:masterfrom
Conversation
|
@seelmann Can you look at it? |
|
Makes perfect sense, +1. Another optimization could be to not fetch all |
Sounds reasonable, thanks! |
|
@seelmann would like to take another look? |
Co-authored-by: Stefan Seelmann <mail@stefan-seelmann.de>
|
|
||
| task_reschedules = TaskReschedule.find_for_task_instance(task_instance=ti) | ||
| if not task_reschedules: | ||
| task_reschedule = TaskReschedule.query_for_task_instance(task_instance=ti, descending=True).first() |
There was a problem hiding this comment.
| task_reschedule = TaskReschedule.query_for_task_instance(task_instance=ti, descending=True).first() | |
| task_reschedule = ( | |
| TaskReschedule.query_for_task_instance(task_instance=ti, descending=True) | |
| .with_entities(TR.reschedule_date) | |
| .first() | |
| ) |
There was a problem hiding this comment.
Oh does with_entites say "just select this one column? Nice!
There was a problem hiding this comment.
This allows you to change the content of the parameter passed to the query method on an existing object. We already use it in the project. https://github.com/apache/airflow/pull/8729/files
There was a problem hiding this comment.
|
|
||
| task_reschedules = TaskReschedule.find_for_task_instance(task_instance=ti) | ||
| if not task_reschedules: | ||
| task_reschedule = TaskReschedule.query_for_task_instance(task_instance=ti, descending=True).first() |
There was a problem hiding this comment.
Please pass on the same session object.
| task_reschedule = TaskReschedule.query_for_task_instance(task_instance=ti, descending=True).first() | |
| task_reschedule = ( | |
| TaskReschedule.query_for_task_instance(task_instance=ti, descending=True, session=session) | |
| .with_entities(TR.reschedule_date) | |
| .first() | |
| ) |
There was a problem hiding this comment.
You missed Kamil's suggestion of .with_entites here.
|
@turbaszek Should we merge it? |
Make sure to mark the boxes below before creating PR: [x]
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.