apache-airflow-providers-postgres 6.2.1rc1__tar.gz → 6.2.2rc1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/PKG-INFO +22 -13
  2. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/README.rst +10 -8
  3. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/changelog.rst +20 -0
  4. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/index.rst +10 -7
  5. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/provider.yaml +2 -1
  6. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/pyproject.toml +16 -5
  7. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/__init__.py +1 -1
  8. {apache_airflow_providers_postgres-6.2.1rc1/tests/system → apache_airflow_providers_postgres-6.2.2rc1/src/airflow/providers}/__init__.py +1 -1
  9. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/__init__.py +1 -1
  10. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/hooks/postgres.py +65 -5
  11. {apache_airflow_providers_postgres-6.2.1rc1/src/airflow/providers → apache_airflow_providers_postgres-6.2.2rc1/tests/system}/__init__.py +1 -1
  12. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/unit/__init__.py +1 -1
  13. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/unit/postgres/hooks/test_postgres.py +34 -0
  14. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/.latest-doc-only-change.txt +0 -0
  15. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/commits.rst +0 -0
  16. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/conf.py +0 -0
  17. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/connections/postgres.rst +0 -0
  18. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/dialects.rst +0 -0
  19. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/installing-providers-from-sources.rst +0 -0
  20. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/integration-logos/Postgres.png +0 -0
  21. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/operators.rst +0 -0
  22. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/redirects.txt +0 -0
  23. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/docs/security.rst +0 -0
  24. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/LICENSE +0 -0
  25. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/assets/__init__.py +0 -0
  26. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/assets/postgres.py +0 -0
  27. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/dialects/__init__.py +0 -0
  28. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/dialects/postgres.py +0 -0
  29. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/get_provider_info.py +0 -0
  30. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/src/airflow/providers/postgres/hooks/__init__.py +0 -0
  31. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/conftest.py +0 -0
  32. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/system/postgres/__init__.py +0 -0
  33. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/system/postgres/example_postgres.py +0 -0
  34. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/unit/postgres/__init__.py +0 -0
  35. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/unit/postgres/assets/__init__.py +0 -0
  36. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/unit/postgres/assets/test_postgres.py +0 -0
  37. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/unit/postgres/dialects/__init__.py +0 -0
  38. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/unit/postgres/dialects/test_postgres.py +0 -0
  39. {apache_airflow_providers_postgres-6.2.1rc1 → apache_airflow_providers_postgres-6.2.2rc1}/tests/unit/postgres/hooks/__init__.py +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apache-airflow-providers-postgres
3
- Version: 6.2.1rc1
3
+ Version: 6.2.2rc1
4
4
  Summary: Provider package apache-airflow-providers-postgres for Apache Airflow
5
5
  Keywords: airflow-provider,postgres,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
7
7
  Maintainer-email: Apache Software Foundation <dev@airflow.apache.org>
8
- Requires-Python: ~=3.10
8
+ Requires-Python: >=3.10
9
9
  Description-Content-Type: text/x-rst
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Environment :: Console
@@ -18,22 +18,29 @@ Classifier: License :: OSI Approved :: Apache Software License
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
21
22
  Classifier: Topic :: System :: Monitoring
22
23
  Requires-Dist: apache-airflow>=2.10.0rc1
23
24
  Requires-Dist: apache-airflow-providers-common-sql>=1.23.0rc1
24
- Requires-Dist: psycopg2-binary>=2.9.9
25
+ Requires-Dist: psycopg2-binary>=2.9.9; python_version < '3.13'
26
+ Requires-Dist: psycopg2-binary>=2.9.10; python_version >= '3.13'
25
27
  Requires-Dist: asyncpg>=0.30.0
26
28
  Requires-Dist: apache-airflow-providers-amazon>=2.6.0rc1 ; extra == "amazon"
27
29
  Requires-Dist: apache-airflow-providers-openlineage ; extra == "openlineage"
30
+ Requires-Dist: pandas>=2.1.2 ; extra == "pandas" and ( python_version <"3.13")
31
+ Requires-Dist: pandas>=2.2.3 ; extra == "pandas" and ( python_version >="3.13")
32
+ Requires-Dist: polars>=1.26.0 ; extra == "polars"
28
33
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
29
- Project-URL: Changelog, https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.1/changelog.html
30
- Project-URL: Documentation, https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.1
34
+ Project-URL: Changelog, https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.2/changelog.html
35
+ Project-URL: Documentation, https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.2
31
36
  Project-URL: Mastodon, https://fosstodon.org/@airflow
32
37
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
33
38
  Project-URL: Source Code, https://github.com/apache/airflow
34
39
  Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
35
40
  Provides-Extra: amazon
36
41
  Provides-Extra: openlineage
42
+ Provides-Extra: pandas
43
+ Provides-Extra: polars
37
44
 
38
45
 
39
46
  .. Licensed to the Apache Software Foundation (ASF) under one
@@ -60,8 +67,9 @@ Provides-Extra: openlineage
60
67
 
61
68
  Package ``apache-airflow-providers-postgres``
62
69
 
63
- Release: ``6.2.1``
70
+ Release: ``6.2.2``
64
71
 
72
+ Release Date: ``|PypiReleaseDate|``
65
73
 
66
74
  `PostgreSQL <https://www.postgresql.org/>`__
67
75
 
@@ -73,7 +81,7 @@ This is a provider package for ``postgres`` provider. All classes for this provi
73
81
  are in ``airflow.providers.postgres`` python package.
74
82
 
75
83
  You can find package information and changelog for the provider
76
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.1/>`_.
84
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.2/>`_.
77
85
 
78
86
  Installation
79
87
  ------------
@@ -82,19 +90,20 @@ You can install this package on top of an existing Airflow 2 installation (see `
82
90
  for the minimum Airflow version supported) via
83
91
  ``pip install apache-airflow-providers-postgres``
84
92
 
85
- The package supports the following python versions: 3.10,3.11,3.12
93
+ The package supports the following python versions: 3.10,3.11,3.12,3.13
86
94
 
87
95
  Requirements
88
96
  ------------
89
97
 
90
- ======================================= ==================
98
+ ======================================= ======================================
91
99
  PIP package Version required
92
- ======================================= ==================
100
+ ======================================= ======================================
93
101
  ``apache-airflow`` ``>=2.10.0``
94
102
  ``apache-airflow-providers-common-sql`` ``>=1.23.0``
95
- ``psycopg2-binary`` ``>=2.9.9``
103
+ ``psycopg2-binary`` ``>=2.9.9; python_version < "3.13"``
104
+ ``psycopg2-binary`` ``>=2.9.10; python_version >= "3.13"``
96
105
  ``asyncpg`` ``>=0.30.0``
97
- ======================================= ==================
106
+ ======================================= ======================================
98
107
 
99
108
  Cross provider package dependencies
100
109
  -----------------------------------
@@ -118,5 +127,5 @@ Dependent package
118
127
  ============================================================================================================== ===============
119
128
 
120
129
  The changelog for the provider package can be found in the
121
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.1/changelog.html>`_.
130
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.2/changelog.html>`_.
122
131
 
@@ -23,8 +23,9 @@
23
23
 
24
24
  Package ``apache-airflow-providers-postgres``
25
25
 
26
- Release: ``6.2.1``
26
+ Release: ``6.2.2``
27
27
 
28
+ Release Date: ``|PypiReleaseDate|``
28
29
 
29
30
  `PostgreSQL <https://www.postgresql.org/>`__
30
31
 
@@ -36,7 +37,7 @@ This is a provider package for ``postgres`` provider. All classes for this provi
36
37
  are in ``airflow.providers.postgres`` python package.
37
38
 
38
39
  You can find package information and changelog for the provider
39
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.1/>`_.
40
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.2/>`_.
40
41
 
41
42
  Installation
42
43
  ------------
@@ -45,19 +46,20 @@ You can install this package on top of an existing Airflow 2 installation (see `
45
46
  for the minimum Airflow version supported) via
46
47
  ``pip install apache-airflow-providers-postgres``
47
48
 
48
- The package supports the following python versions: 3.10,3.11,3.12
49
+ The package supports the following python versions: 3.10,3.11,3.12,3.13
49
50
 
50
51
  Requirements
51
52
  ------------
52
53
 
53
- ======================================= ==================
54
+ ======================================= ======================================
54
55
  PIP package Version required
55
- ======================================= ==================
56
+ ======================================= ======================================
56
57
  ``apache-airflow`` ``>=2.10.0``
57
58
  ``apache-airflow-providers-common-sql`` ``>=1.23.0``
58
- ``psycopg2-binary`` ``>=2.9.9``
59
+ ``psycopg2-binary`` ``>=2.9.9; python_version < "3.13"``
60
+ ``psycopg2-binary`` ``>=2.9.10; python_version >= "3.13"``
59
61
  ``asyncpg`` ``>=0.30.0``
60
- ======================================= ==================
62
+ ======================================= ======================================
61
63
 
62
64
  Cross provider package dependencies
63
65
  -----------------------------------
@@ -81,4 +83,4 @@ Dependent package
81
83
  ============================================================================================================== ===============
82
84
 
83
85
  The changelog for the provider package can be found in the
84
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.1/changelog.html>`_.
86
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.2/changelog.html>`_.
@@ -27,6 +27,26 @@
27
27
  Changelog
28
28
  ---------
29
29
 
30
+ 6.2.2
31
+ .....
32
+
33
+ Bug Fixes
34
+ ~~~~~~~~~
35
+
36
+ * ``fix(postgres/hooks): ensure get_df uses SQLAlchemy engine to avoid pandas warning (#52224)``
37
+
38
+ Misc
39
+ ~~~~
40
+
41
+ * ``Add Python 3.13 support for Airflow. (#46891)``
42
+ * ``Cleanup type ignores in postgres provider where possible (#53275)``
43
+ * ``Remove type ignore across codebase after mypy upgrade (#53243)``
44
+ * ``Remove upper-binding for "python-requires" (#52980)``
45
+ * ``Temporarily switch to use >=,< pattern instead of '~=' (#52967)``
46
+
47
+ .. Below changes are excluded from the changelog. Move them to
48
+ appropriate section above if needed. Do not delete the lines(!):
49
+
30
50
  6.2.1
31
51
  .....
32
52
 
@@ -77,7 +77,9 @@ apache-airflow-providers-postgres package
77
77
  `PostgreSQL <https://www.postgresql.org/>`__
78
78
 
79
79
 
80
- Release: 6.2.1
80
+ Release: 6.2.2
81
+
82
+ Release Date: ``|PypiReleaseDate|``
81
83
 
82
84
  Provider package
83
85
  ----------------
@@ -97,14 +99,15 @@ Requirements
97
99
 
98
100
  The minimum Apache Airflow version supported by this provider distribution is ``2.10.0``.
99
101
 
100
- ======================================= ==================
102
+ ======================================= ======================================
101
103
  PIP package Version required
102
- ======================================= ==================
104
+ ======================================= ======================================
103
105
  ``apache-airflow`` ``>=2.10.0``
104
106
  ``apache-airflow-providers-common-sql`` ``>=1.23.0``
105
- ``psycopg2-binary`` ``>=2.9.9``
107
+ ``psycopg2-binary`` ``>=2.9.9; python_version < "3.13"``
108
+ ``psycopg2-binary`` ``>=2.9.10; python_version >= "3.13"``
106
109
  ``asyncpg`` ``>=0.30.0``
107
- ======================================= ==================
110
+ ======================================= ======================================
108
111
 
109
112
  Cross provider package dependencies
110
113
  -----------------------------------
@@ -133,5 +136,5 @@ Downloading official packages
133
136
  You can download officially released packages and verify their checksums and signatures from the
134
137
  `Official Apache Download site <https://downloads.apache.org/airflow/providers/>`_
135
138
 
136
- * `The apache-airflow-providers-postgres 6.2.1 sdist package <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.1.tar.gz>`_ (`asc <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.1.tar.gz.asc>`__, `sha512 <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.1.tar.gz.sha512>`__)
137
- * `The apache-airflow-providers-postgres 6.2.1 wheel package <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.1-py3-none-any.whl>`_ (`asc <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.1-py3-none-any.whl.asc>`__, `sha512 <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.1-py3-none-any.whl.sha512>`__)
139
+ * `The apache-airflow-providers-postgres 6.2.2 sdist package <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.2.tar.gz>`_ (`asc <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.2.tar.gz.asc>`__, `sha512 <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.2.tar.gz.sha512>`__)
140
+ * `The apache-airflow-providers-postgres 6.2.2 wheel package <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.2-py3-none-any.whl>`_ (`asc <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.2-py3-none-any.whl.asc>`__, `sha512 <https://downloads.apache.org/airflow/providers/apache_airflow_providers_postgres-6.2.2-py3-none-any.whl.sha512>`__)
@@ -22,12 +22,13 @@ description: |
22
22
  `PostgreSQL <https://www.postgresql.org/>`__
23
23
 
24
24
  state: ready
25
- source-date-epoch: 1751474070
25
+ source-date-epoch: 1753691797
26
26
  # Note that those versions are maintained by release manager - do not update them manually
27
27
  # with the exception of case where other provider in sources has >= new provider version.
28
28
  # In such case adding >= NEW_VERSION and bumping to NEW_VERSION in a provider have
29
29
  # to be done in the same PR
30
30
  versions:
31
+ - 6.2.2
31
32
  - 6.2.1
32
33
  - 6.2.0
33
34
  - 6.1.3
@@ -25,7 +25,7 @@ build-backend = "flit_core.buildapi"
25
25
 
26
26
  [project]
27
27
  name = "apache-airflow-providers-postgres"
28
- version = "6.2.1rc1"
28
+ version = "6.2.2rc1"
29
29
  description = "Provider package apache-airflow-providers-postgres for Apache Airflow"
30
30
  readme = "README.rst"
31
31
  authors = [
@@ -47,9 +47,10 @@ classifiers = [
47
47
  "Programming Language :: Python :: 3.10",
48
48
  "Programming Language :: Python :: 3.11",
49
49
  "Programming Language :: Python :: 3.12",
50
+ "Programming Language :: Python :: 3.13",
50
51
  "Topic :: System :: Monitoring",
51
52
  ]
52
- requires-python = "~=3.10"
53
+ requires-python = ">=3.10"
53
54
 
54
55
  # The dependencies should be modified in place in the generated file.
55
56
  # Any change in the dependencies is preserved when the file is regenerated
@@ -58,7 +59,8 @@ requires-python = "~=3.10"
58
59
  dependencies = [
59
60
  "apache-airflow>=2.10.0rc1",
60
61
  "apache-airflow-providers-common-sql>=1.23.0rc1",
61
- "psycopg2-binary>=2.9.9",
62
+ "psycopg2-binary>=2.9.9; python_version < '3.13'",
63
+ "psycopg2-binary>=2.9.10; python_version >= '3.13'",
62
64
  "asyncpg>=0.30.0",
63
65
  ]
64
66
 
@@ -71,6 +73,13 @@ dependencies = [
71
73
  "openlineage" = [
72
74
  "apache-airflow-providers-openlineage"
73
75
  ]
76
+ "pandas" = [
77
+ 'pandas>=2.1.2; python_version <"3.13"',
78
+ 'pandas>=2.2.3; python_version >="3.13"',
79
+ ]
80
+ "polars" = [
81
+ "polars>=1.26.0"
82
+ ]
74
83
 
75
84
  [dependency-groups]
76
85
  dev = [
@@ -81,6 +90,8 @@ dev = [
81
90
  "apache-airflow-providers-common-sql",
82
91
  "apache-airflow-providers-openlineage",
83
92
  # Additional devel dependencies (do not remove this line and add extra development dependencies)
93
+ "apache-airflow-providers-common-sql[pandas]",
94
+ "apache-airflow-providers-common-sql[polars]",
84
95
  ]
85
96
 
86
97
  # To build docs:
@@ -109,8 +120,8 @@ apache-airflow-providers-common-sql = {workspace = true}
109
120
  apache-airflow-providers-standard = {workspace = true}
110
121
 
111
122
  [project.urls]
112
- "Documentation" = "https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.1"
113
- "Changelog" = "https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.1/changelog.html"
123
+ "Documentation" = "https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.2"
124
+ "Changelog" = "https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.2/changelog.html"
114
125
  "Bug Tracker" = "https://github.com/apache/airflow/issues"
115
126
  "Source Code" = "https://github.com/apache/airflow"
116
127
  "Slack Chat" = "https://s.apache.org/airflow-slack"
@@ -14,4 +14,4 @@
14
14
  # KIND, either express or implied. See the License for the
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
- __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
17
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
@@ -14,4 +14,4 @@
14
14
  # KIND, either express or implied. See the License for the
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
- __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
17
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
@@ -29,7 +29,7 @@ from airflow import __version__ as airflow_version
29
29
 
30
30
  __all__ = ["__version__"]
31
31
 
32
- __version__ = "6.2.1"
32
+ __version__ = "6.2.2"
33
33
 
34
34
  if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
35
35
  "2.10.0"
@@ -18,9 +18,10 @@
18
18
  from __future__ import annotations
19
19
 
20
20
  import os
21
+ from collections.abc import Mapping
21
22
  from contextlib import closing
22
23
  from copy import deepcopy
23
- from typing import TYPE_CHECKING, Any, TypeAlias, cast
24
+ from typing import TYPE_CHECKING, Any, Literal, TypeAlias, cast, overload
24
25
 
25
26
  import psycopg2
26
27
  import psycopg2.extensions
@@ -28,11 +29,16 @@ import psycopg2.extras
28
29
  from psycopg2.extras import DictCursor, Json, NamedTupleCursor, RealDictCursor
29
30
  from sqlalchemy.engine import URL
30
31
 
31
- from airflow.exceptions import AirflowException
32
+ from airflow.exceptions import (
33
+ AirflowException,
34
+ AirflowOptionalProviderFeatureException,
35
+ )
32
36
  from airflow.providers.common.sql.hooks.sql import DbApiHook
33
37
  from airflow.providers.postgres.dialects.postgres import PostgresDialect
34
38
 
35
39
  if TYPE_CHECKING:
40
+ from pandas import DataFrame as PandasDataFrame
41
+ from polars import DataFrame as PolarsDataFrame
36
42
  from psycopg2.extensions import connection
37
43
 
38
44
  from airflow.providers.common.sql.dialects.dialect import Dialect
@@ -177,6 +183,62 @@ class PostgresHook(DbApiHook):
177
183
  self.conn = psycopg2.connect(**conn_args)
178
184
  return self.conn
179
185
 
186
+ @overload
187
+ def get_df(
188
+ self,
189
+ sql: str | list[str],
190
+ parameters: list | tuple | Mapping[str, Any] | None = None,
191
+ *,
192
+ df_type: Literal["pandas"] = "pandas",
193
+ **kwargs: Any,
194
+ ) -> PandasDataFrame: ...
195
+
196
+ @overload
197
+ def get_df(
198
+ self,
199
+ sql: str | list[str],
200
+ parameters: list | tuple | Mapping[str, Any] | None = None,
201
+ *,
202
+ df_type: Literal["polars"] = ...,
203
+ **kwargs: Any,
204
+ ) -> PolarsDataFrame: ...
205
+
206
+ def get_df(
207
+ self,
208
+ sql: str | list[str],
209
+ parameters: list | tuple | Mapping[str, Any] | None = None,
210
+ *,
211
+ df_type: Literal["pandas", "polars"] = "pandas",
212
+ **kwargs: Any,
213
+ ) -> PandasDataFrame | PolarsDataFrame:
214
+ """
215
+ Execute the sql and returns a dataframe.
216
+
217
+ :param sql: the sql statement to be executed (str) or a list of sql statements to execute
218
+ :param parameters: The parameters to render the SQL query with.
219
+ :param df_type: Type of dataframe to return, either "pandas" or "polars"
220
+ :param kwargs: (optional) passed into `pandas.io.sql.read_sql` or `polars.read_database` method
221
+ :return: A pandas or polars DataFrame containing the query results.
222
+ """
223
+ if df_type == "pandas":
224
+ try:
225
+ from pandas.io import sql as psql
226
+ except ImportError:
227
+ raise AirflowOptionalProviderFeatureException(
228
+ "pandas library not installed, run: pip install "
229
+ "'apache-airflow-providers-common-sql[pandas]'."
230
+ )
231
+
232
+ engine = self.get_sqlalchemy_engine()
233
+ with engine.connect() as conn:
234
+ return psql.read_sql(sql, con=conn, params=parameters, **kwargs)
235
+
236
+ elif df_type == "polars":
237
+ return self._get_polars_df(sql, parameters, **kwargs)
238
+
239
+ else:
240
+ raise ValueError(f"Unsupported df_type: {df_type}")
241
+
180
242
  def copy_expert(self, sql: str, filename: str) -> None:
181
243
  """
182
244
  Execute SQL using psycopg2's ``copy_expert`` method.
@@ -315,9 +377,7 @@ class PostgresHook(DbApiHook):
315
377
  if is_redshift:
316
378
  authority = self._get_openlineage_redshift_authority_part(connection)
317
379
  else:
318
- authority = DbApiHook.get_openlineage_authority_part( # type: ignore[attr-defined]
319
- connection, default_port=5432
320
- )
380
+ authority = DbApiHook.get_openlineage_authority_part(connection, default_port=5432)
321
381
 
322
382
  return DatabaseInfo(
323
383
  scheme="postgres" if not is_redshift else "redshift",
@@ -14,4 +14,4 @@
14
14
  # KIND, either express or implied. See the License for the
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
- __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
17
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
@@ -14,4 +14,4 @@
14
14
  # KIND, either express or implied. See the License for the
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
- __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
17
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
@@ -22,6 +22,8 @@ import logging
22
22
  import os
23
23
  from unittest import mock
24
24
 
25
+ import pandas as pd
26
+ import polars as pl
25
27
  import psycopg2.extras
26
28
  import pytest
27
29
  import sqlalchemy
@@ -33,6 +35,8 @@ from airflow.providers.postgres.dialects.postgres import PostgresDialect
33
35
  from airflow.providers.postgres.hooks.postgres import PostgresHook
34
36
  from airflow.utils.types import NOTSET
35
37
 
38
+ from tests_common.test_utils.common_sql import mock_db_hook
39
+
36
40
  INSERT_SQL_STATEMENT = "INSERT INTO connection (id, conn_id, conn_type, description, host, {}, login, password, port, is_encrypted, is_extra_encrypted, extra) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
37
41
 
38
42
 
@@ -517,6 +521,36 @@ class TestPostgresHook:
517
521
  else:
518
522
  assert expected_serialized == raw_cell
519
523
 
524
+ @pytest.mark.parametrize(
525
+ "df_type, expected_type",
526
+ [
527
+ ("pandas", pd.DataFrame),
528
+ ("polars", pl.DataFrame),
529
+ ],
530
+ )
531
+ @mock.patch("airflow.providers.postgres.hooks.postgres.PostgresHook._get_polars_df")
532
+ @mock.patch("pandas.io.sql.read_sql")
533
+ @mock.patch("airflow.providers.postgres.hooks.postgres.PostgresHook.get_sqlalchemy_engine")
534
+ def test_get_df_with_df_type(
535
+ self, mock_get_engine, mock_read_sql, mock_polars_df, df_type, expected_type
536
+ ):
537
+ hook = mock_db_hook(PostgresHook)
538
+ mock_read_sql.return_value = pd.DataFrame()
539
+ mock_polars_df.return_value = pl.DataFrame()
540
+ sql = "SELECT * FROM table"
541
+ if df_type == "pandas":
542
+ mock_conn = mock.MagicMock()
543
+ mock_engine = mock.MagicMock()
544
+ mock_engine.connect.return_value.__enter__.return_value = mock_conn
545
+ mock_get_engine.return_value = mock_engine
546
+ df = hook.get_df(sql, df_type="pandas")
547
+ mock_read_sql.assert_called_once_with(sql, con=mock_conn, params=None)
548
+ assert isinstance(df, expected_type)
549
+ elif df_type == "polars":
550
+ df = hook.get_df(sql, df_type="polars")
551
+ mock_polars_df.assert_called_once_with(sql, None)
552
+ assert isinstance(df, expected_type)
553
+
520
554
  def test_insert_rows(self):
521
555
  table = "table"
522
556
  rows = [("hello",), ("world",)]