apache-airflow-providers-postgres 6.2.1rc1__py3-none-any.whl → 6.2.2rc1__py3-none-any.whl
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.
- airflow/providers/postgres/__init__.py +1 -1
- airflow/providers/postgres/hooks/postgres.py +65 -5
- {apache_airflow_providers_postgres-6.2.1rc1.dist-info → apache_airflow_providers_postgres-6.2.2rc1.dist-info}/METADATA +22 -13
- {apache_airflow_providers_postgres-6.2.1rc1.dist-info → apache_airflow_providers_postgres-6.2.2rc1.dist-info}/RECORD +6 -6
- {apache_airflow_providers_postgres-6.2.1rc1.dist-info → apache_airflow_providers_postgres-6.2.2rc1.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_postgres-6.2.1rc1.dist-info → apache_airflow_providers_postgres-6.2.2rc1.dist-info}/entry_points.txt +0 -0
@@ -29,7 +29,7 @@ from airflow import __version__ as airflow_version
|
|
29
29
|
|
30
30
|
__all__ = ["__version__"]
|
31
31
|
|
32
|
-
__version__ = "6.2.
|
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
|
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(
|
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",
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: apache-airflow-providers-postgres
|
3
|
-
Version: 6.2.
|
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:
|
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.
|
30
|
-
Project-URL: Documentation, https://airflow.staged.apache.org/docs/apache-airflow-providers-postgres/6.2.
|
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.
|
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.
|
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.
|
130
|
+
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/6.2.2/changelog.html>`_.
|
122
131
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
airflow/providers/postgres/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
|
2
|
-
airflow/providers/postgres/__init__.py,sha256=
|
2
|
+
airflow/providers/postgres/__init__.py,sha256=FlEbneFcch2XA2xgjink0A627hTPgaO-v539Ks-FIFg,1497
|
3
3
|
airflow/providers/postgres/get_provider_info.py,sha256=qEEYbClLY3-NH40dBk2u_nOIfvfEIHdXaWsIJ8J5Z68,2626
|
4
4
|
airflow/providers/postgres/assets/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
5
5
|
airflow/providers/postgres/assets/postgres.py,sha256=XNhOJCbOA_soaaiS73JjULMqAM_7PBryhToe8FJREA0,1522
|
6
6
|
airflow/providers/postgres/dialects/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
7
7
|
airflow/providers/postgres/dialects/postgres.py,sha256=8ygA2Jq2WBPhNOISU8YyitLmahxWnPGYNt8OaU_CBFI,3764
|
8
8
|
airflow/providers/postgres/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
9
|
-
airflow/providers/postgres/hooks/postgres.py,sha256=
|
10
|
-
apache_airflow_providers_postgres-6.2.
|
11
|
-
apache_airflow_providers_postgres-6.2.
|
12
|
-
apache_airflow_providers_postgres-6.2.
|
13
|
-
apache_airflow_providers_postgres-6.2.
|
9
|
+
airflow/providers/postgres/hooks/postgres.py,sha256=M0B0VX4E4U0LZRqVhiqi7GmIH_1oZ0RZGDAhzm9ZvlA,17742
|
10
|
+
apache_airflow_providers_postgres-6.2.2rc1.dist-info/entry_points.txt,sha256=dhtJi6PTWHd6BwKhmI4OtSPvQVI_p0yYWI0eba83HqY,104
|
11
|
+
apache_airflow_providers_postgres-6.2.2rc1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
12
|
+
apache_airflow_providers_postgres-6.2.2rc1.dist-info/METADATA,sha256=7XCr-2MXjAQmSXtAIFZkZkNv-rnHlybw04gpzLwvJyk,6264
|
13
|
+
apache_airflow_providers_postgres-6.2.2rc1.dist-info/RECORD,,
|
File without changes
|