You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Taragolis (via GitHub)" <gi...@apache.org> on 2023/08/19 14:29:03 UTC
[GitHub] [airflow] Taragolis opened a new pull request, #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Taragolis opened a new pull request, #33527:
URL: https://github.com/apache/airflow/pull/33527
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
Replace tuple-not-in-collection by pure NOT EXISTS statement, which should be supported by all modern RDBMS.
This should improve performance for such of queries in MSSQL, and I do not expect any noticeable changes for other backend
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Taragolis merged pull request #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis merged PR #33527:
URL: https://github.com/apache/airflow/pull/33527
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Taragolis commented on a diff in pull request #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #33527:
URL: https://github.com/apache/airflow/pull/33527#discussion_r1299330725
##########
airflow/utils/sqlalchemy.py:
##########
@@ -590,7 +592,17 @@ def tuple_not_in_condition(
:meta private:
"""
- if settings.engine.dialect.name != "mssql":
+ warnings.warn(
Review Comment:
Anyway, I would remove deprecation note
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33527:
URL: https://github.com/apache/airflow/pull/33527#discussion_r1299299945
##########
airflow/utils/sqlalchemy.py:
##########
@@ -590,7 +592,17 @@ def tuple_not_in_condition(
:meta private:
"""
- if settings.engine.dialect.name != "mssql":
+ warnings.warn(
Review Comment:
No need to deprecate it, this has `:meta private:` so no user code should depend on it. I feel it’s fine to keep this though, it’s a mirror to `tuple_in_condition` and might be useful at some point.
##########
airflow/utils/sqlalchemy.py:
##########
@@ -590,7 +592,17 @@ def tuple_not_in_condition(
:meta private:
"""
- if settings.engine.dialect.name != "mssql":
+ warnings.warn(
Review Comment:
No need to deprecate it, this has `:meta private:` so no user code should depend on it. I feel it’s fine to keep this though, it’s a mirror to `tuple_in_condition` and might be useful at some point.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on a diff in pull request #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #33527:
URL: https://github.com/apache/airflow/pull/33527#discussion_r1299835539
##########
airflow/models/renderedtifields.py:
##########
@@ -201,11 +209,11 @@ def delete_old_records(
:param num_to_keep: Number of Records to keep
:param session: SqlAlchemy Session
"""
- from airflow.models.dagrun import DagRun
-
if num_to_keep <= 0:
return
+ from airflow.models.dagrun import DagRun
Review Comment:
Side comment. I've learned recently to use more and more local imports. I think basically that when not really needed, the advice of "use top level imports by default" is less and less relevant for "heavy" imports.
The lazy import PEP is years away and it does not seem that it will be enabled by default - you will have to specify an option when you launch interpreter, and I think it's simply inevitable that people will use more and more local imports and the tooling (static checks IDE support etc.) will start supporting it better.
That's my bet actually that rather than switching to lazy impors we will switch to "local imports for heavy things by default". You can see it all over Airflow's code already.
The only reason why you would like to use top-level imports for "heavy" packages is when you use the same import in multiple methods in the same module - but this also can be solved by simply local importing that partiular module.
I bet some tooling for "detect heavy top-level imports" will soon show up in one of the static check tooling.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on a diff in pull request #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #33527:
URL: https://github.com/apache/airflow/pull/33527#discussion_r1299837965
##########
airflow/models/renderedtifields.py:
##########
@@ -201,11 +209,11 @@ def delete_old_records(
:param num_to_keep: Number of Records to keep
:param session: SqlAlchemy Session
"""
- from airflow.models.dagrun import DagRun
-
if num_to_keep <= 0:
return
+ from airflow.models.dagrun import DagRun
Review Comment:
(and of course the problem is with type annotations and TYPE_CHECKING - would also be nice to solve that one as the TYPE_CHECKING is really a hack as opposed to local imports)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Taragolis commented on a diff in pull request #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #33527:
URL: https://github.com/apache/airflow/pull/33527#discussion_r1299330014
##########
airflow/utils/sqlalchemy.py:
##########
@@ -590,7 +592,17 @@ def tuple_not_in_condition(
:meta private:
"""
- if settings.engine.dialect.name != "mssql":
+ warnings.warn(
Review Comment:
I hope we also could get rid of `tuple_in_condition`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Taragolis commented on a diff in pull request #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #33527:
URL: https://github.com/apache/airflow/pull/33527#discussion_r1299220106
##########
airflow/utils/sqlalchemy.py:
##########
@@ -590,7 +592,17 @@ def tuple_not_in_condition(
:meta private:
"""
- if settings.engine.dialect.name != "mssql":
+ warnings.warn(
Review Comment:
Or maybe better remove this function 🤔
##########
airflow/utils/sqlalchemy.py:
##########
@@ -590,7 +592,17 @@ def tuple_not_in_condition(
:meta private:
"""
- if settings.engine.dialect.name != "mssql":
+ warnings.warn(
Review Comment:
Or maybe better remove this function 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #33527: Use `NOT EXISTS` subquery instead of `tuple_not_in_condition`
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33527:
URL: https://github.com/apache/airflow/pull/33527#discussion_r1299822604
##########
airflow/models/renderedtifields.py:
##########
@@ -201,11 +209,11 @@ def delete_old_records(
:param num_to_keep: Number of Records to keep
:param session: SqlAlchemy Session
"""
- from airflow.models.dagrun import DagRun
-
if num_to_keep <= 0:
return
+ from airflow.models.dagrun import DagRun
Review Comment:
I don’t think this actually matters, at this point it’s likely DagRun is imported anyway and the import would be basically free. But either way works.
##########
airflow/models/renderedtifields.py:
##########
@@ -201,11 +209,11 @@ def delete_old_records(
:param num_to_keep: Number of Records to keep
:param session: SqlAlchemy Session
"""
- from airflow.models.dagrun import DagRun
-
if num_to_keep <= 0:
return
+ from airflow.models.dagrun import DagRun
Review Comment:
I don’t think this actually matters, at this point it’s likely DagRun is imported anyway and the import would be basically free. But either way works.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org