You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "guan404ming (via GitHub)" <gi...@apache.org> on 2025/04/16 08:39:57 UTC
[PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
guan404ming opened a new pull request, #49339:
URL: https://github.com/apache/airflow/pull/49339
<!--
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/
-->
## Related Issue
- #49334
## Why
get_pandas and get_pandas_by_chunks is deprecated in https://github.com/apache/airflow/pull/48875, which would be replaced by get_df. Thus, we need to migrate them in providers.
## How
This PR is focus on migration of test migration only case as they are more simple and general. Thus I thought that put them together would be better.
- Apache Drill
- Apache Druid
- Apache Impala
- Apache Pinot
- Elasticsearch
- SQLite
- Vertica
In this test, the original `get_pandas_df` would still be tested since it's implemented like
https://github.com/apache/airflow/blob/438220f6b5e6c686015fefddb73daba1a8a5f9d4/providers/common/sql/src/airflow/providers/common/sql/hooks/sql.py#L387-L400
and get_df is like this
https://github.com/apache/airflow/blob/438220f6b5e6c686015fefddb73daba1a8a5f9d4/providers/common/sql/src/airflow/providers/common/sql/hooks/sql.py#L433-L436
thus it still handled the backwards compatibility.
<!-- 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-docs/05_pull_requests.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 [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051551464
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
Oh, I know that is not related to core. But the reason why I do this is to pass the test in [provider distributions tests / Compat 2.9.3:P3.9](https://github.com/apache/airflow/actions/runs/14551412059/job/40823119342?pr=49339#logs) and [Tests / provider distributions tests / Compat 2.10.5:P3.9: (pull_request)](https://github.com/apache/airflow/actions/runs/14551412059/job/40823119531?pr=49339) if I didn't bypass it I would lead to error like
```
FAILED providers/vertica/tests/unit/vertica/hooks/test_vertica.py::TestVerticaHook::test_get_df_polars - airflow.exceptions.AirflowOptionalProviderFeatureException: polars library not installed, run: pip install 'apache-airflow-providers-common-sql[polars]'.
```
or I should add them into `incompatible provider` or is there better to do so? Thanks again~
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2050802437
##########
providers/apache/drill/tests/unit/apache/drill/hooks/test_drill.py:
##########
@@ -90,13 +90,13 @@ def test_get_records(self):
assert self.cur.close.call_count == 1
self.cur.execute.assert_called_once_with(statement)
- def test_get_pandas_df(self):
+ def test_get_df(self):
statement = "SQL"
column = "col"
result_sets = [("row1",), ("row2",)]
self.cur.description = [(column,)]
self.cur.fetchall.return_value = result_sets
- df = self.db_hook().get_pandas_df(statement)
+ df = self.db_hook().get_df(statement, df_type="pandas")
Review Comment:
Thanks for reviewing~ I've updated the test.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2833453415
Thanks a lots, I would keep track on the change and try to do my "polars" one~
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #49339:
URL: https://github.com/apache/airflow/pull/49339
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051538227
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
Since polars related func is not implemented in AF2 which may lead to ci error, I would like to skip the test for AF2 compat test, but the tag description is not really precise. I would change it to "not implemented in Airflow 2", not sure if it make sense, if not please let me know, thanks~
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051551464
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
Oh, I know that is not related to core. But the reason why I do this is to pass the test in [provider distributions tests / Compat 2.9.3:P3.9](https://github.com/apache/airflow/actions/runs/14551412059/job/40823119342?pr=49339#logs) and [Tests / provider distributions tests / Compat 2.10.5:P3.9: (pull_request)](https://github.com/apache/airflow/actions/runs/14551412059/job/40823119531?pr=49339) if I didn't bypass it I would lead to error like
```
FAILED providers/vertica/tests/unit/vertica/hooks/test_vertica.py::TestVerticaHook::test_get_df_polars - airflow.exceptions.AirflowOptionalProviderFeatureException: polars library not installed, run: pip install 'apache-airflow-providers-common-sql[polars]'.
```
or I should add them into `incompatible provider`(but it may skip other tests which is still work) or is there other solution to do so? Thanks again~
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051642046
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
cc @potiuk WDYT?
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834494881
There is still one problem left - compat tests - because there `polars` is not present as extra in airflow. But what we can do, we can somewhat modify the scripts to add `polars` extra to common.sql - cheating a bit.
In this script : https://github.com/apache/airflow/blob/main/scripts/in_container/install_airflow_and_providers.py#L720 we are looping through providers available in `/dist` folder and install them. So if find `apache_airflow_providers_common_sql` .whl file there we could add `[polars]` to it.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834742864
> It works!! 🎉 Force push for the conflict.
🎉
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2825329806
I do not think we should base it on polars importability. We should not check for Airflow 3 here, but instead we should put minimum common.sql version (to the new version that will be released ) in all providers that are going to use the new feature. This is a "common.sql" not airflow feature, so theoretically when you install the new provider and they have `common.sql >=NEW_VERSION` the tests should also work for compatibility tests and polars should be installed - because we are going to install the new common.sql there.
Or am I missing something?.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2833457060
https://github.com/apache/airflow/pull/49846 -> look there, I am moving most extras from `airflow-core` to `apache-airflow` and `pandas` is among them. Once it is merged you should rebase and add polars in a very similar way we will have pandas in the main `pyproject.toml`. Once you do it, pre-commit should automatically add it to `all` extra in the `pyproject.toml` (pandas is already there) and that should make polars installed in the CI image of ours during tests.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2833443261
The provider itself is installed - but without polars extra. What you also need to do is to add another extra (`polars`) to airflow-core,. I am abot to fix one small issue with pandas extras in a moment so you should do a similar "polars" change.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834131759
Ah..... and one other nice optmisation now that you are looking at that. Actually we should do the same in the main `pyproject.toml` in "optional-dependencies". Instead of having this:
```
"pandas" = [
# In pandas 2.2 minimal version of the sqlalchemy is 2.0
# https://pandas.pydata.org/docs/whatsnew/v2.2.0.html#increased-minimum-versions-for-dependencies
# However Airflow not fully supports it yet: https://github.com/apache/airflow/issues/28723
"pandas>=2.1.2,<2.3",
]
"polars" = [
"polars>=1.26.0",
]
```
We shoudl have this:
```
"pandas" = [
"apache-airflow-providers-common-sql[pandas]",
]
"polars" = [
"apache-airflow-providers-common-sql[polars]",
]
```
This has two benefits:
* more DRY
* future-compatible (if we increase lower-bound polars / pandas in the future common-sql, it will be used from there when installing `apache-airflow[pandas,polars]`
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2829313729
I agree with your approach — this should indeed be handled via the common.sql version rather than checking for Airflow 3. As long as to test when only common.sql >= NEW_VERSION, the required features and polars should be pulled in during installation.
I'll take some time to test this out and make sure everything works as intended. Thanks for pointing this out!
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2832441825
Hi @potiuk, I've bumped the `common-sql` min version to `1.26.0` but it seems like it still not installed the polars in ci.
Should I add polars into provider dev deps or optional deps which used new func to make them installed?
Thanks in advance!
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834802796
> > It works!! 🎉 Force push for the conflict.
>
> 🎉
Nice!!!!
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834878468
Thanks for the review and suggestions!
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2833458005
That makes sense to me, I would do so after that one merged.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834156916
cc: @kaxil -> I also will backport it to 3.0.1 even if those are provider changes mostly, but it also affects the `pyproject.toml` / dependencies of the `apache-airflow` distributions.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming closed pull request #49339: test: migrate `get_pandas_df` to `get_df` in `provider` test
URL: https://github.com/apache/airflow/pull/49339
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051538227
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
Since polars related func is not implemented in AF2 which may lead to ci error, I would like to skip the test for AF2 compat test, but the tag description is not really precise. I would change it to "not implemented in Airflow 2"~
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051549905
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
but polar exists only in sql provider. How is it related to core?
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834530182
I agree with you.
Initially, I wanted to bump the Apache Airflow version to >= 3.1.0 in the providers. However, it seems like that is not the best approach because it will break compatibility. Considering this is not "really" incompatible but lack of package for test, I thought we can proceed with that.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834592745
> I agree with you.
>
> Initially, I wanted to bump the Apache Airflow version to >= 3.1.0 in the providers. However, it seems like that is not the best approach because it will break compatibility. Considering this is not "really" incompatible but lack of package for test, I thought we can proceed with that.
Nice.. Looks good. Let's see if CI agrees with this approach :)
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2816669851
Hi @eladkal after my investigation, I found the the cursor execution logic is different for `pandas` and `polars`. Reference to the `polars.read_database` source code, there is a abstraction for executer when calling `read_database`:
https://github.com/pola-rs/polars/blob/5c114f0f32a62bf796629e4ccf01b93146ae22c4/py-polars/polars/io/database/functions.py#L247-L256
Thus we have also need to make the abstraction, while pandas just do `cursor.fetchall()` directly which meaning that the current implement for test is suitable for pandas. Also, we need to skip the polars test for `low_deps` and `AF2` in ci, so I split them into two functions to handle the test here
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051537564
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
How is Airflow 3/2 related to these changes?
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051551464
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
Oh, I know that is not related to core. But the reason why I do this is to pass the test in [provider distributions tests / Compat 2.9.3:P3.9](https://github.com/apache/airflow/actions/runs/14551412059/job/40823119342?pr=49339#logs) and [Tests / provider distributions tests / Compat 2.10.5:P3.9: (pull_request)](https://github.com/apache/airflow/actions/runs/14551412059/job/40823119531?pr=49339) if I didn't bypass it I would lead to error like
```
FAILED providers/vertica/tests/unit/vertica/hooks/test_vertica.py::TestVerticaHook::test_get_df_polars - airflow.exceptions.AirflowOptionalProviderFeatureException: polars library not installed, run: pip install 'apache-airflow-providers-common-sql[polars]'.
```
or I should add them into `incompatible provider`(but it may skip other tests which is still work) or is there better to do so? Thanks again~
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2048321927
##########
providers/apache/drill/tests/unit/apache/drill/hooks/test_drill.py:
##########
@@ -90,13 +90,13 @@ def test_get_records(self):
assert self.cur.close.call_count == 1
self.cur.execute.assert_called_once_with(statement)
- def test_get_pandas_df(self):
+ def test_get_df(self):
statement = "SQL"
column = "col"
result_sets = [("row1",), ("row2",)]
self.cur.description = [(column,)]
self.cur.fetchall.return_value = result_sets
- df = self.db_hook().get_pandas_df(statement)
+ df = self.db_hook().get_df(statement, df_type="pandas")
Review Comment:
Lets change it to test both pandas and polars
You can do that easily with `@pytest.mark.parametrize`
see example in the test_get_host function
Also lets apply the same for all other providers
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051538227
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
Since polars related func is not implemented in AF2 which may lead to ci error, I would like to skip those tests for AF2 compat test, but the tag description is not really precise. I would change it to "not implemented in Airflow 2", not sure if it makes sense, if not please let me know, thanks~
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2051549905
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
but polar exists only in sql provider. How is it related to airflow core?
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49339:
URL: https://github.com/apache/airflow/pull/49339#discussion_r2055204208
##########
devel-common/src/tests_common/test_utils/markers.py:
##########
@@ -21,7 +21,14 @@
import pytest
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
skip_if_force_lowest_dependencies_marker = pytest.mark.skipif(
os.environ.get("FORCE_LOWEST_DEPENDENCIES", "") == "true",
reason="When lowest dependencies are set only some providers are loaded",
)
+
+skip_if_not_airflow_3_marker = pytest.mark.skipif(
+ not AIRFLOW_V_3_0_PLUS,
+ reason="Airflow 2 had a different implementation",
+)
Review Comment:
Hi @eladkal, I thought I got a better way to skip the test. I use importlib to detect whether the polars is installed and skip the test if there is no polars installed.
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834145601
> aaaaach ... Almost :). You also need to add `[polars]` to development dependencies of the providers where we want to test the dependencies (this is why "lowest dep" tests are failing.
>
> ```
> [dependency-groups]
> dev = [
> "apache-airflow",
> "apache-airflow-task-sdk",
> "apache-airflow-devel-common",
> "apache-airflow-providers-common-sql",
> # Additional devel dependencies (do not remove this line and add extra development dependencies)
> "kerberos>=1.3.0",
> "apache-airflow-providers-common-sql[pandas,polars]" # <-- here
> ]
> ```
Updated! Hope that should work
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2816673886
I currently removed the test for polars for `Elasticsearch`for this PR, since Elasticsearch has its own `ElasticsearchSQLCursor` which is not compatable with `polars` cursor execution. I think the modification which the `Elasticsearch` need is maybe quite different with the other in this PR thus I would try open another to deal with it and I have documented it in https://github.com/apache/airflow/issues/49334
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834123165
aaaaach ... Almost :). You also need to add `[polars]` to development dependencies of the providers where we want to test the dependencies (this is why "lowest dep" tests are failing.
```
[dependency-groups]
dev = [
"apache-airflow",
"apache-airflow-task-sdk",
"apache-airflow-devel-common",
"apache-airflow-providers-common-sql",
# Additional devel dependencies (do not remove this line and add extra development dependencies)
"kerberos>=1.3.0",
"apache-airflow-providers-common-sql[pandas,polars]" # <-- here
]
```
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834149105
> Ah..... and one other nice optmisation now that you are looking at that. Actually we should do the same in the main `pyproject.toml` in "optional-dependencies". Instead of having this:
>
> ```
> "pandas" = [
> # In pandas 2.2 minimal version of the sqlalchemy is 2.0
> # https://pandas.pydata.org/docs/whatsnew/v2.2.0.html#increased-minimum-versions-for-dependencies
> # However Airflow not fully supports it yet: https://github.com/apache/airflow/issues/28723
> "pandas>=2.1.2,<2.3",
> ]
> "polars" = [
> "polars>=1.26.0",
> ]
> ```
>
> We shoudl have this:
>
> ```
> "pandas" = [
> "apache-airflow-providers-common-sql[pandas]",
> ]
> "polars" = [
> "apache-airflow-providers-common-sql[polars]",
> ]
> ```
>
> This has two benefits:
>
> * more DRY
> * future-compatible (if we increase lower-bound polars / pandas in the future common-sql, it will be used from there when installing `apache-airflow[pandas,polars]`
It did help to make it more DRY since it's only used by common-sql. Thanks for pointing this out!
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834154320
Nice !
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834879351
### Backport failed to create: v3-0-test. View the failure log <a href='https://github.com/apache/airflow/actions/runs/14706184515'> Run details </a>
<table>
<tr>
<th>Status</th>
<th>Branch</th>
<th>Result</th>
</tr>
<tr>
<td>❌</td>
<td>v3-0-test</td>
<td><a href="https://github.com/apache/airflow/commit/c6ca8a276d14c542420d0e990cef740443aedeb6"><img src='https://img.shields.io/badge/Commit-c6ca8a2-red' alt='Commit Link'></a></td>
</tr>
</table>
You can attempt to backport this manually by running:
```bash
cherry_picker c6ca8a2 v3-0-test
```
This should apply the commit to the v3-0-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.
After you have resolved the conflicts, you can continue the backport process by running:
```bash
cherry_picker --continue
```
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834157790
Thanks for the review!
--
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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2834727172
It 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
Re: [PR] test: migrate `get_pandas_df` to `get_df` in `provider` test [airflow]
Posted by "mergeable[bot] (via GitHub)" <gi...@apache.org>.
mergeable[bot] commented on PR #49339:
URL: https://github.com/apache/airflow/pull/49339#issuecomment-2823283700
#### :x: Error Occurred while executing an Action
If you believe this is an unexpected error, please report it on our issue tracker: https://github.com/mergeability/mergeable/issues/new
##### Error Details
--------------------
HttpError: invalid json response body at https://api.github.com/repos/apache/airflow/check-runs/40992010774 reason: Unexpected end of JSON input
--
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