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

Correctly select DagRun.execution_date from db #18421

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Sep 22, 2021

The importance of test coverage and type annotations…

@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label Sep 22, 2021
@uranusjr uranusjr added the AIP-39 Timetables label Sep 22, 2021
@uranusjr uranusjr added this to the Airflow 2.2.0 milestone Sep 22, 2021
@uranusjr uranusjr force-pushed the aip-39-get-task-instances-before-use-execution-date branch from 2fad057 to fe45c39 Compare September 22, 2021 02:51
Comment on lines +1281 to +1282
.limit(1)
.scalar()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.limit(1)
.scalar()
.scalar()

I think using only .scalar() is enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs say scalar() fails if there’s more than one row

https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Query.scalar

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why you went with limit instead of first ?

https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Query.first

Copy link
Member Author

@uranusjr uranusjr Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think first() would require unpacking the returning tuple manually? This feels slightly easier to read for me than

min_date_row = session.query(...).first()
if min_date_row is None:
    ...
min_date = min_date_row[0]

@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Sep 22, 2021
@uranusjr uranusjr force-pushed the aip-39-get-task-instances-before-use-execution-date branch from 555be7e to 754d78c Compare September 22, 2021 09:45
@uranusjr uranusjr force-pushed the aip-39-get-task-instances-before-use-execution-date branch 3 times, most recently from b2c82b5 to abda7d6 Compare September 22, 2021 12:19
@uranusjr

This comment has been minimized.

@uranusjr uranusjr force-pushed the aip-39-get-task-instances-before-use-execution-date branch from abda7d6 to 4c4c98c Compare September 22, 2021 19:44
@kaxil kaxil merged commit 1ef41be into apache:main Sep 23, 2021
@uranusjr uranusjr deleted the aip-39-get-task-instances-before-use-execution-date branch September 23, 2021 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-39 Timetables area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants