apache-airflow-providers-postgres 5.5.2rc2__py3-none-any.whl → 5.6.0__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 +4 -2
- airflow/providers/postgres/get_provider_info.py +1 -0
- airflow/providers/postgres/hooks/postgres.py +47 -1
- airflow/providers/postgres/operators/postgres.py +4 -0
- {apache_airflow_providers_postgres-5.5.2rc2.dist-info → apache_airflow_providers_postgres-5.6.0.dist-info}/METADATA +17 -14
- apache_airflow_providers_postgres-5.6.0.dist-info/RECORD +13 -0
- {apache_airflow_providers_postgres-5.5.2rc2.dist-info → apache_airflow_providers_postgres-5.6.0.dist-info}/WHEEL +1 -1
- apache_airflow_providers_postgres-5.5.2rc2.dist-info/RECORD +0 -13
- {apache_airflow_providers_postgres-5.5.2rc2.dist-info → apache_airflow_providers_postgres-5.6.0.dist-info}/LICENSE +0 -0
- {apache_airflow_providers_postgres-5.5.2rc2.dist-info → apache_airflow_providers_postgres-5.6.0.dist-info}/NOTICE +0 -0
- {apache_airflow_providers_postgres-5.5.2rc2.dist-info → apache_airflow_providers_postgres-5.6.0.dist-info}/entry_points.txt +0 -0
- {apache_airflow_providers_postgres-5.5.2rc2.dist-info → apache_airflow_providers_postgres-5.6.0.dist-info}/top_level.txt +0 -0
@@ -28,14 +28,16 @@ import packaging.version
|
|
28
28
|
|
29
29
|
__all__ = ["__version__"]
|
30
30
|
|
31
|
-
__version__ = "5.
|
31
|
+
__version__ = "5.6.0"
|
32
32
|
|
33
33
|
try:
|
34
34
|
from airflow import __version__ as airflow_version
|
35
35
|
except ImportError:
|
36
36
|
from airflow.version import version as airflow_version
|
37
37
|
|
38
|
-
if packaging.version.parse(airflow_version) < packaging.version.parse(
|
38
|
+
if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
|
39
|
+
"2.4.0"
|
40
|
+
):
|
39
41
|
raise RuntimeError(
|
40
42
|
f"The package `apache-airflow-providers-postgres:{__version__}` requires Apache Airflow 2.4.0+" # NOQA: E501
|
41
43
|
)
|
@@ -21,7 +21,7 @@ import os
|
|
21
21
|
import warnings
|
22
22
|
from contextlib import closing
|
23
23
|
from copy import deepcopy
|
24
|
-
from typing import Any, Iterable, Union
|
24
|
+
from typing import TYPE_CHECKING, Any, Iterable, Union
|
25
25
|
|
26
26
|
import psycopg2
|
27
27
|
import psycopg2.extensions
|
@@ -33,6 +33,9 @@ from airflow.exceptions import AirflowProviderDeprecationWarning
|
|
33
33
|
from airflow.models.connection import Connection
|
34
34
|
from airflow.providers.common.sql.hooks.sql import DbApiHook
|
35
35
|
|
36
|
+
if TYPE_CHECKING:
|
37
|
+
from airflow.providers.openlineage.sqlparser import DatabaseInfo
|
38
|
+
|
36
39
|
CursorType = Union[DictCursor, RealDictCursor, NamedTupleCursor]
|
37
40
|
|
38
41
|
|
@@ -317,3 +320,46 @@ class PostgresHook(DbApiHook):
|
|
317
320
|
sql += f"{on_conflict_str} DO NOTHING"
|
318
321
|
|
319
322
|
return sql
|
323
|
+
|
324
|
+
def get_openlineage_database_info(self, connection) -> DatabaseInfo:
|
325
|
+
"""Returns Postgres/Redshift specific information for OpenLineage."""
|
326
|
+
from airflow.providers.openlineage.sqlparser import DatabaseInfo
|
327
|
+
|
328
|
+
is_redshift = connection.extra_dejson.get("redshift", False)
|
329
|
+
|
330
|
+
if is_redshift:
|
331
|
+
authority = self._get_openlineage_redshift_authority_part(connection)
|
332
|
+
else:
|
333
|
+
authority = DbApiHook.get_openlineage_authority_part(connection, default_port=5432)
|
334
|
+
|
335
|
+
return DatabaseInfo(
|
336
|
+
scheme="postgres" if not is_redshift else "redshift",
|
337
|
+
authority=authority,
|
338
|
+
database=self.database or connection.schema,
|
339
|
+
)
|
340
|
+
|
341
|
+
def _get_openlineage_redshift_authority_part(self, connection) -> str:
|
342
|
+
try:
|
343
|
+
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
|
344
|
+
except ImportError:
|
345
|
+
from airflow.exceptions import AirflowException
|
346
|
+
|
347
|
+
raise AirflowException(
|
348
|
+
"apache-airflow-providers-amazon not installed, run: "
|
349
|
+
"pip install 'apache-airflow-providers-postgres[amazon]'."
|
350
|
+
)
|
351
|
+
aws_conn_id = connection.extra_dejson.get("aws_conn_id", "aws_default")
|
352
|
+
|
353
|
+
port = connection.port or 5439
|
354
|
+
cluster_identifier = connection.extra_dejson.get("cluster-identifier", connection.host.split(".")[0])
|
355
|
+
region_name = AwsBaseHook(aws_conn_id=aws_conn_id).region_name
|
356
|
+
|
357
|
+
return f"{cluster_identifier}.{region_name}:{port}"
|
358
|
+
|
359
|
+
def get_openlineage_database_dialect(self, connection) -> str:
|
360
|
+
"""Returns postgres/redshift dialect."""
|
361
|
+
return "redshift" if connection.extra_dejson.get("redshift", False) else "postgres"
|
362
|
+
|
363
|
+
def get_openlineage_default_schema(self) -> str | None:
|
364
|
+
"""Returns current schema. This is usually changed with ``SEARCH_PATH`` parameter."""
|
365
|
+
return self.get_first("SELECT CURRENT_SCHEMA;")[0]
|
@@ -28,6 +28,10 @@ class PostgresOperator(SQLExecuteQueryOperator):
|
|
28
28
|
"""
|
29
29
|
Executes sql code in a specific Postgres database.
|
30
30
|
|
31
|
+
This class is deprecated.
|
32
|
+
|
33
|
+
Please use :class:`airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`.
|
34
|
+
|
31
35
|
:param sql: the SQL code to be executed as a single string, or
|
32
36
|
a list of str (sql statements), or a reference to a template file.
|
33
37
|
Template references are recognized by str ending in '.sql'
|
@@ -1,14 +1,14 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: apache-airflow-providers-postgres
|
3
|
-
Version: 5.
|
3
|
+
Version: 5.6.0
|
4
4
|
Summary: Provider for Apache Airflow. Implements apache-airflow-providers-postgres package
|
5
5
|
Home-page: https://airflow.apache.org/
|
6
6
|
Download-URL: https://archive.apache.org/dist/airflow/providers
|
7
7
|
Author: Apache Software Foundation
|
8
8
|
Author-email: dev@airflow.apache.org
|
9
9
|
License: Apache License 2.0
|
10
|
-
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.
|
11
|
-
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.
|
10
|
+
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.6.0/
|
11
|
+
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.6.0/changelog.html
|
12
12
|
Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
|
13
13
|
Project-URL: Source Code, https://github.com/apache/airflow
|
14
14
|
Project-URL: Slack Chat, https://s.apache.org/airflow-slack
|
@@ -31,13 +31,15 @@ Requires-Python: ~=3.8
|
|
31
31
|
Description-Content-Type: text/x-rst
|
32
32
|
License-File: LICENSE
|
33
33
|
License-File: NOTICE
|
34
|
-
Requires-Dist: apache-airflow-providers-common-sql (>=1.3.1
|
35
|
-
Requires-Dist: apache-airflow (>=2.4.0
|
34
|
+
Requires-Dist: apache-airflow-providers-common-sql (>=1.3.1)
|
35
|
+
Requires-Dist: apache-airflow (>=2.4.0)
|
36
36
|
Requires-Dist: psycopg2-binary (>=2.8.0)
|
37
37
|
Provides-Extra: amazon
|
38
38
|
Requires-Dist: apache-airflow-providers-amazon (>=2.6.0) ; extra == 'amazon'
|
39
39
|
Provides-Extra: common.sql
|
40
40
|
Requires-Dist: apache-airflow-providers-common-sql ; extra == 'common.sql'
|
41
|
+
Provides-Extra: openlineage
|
42
|
+
Requires-Dist: apache-airflow-providers-openlineage ; extra == 'openlineage'
|
41
43
|
|
42
44
|
|
43
45
|
.. Licensed to the Apache Software Foundation (ASF) under one
|
@@ -77,7 +79,7 @@ Requires-Dist: apache-airflow-providers-common-sql ; extra == 'common.sql'
|
|
77
79
|
|
78
80
|
Package ``apache-airflow-providers-postgres``
|
79
81
|
|
80
|
-
Release: ``5.
|
82
|
+
Release: ``5.6.0``
|
81
83
|
|
82
84
|
|
83
85
|
`PostgreSQL <https://www.postgresql.org/>`__
|
@@ -90,7 +92,7 @@ This is a provider package for ``postgres`` provider. All classes for this provi
|
|
90
92
|
are in ``airflow.providers.postgres`` python package.
|
91
93
|
|
92
94
|
You can find package information and changelog for the provider
|
93
|
-
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.
|
95
|
+
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.6.0/>`_.
|
94
96
|
|
95
97
|
|
96
98
|
Installation
|
@@ -126,12 +128,13 @@ You can install such cross-provider dependencies when installing from PyPI. For
|
|
126
128
|
pip install apache-airflow-providers-postgres[amazon]
|
127
129
|
|
128
130
|
|
129
|
-
|
130
|
-
Dependent package
|
131
|
-
|
132
|
-
`apache-airflow-providers-amazon <https://airflow.apache.org/docs/apache-airflow-providers-amazon>`_
|
133
|
-
`apache-airflow-providers-common-sql <https://airflow.apache.org/docs/apache-airflow-providers-common-sql>`_
|
134
|
-
|
131
|
+
============================================================================================================== ===============
|
132
|
+
Dependent package Extra
|
133
|
+
============================================================================================================== ===============
|
134
|
+
`apache-airflow-providers-amazon <https://airflow.apache.org/docs/apache-airflow-providers-amazon>`_ ``amazon``
|
135
|
+
`apache-airflow-providers-common-sql <https://airflow.apache.org/docs/apache-airflow-providers-common-sql>`_ ``common.sql``
|
136
|
+
`apache-airflow-providers-openlineage <https://airflow.apache.org/docs/apache-airflow-providers-openlineage>`_ ``openlineage``
|
137
|
+
============================================================================================================== ===============
|
135
138
|
|
136
139
|
The changelog for the provider package can be found in the
|
137
|
-
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.
|
140
|
+
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-postgres/5.6.0/changelog.html>`_.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
airflow/providers/postgres/__init__.py,sha256=8epKsPUPz0y18-ywzTPCsP13mywZ4CpX6ZrQ-EOrX60,1577
|
2
|
+
airflow/providers/postgres/get_provider_info.py,sha256=x8rgbDV8-j_KbfnelfcoOInla0qakl0S2iNaRe_Fbxc,3119
|
3
|
+
airflow/providers/postgres/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
4
|
+
airflow/providers/postgres/hooks/postgres.py,sha256=Yn6NKaDkgPH0QeZs10RNKUsgqok1RKIsZ3mN2i4-puY,15392
|
5
|
+
airflow/providers/postgres/operators/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
6
|
+
airflow/providers/postgres/operators/postgres.py,sha256=jciwF-MeXCuz4sPen7jUWayDXPMPQMOhOI3swCqV4I8,3591
|
7
|
+
apache_airflow_providers_postgres-5.6.0.dist-info/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
|
8
|
+
apache_airflow_providers_postgres-5.6.0.dist-info/METADATA,sha256=Aa9JdzHP8lVejsZWaq_j90hh7coWUzLCXUJobLDiL4w,6345
|
9
|
+
apache_airflow_providers_postgres-5.6.0.dist-info/NOTICE,sha256=m-6s2XynUxVSUIxO4rVablAZCvFq-wmLrqV91DotRBw,240
|
10
|
+
apache_airflow_providers_postgres-5.6.0.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
|
11
|
+
apache_airflow_providers_postgres-5.6.0.dist-info/entry_points.txt,sha256=boiuBo37TJDstSn7YjGsk80nn8EOyQ_s3sVJmIJ8Sp8,105
|
12
|
+
apache_airflow_providers_postgres-5.6.0.dist-info/top_level.txt,sha256=OeMVH5md7fr2QQWpnZoOWWxWO-0WH1IP70lpTVwopPg,8
|
13
|
+
apache_airflow_providers_postgres-5.6.0.dist-info/RECORD,,
|
@@ -1,13 +0,0 @@
|
|
1
|
-
airflow/providers/postgres/__init__.py,sha256=HC4IJM3f3qy-qI8jkgt1I0LpisWCx0yJJHmaimwOaPo,1533
|
2
|
-
airflow/providers/postgres/get_provider_info.py,sha256=J8uMfa6fZk74LkkVQzdNnwHq1_dKmMJtElP4wPCWMWQ,3098
|
3
|
-
airflow/providers/postgres/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
4
|
-
airflow/providers/postgres/hooks/postgres.py,sha256=VZMqETR2iWRhXvqBW3z_H4B8mkuYq8ZfA4l5ZUqlieg,13342
|
5
|
-
airflow/providers/postgres/operators/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
6
|
-
airflow/providers/postgres/operators/postgres.py,sha256=M2_3KAFMx-Cs-hQjiQ--tiM9E1V8xgmX-UroKDArCds,3467
|
7
|
-
apache_airflow_providers_postgres-5.5.2rc2.dist-info/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
|
8
|
-
apache_airflow_providers_postgres-5.5.2rc2.dist-info/METADATA,sha256=uk4cgyIiyLRRbW97J_oeibzhNvW_MHfVTt5fe-XuhWs,6113
|
9
|
-
apache_airflow_providers_postgres-5.5.2rc2.dist-info/NOTICE,sha256=m-6s2XynUxVSUIxO4rVablAZCvFq-wmLrqV91DotRBw,240
|
10
|
-
apache_airflow_providers_postgres-5.5.2rc2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
11
|
-
apache_airflow_providers_postgres-5.5.2rc2.dist-info/entry_points.txt,sha256=boiuBo37TJDstSn7YjGsk80nn8EOyQ_s3sVJmIJ8Sp8,105
|
12
|
-
apache_airflow_providers_postgres-5.5.2rc2.dist-info/top_level.txt,sha256=OeMVH5md7fr2QQWpnZoOWWxWO-0WH1IP70lpTVwopPg,8
|
13
|
-
apache_airflow_providers_postgres-5.5.2rc2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|