apache-airflow-providers-common-sql 1.11.1rc1__py3-none-any.whl → 1.12.0rc1__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/common/sql/__init__.py +1 -1
- airflow/providers/common/sql/get_provider_info.py +2 -1
- airflow/providers/common/sql/hooks/sql.py +31 -18
- airflow/providers/common/sql/operators/sql.py +7 -6
- airflow/providers/common/sql/sensors/sql.py +1 -1
- {apache_airflow_providers_common_sql-1.11.1rc1.dist-info → apache_airflow_providers_common_sql-1.12.0rc1.dist-info}/METADATA +9 -8
- {apache_airflow_providers_common_sql-1.11.1rc1.dist-info → apache_airflow_providers_common_sql-1.12.0rc1.dist-info}/RECORD +9 -9
- {apache_airflow_providers_common_sql-1.11.1rc1.dist-info → apache_airflow_providers_common_sql-1.12.0rc1.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_common_sql-1.11.1rc1.dist-info → apache_airflow_providers_common_sql-1.12.0rc1.dist-info}/entry_points.txt +0 -0
|
@@ -28,8 +28,9 @@ def get_provider_info():
|
|
|
28
28
|
"name": "Common SQL",
|
|
29
29
|
"description": "`Common SQL Provider <https://en.wikipedia.org/wiki/SQL>`__\n",
|
|
30
30
|
"state": "ready",
|
|
31
|
-
"source-date-epoch":
|
|
31
|
+
"source-date-epoch": 1712665507,
|
|
32
32
|
"versions": [
|
|
33
|
+
"1.12.0",
|
|
33
34
|
"1.11.1",
|
|
34
35
|
"1.11.0",
|
|
35
36
|
"1.10.1",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import contextlib
|
|
20
|
+
import warnings
|
|
20
21
|
from contextlib import closing
|
|
21
22
|
from datetime import datetime
|
|
22
23
|
from typing import (
|
|
@@ -36,11 +37,14 @@ from typing import (
|
|
|
36
37
|
from urllib.parse import urlparse
|
|
37
38
|
|
|
38
39
|
import sqlparse
|
|
39
|
-
from deprecated import deprecated
|
|
40
40
|
from more_itertools import chunked
|
|
41
41
|
from sqlalchemy import create_engine
|
|
42
42
|
|
|
43
|
-
from airflow.exceptions import
|
|
43
|
+
from airflow.exceptions import (
|
|
44
|
+
AirflowException,
|
|
45
|
+
AirflowOptionalProviderFeatureException,
|
|
46
|
+
AirflowProviderDeprecationWarning,
|
|
47
|
+
)
|
|
44
48
|
from airflow.hooks.base import BaseHook
|
|
45
49
|
|
|
46
50
|
if TYPE_CHECKING:
|
|
@@ -50,6 +54,7 @@ if TYPE_CHECKING:
|
|
|
50
54
|
from airflow.providers.openlineage.sqlparser import DatabaseInfo
|
|
51
55
|
|
|
52
56
|
T = TypeVar("T")
|
|
57
|
+
SQL_PLACEHOLDERS = frozenset({"%s", "?"})
|
|
53
58
|
|
|
54
59
|
|
|
55
60
|
def return_single_query_results(sql: str | Iterable[str], return_last: bool, split_statements: bool):
|
|
@@ -146,6 +151,8 @@ class DbApiHook(BaseHook):
|
|
|
146
151
|
connector: ConnectorProtocol | None = None
|
|
147
152
|
# Override with db-specific query to check connection
|
|
148
153
|
_test_connection_sql = "select 1"
|
|
154
|
+
# Default SQL placeholder
|
|
155
|
+
_placeholder: str = "%s"
|
|
149
156
|
|
|
150
157
|
def __init__(self, *args, schema: str | None = None, log_sql: bool = True, **kwargs):
|
|
151
158
|
super().__init__()
|
|
@@ -164,7 +171,6 @@ class DbApiHook(BaseHook):
|
|
|
164
171
|
self.__schema = schema
|
|
165
172
|
self.log_sql = log_sql
|
|
166
173
|
self.descriptions: list[Sequence[Sequence] | None] = []
|
|
167
|
-
self._placeholder: str = "%s"
|
|
168
174
|
self._insert_statement_format: str = kwargs.get(
|
|
169
175
|
"insert_statement_format", "INSERT INTO {} {} VALUES ({})"
|
|
170
176
|
)
|
|
@@ -173,7 +179,17 @@ class DbApiHook(BaseHook):
|
|
|
173
179
|
)
|
|
174
180
|
|
|
175
181
|
@property
|
|
176
|
-
def placeholder(self)
|
|
182
|
+
def placeholder(self):
|
|
183
|
+
conn = self.get_connection(getattr(self, self.conn_name_attr))
|
|
184
|
+
placeholder = conn.extra_dejson.get("placeholder")
|
|
185
|
+
if placeholder in SQL_PLACEHOLDERS:
|
|
186
|
+
return placeholder
|
|
187
|
+
self.log.warning(
|
|
188
|
+
"Placeholder defined in Connection '%s' is not listed in 'DEFAULT_SQL_PLACEHOLDERS' "
|
|
189
|
+
"and got ignored. Falling back to the default placeholder '%s'.",
|
|
190
|
+
placeholder,
|
|
191
|
+
self._placeholder,
|
|
192
|
+
)
|
|
177
193
|
return self._placeholder
|
|
178
194
|
|
|
179
195
|
def get_conn(self):
|
|
@@ -218,7 +234,7 @@ class DbApiHook(BaseHook):
|
|
|
218
234
|
try:
|
|
219
235
|
from pandas.io import sql as psql
|
|
220
236
|
except ImportError:
|
|
221
|
-
raise
|
|
237
|
+
raise AirflowOptionalProviderFeatureException(
|
|
222
238
|
"pandas library not installed, run: pip install "
|
|
223
239
|
"'apache-airflow-providers-common-sql[pandas]'."
|
|
224
240
|
)
|
|
@@ -245,7 +261,7 @@ class DbApiHook(BaseHook):
|
|
|
245
261
|
try:
|
|
246
262
|
from pandas.io import sql as psql
|
|
247
263
|
except ImportError:
|
|
248
|
-
raise
|
|
264
|
+
raise AirflowOptionalProviderFeatureException(
|
|
249
265
|
"pandas library not installed, run: pip install "
|
|
250
266
|
"'apache-airflow-providers-common-sql[pandas]'."
|
|
251
267
|
)
|
|
@@ -305,8 +321,7 @@ class DbApiHook(BaseHook):
|
|
|
305
321
|
handler: None = ...,
|
|
306
322
|
split_statements: bool = ...,
|
|
307
323
|
return_last: bool = ...,
|
|
308
|
-
) -> None:
|
|
309
|
-
...
|
|
324
|
+
) -> None: ...
|
|
310
325
|
|
|
311
326
|
@overload
|
|
312
327
|
def run(
|
|
@@ -317,8 +332,7 @@ class DbApiHook(BaseHook):
|
|
|
317
332
|
handler: Callable[[Any], T] = ...,
|
|
318
333
|
split_statements: bool = ...,
|
|
319
334
|
return_last: bool = ...,
|
|
320
|
-
) -> tuple | list[tuple] | list[list[tuple] | tuple] | None:
|
|
321
|
-
...
|
|
335
|
+
) -> tuple | list[tuple] | list[list[tuple] | tuple] | None: ...
|
|
322
336
|
|
|
323
337
|
def run(
|
|
324
338
|
self,
|
|
@@ -424,14 +438,6 @@ class DbApiHook(BaseHook):
|
|
|
424
438
|
else:
|
|
425
439
|
return results
|
|
426
440
|
|
|
427
|
-
@deprecated(
|
|
428
|
-
reason=(
|
|
429
|
-
"The `_make_serializable` method is deprecated and support will be removed in a future "
|
|
430
|
-
"version of the common.sql provider. Please update the DbApiHook's provider "
|
|
431
|
-
"to a version based on common.sql >= 1.9.1."
|
|
432
|
-
),
|
|
433
|
-
category=AirflowProviderDeprecationWarning,
|
|
434
|
-
)
|
|
435
441
|
def _make_common_data_structure(self, result: T | Sequence[T]) -> tuple | list[tuple]:
|
|
436
442
|
"""Ensure the data returned from an SQL command is a standard tuple or list[tuple].
|
|
437
443
|
|
|
@@ -446,6 +452,13 @@ class DbApiHook(BaseHook):
|
|
|
446
452
|
# Back-compatibility call for providers implementing old ´_make_serializable' method.
|
|
447
453
|
with contextlib.suppress(AttributeError):
|
|
448
454
|
result = self._make_serializable(result=result) # type: ignore[attr-defined]
|
|
455
|
+
warnings.warn(
|
|
456
|
+
"The `_make_serializable` method is deprecated and support will be removed in a future "
|
|
457
|
+
f"version of the common.sql provider. Please update the {self.__class__.__name__}'s provider "
|
|
458
|
+
"to a version based on common.sql >= 1.9.1.",
|
|
459
|
+
AirflowProviderDeprecationWarning,
|
|
460
|
+
stacklevel=2,
|
|
461
|
+
)
|
|
449
462
|
|
|
450
463
|
if isinstance(result, Sequence):
|
|
451
464
|
return cast(List[tuple], result)
|
|
@@ -220,7 +220,7 @@ class SQLExecuteQueryOperator(BaseSQLOperator):
|
|
|
220
220
|
:ref:`howto/operator:SQLExecuteQueryOperator`
|
|
221
221
|
"""
|
|
222
222
|
|
|
223
|
-
template_fields: Sequence[str] = ("conn_id", "sql", "parameters")
|
|
223
|
+
template_fields: Sequence[str] = ("conn_id", "sql", "parameters", "hook_params")
|
|
224
224
|
template_ext: Sequence[str] = (".sql", ".json")
|
|
225
225
|
template_fields_renderers = {"sql": "sql", "parameters": "json"}
|
|
226
226
|
ui_color = "#cdaaed"
|
|
@@ -416,7 +416,7 @@ class SQLColumnCheckOperator(BaseSQLOperator):
|
|
|
416
416
|
:ref:`howto/operator:SQLColumnCheckOperator`
|
|
417
417
|
"""
|
|
418
418
|
|
|
419
|
-
template_fields: Sequence[str] = ("partition_clause", "table", "sql")
|
|
419
|
+
template_fields: Sequence[str] = ("partition_clause", "table", "sql", "hook_params")
|
|
420
420
|
template_fields_renderers = {"sql": "sql"}
|
|
421
421
|
|
|
422
422
|
sql_check_template = """
|
|
@@ -644,7 +644,7 @@ class SQLTableCheckOperator(BaseSQLOperator):
|
|
|
644
644
|
:ref:`howto/operator:SQLTableCheckOperator`
|
|
645
645
|
"""
|
|
646
646
|
|
|
647
|
-
template_fields: Sequence[str] = ("partition_clause", "table", "sql", "conn_id")
|
|
647
|
+
template_fields: Sequence[str] = ("partition_clause", "table", "sql", "conn_id", "hook_params")
|
|
648
648
|
|
|
649
649
|
template_fields_renderers = {"sql": "sql"}
|
|
650
650
|
|
|
@@ -760,7 +760,7 @@ class SQLCheckOperator(BaseSQLOperator):
|
|
|
760
760
|
:param parameters: (optional) the parameters to render the SQL query with.
|
|
761
761
|
"""
|
|
762
762
|
|
|
763
|
-
template_fields: Sequence[str] = ("sql",)
|
|
763
|
+
template_fields: Sequence[str] = ("sql", "hook_params")
|
|
764
764
|
template_ext: Sequence[str] = (
|
|
765
765
|
".hql",
|
|
766
766
|
".sql",
|
|
@@ -809,6 +809,7 @@ class SQLValueCheckOperator(BaseSQLOperator):
|
|
|
809
809
|
template_fields: Sequence[str] = (
|
|
810
810
|
"sql",
|
|
811
811
|
"pass_value",
|
|
812
|
+
"hook_params",
|
|
812
813
|
)
|
|
813
814
|
template_ext: Sequence[str] = (
|
|
814
815
|
".hql",
|
|
@@ -906,7 +907,7 @@ class SQLIntervalCheckOperator(BaseSQLOperator):
|
|
|
906
907
|
"""
|
|
907
908
|
|
|
908
909
|
__mapper_args__ = {"polymorphic_identity": "SQLIntervalCheckOperator"}
|
|
909
|
-
template_fields: Sequence[str] = ("sql1", "sql2")
|
|
910
|
+
template_fields: Sequence[str] = ("sql1", "sql2", "hook_params")
|
|
910
911
|
template_ext: Sequence[str] = (
|
|
911
912
|
".hql",
|
|
912
913
|
".sql",
|
|
@@ -1034,7 +1035,7 @@ class SQLThresholdCheckOperator(BaseSQLOperator):
|
|
|
1034
1035
|
:param max_threshold: numerical value or max threshold sql to be executed (templated)
|
|
1035
1036
|
"""
|
|
1036
1037
|
|
|
1037
|
-
template_fields: Sequence[str] = ("sql", "min_threshold", "max_threshold")
|
|
1038
|
+
template_fields: Sequence[str] = ("sql", "min_threshold", "max_threshold", "hook_params")
|
|
1038
1039
|
template_ext: Sequence[str] = (
|
|
1039
1040
|
".hql",
|
|
1040
1041
|
".sql",
|
|
@@ -51,7 +51,7 @@ class SqlSensor(BaseSensorOperator):
|
|
|
51
51
|
Should match the desired hook constructor params.
|
|
52
52
|
"""
|
|
53
53
|
|
|
54
|
-
template_fields: Sequence[str] = ("sql",)
|
|
54
|
+
template_fields: Sequence[str] = ("sql", "hook_params")
|
|
55
55
|
template_ext: Sequence[str] = (
|
|
56
56
|
".hql",
|
|
57
57
|
".sql",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: apache-airflow-providers-common-sql
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.12.0rc1
|
|
4
4
|
Summary: Provider package apache-airflow-providers-common-sql for Apache Airflow
|
|
5
5
|
Keywords: airflow-provider,common.sql,airflow,integration
|
|
6
6
|
Author-email: Apache Software Foundation <dev@airflow.apache.org>
|
|
@@ -19,15 +19,16 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
23
|
Classifier: Topic :: System :: Monitoring
|
|
23
|
-
Requires-Dist: apache-airflow>=2.6.
|
|
24
|
+
Requires-Dist: apache-airflow>=2.6.0rc0
|
|
24
25
|
Requires-Dist: more-itertools>=9.0.0
|
|
25
26
|
Requires-Dist: sqlparse>=0.4.2
|
|
26
27
|
Requires-Dist: apache-airflow-providers-openlineage ; extra == "openlineage"
|
|
27
28
|
Requires-Dist: pandas>=1.2.5,<2.2 ; extra == "pandas"
|
|
28
29
|
Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
|
|
29
|
-
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.
|
|
30
|
-
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.
|
|
30
|
+
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0/changelog.html
|
|
31
|
+
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0
|
|
31
32
|
Project-URL: Slack Chat, https://s.apache.org/airflow-slack
|
|
32
33
|
Project-URL: Source Code, https://github.com/apache/airflow
|
|
33
34
|
Project-URL: Twitter, https://twitter.com/ApacheAirflow
|
|
@@ -79,7 +80,7 @@ Provides-Extra: pandas
|
|
|
79
80
|
|
|
80
81
|
Package ``apache-airflow-providers-common-sql``
|
|
81
82
|
|
|
82
|
-
Release: ``1.
|
|
83
|
+
Release: ``1.12.0.rc1``
|
|
83
84
|
|
|
84
85
|
|
|
85
86
|
`Common SQL Provider <https://en.wikipedia.org/wiki/SQL>`__
|
|
@@ -92,7 +93,7 @@ This is a provider package for ``common.sql`` provider. All classes for this pro
|
|
|
92
93
|
are in ``airflow.providers.common.sql`` python package.
|
|
93
94
|
|
|
94
95
|
You can find package information and changelog for the provider
|
|
95
|
-
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.
|
|
96
|
+
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0/>`_.
|
|
96
97
|
|
|
97
98
|
Installation
|
|
98
99
|
------------
|
|
@@ -101,7 +102,7 @@ You can install this package on top of an existing Airflow 2 installation (see `
|
|
|
101
102
|
for the minimum Airflow version supported) via
|
|
102
103
|
``pip install apache-airflow-providers-common-sql``
|
|
103
104
|
|
|
104
|
-
The package supports the following python versions: 3.8,3.9,3.10,3.11
|
|
105
|
+
The package supports the following python versions: 3.8,3.9,3.10,3.11,3.12
|
|
105
106
|
|
|
106
107
|
Requirements
|
|
107
108
|
------------
|
|
@@ -134,4 +135,4 @@ Dependent package
|
|
|
134
135
|
============================================================================================================== ===============
|
|
135
136
|
|
|
136
137
|
The changelog for the provider package can be found in the
|
|
137
|
-
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.
|
|
138
|
+
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0/changelog.html>`_.
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
airflow/providers/common/sql/LICENSE,sha256=ywUBpKZc7Jb96rVt5I3IDbg7dIJAbUSHkuoDcF3jbH4,13569
|
|
2
2
|
airflow/providers/common/sql/README_API.md,sha256=CxhaS8EedZ4dcbLUPC4-GLCMaY3OH96oHxXttUGU06E,5932
|
|
3
|
-
airflow/providers/common/sql/__init__.py,sha256=
|
|
4
|
-
airflow/providers/common/sql/get_provider_info.py,sha256=
|
|
3
|
+
airflow/providers/common/sql/__init__.py,sha256=klMx41vmt09tJSbH0p_K4neG58LhZ-sXr4Y6t9tpYEs,1586
|
|
4
|
+
airflow/providers/common/sql/get_provider_info.py,sha256=H9lLcgafXyHuzteDB8Jl_yjKx2D1GRt2Fyh1ws1jcg0,2974
|
|
5
5
|
airflow/providers/common/sql/doc/adr/0001-record-architecture-decisions.md,sha256=TfANqrzoFto9PMOMza3MitIkXHGLx2kY_BhhF-N0_ow,1675
|
|
6
6
|
airflow/providers/common/sql/doc/adr/0002-return-common-data-structure-from-dbapihook-derived-hooks.md,sha256=ze5w9IVS-HkUwdZvPW8_JaJaVwel7-N6XdEVN4pTuCE,8457
|
|
7
7
|
airflow/providers/common/sql/hooks/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
8
|
-
airflow/providers/common/sql/hooks/sql.py,sha256=
|
|
8
|
+
airflow/providers/common/sql/hooks/sql.py,sha256=aCDIgO1wmWWJjluSBiHc5rBaBBqQHHRlSozPgctEOdY,28425
|
|
9
9
|
airflow/providers/common/sql/hooks/sql.pyi,sha256=dqxjIq0JLrsPiC65wvOntDpXpEzWdEuv80abfqq2yFU,4138
|
|
10
10
|
airflow/providers/common/sql/operators/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
11
|
-
airflow/providers/common/sql/operators/sql.py,sha256=
|
|
11
|
+
airflow/providers/common/sql/operators/sql.py,sha256=C7w4xxXQdrkJCuqQqgUxYqL_pxkXhI65YAKtYMrO5WA,47843
|
|
12
12
|
airflow/providers/common/sql/operators/sql.pyi,sha256=-Wa-4uMtRPvUowYgSDnfH98Joe3Uakzvof4F4G4mgMM,7769
|
|
13
13
|
airflow/providers/common/sql/sensors/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
14
|
-
airflow/providers/common/sql/sensors/sql.py,sha256=
|
|
14
|
+
airflow/providers/common/sql/sensors/sql.py,sha256=t4RiXUZGrr_FgcRo5QV-rIwNgo7qNuyafqP-GzWJuFY,5683
|
|
15
15
|
airflow/providers/common/sql/sensors/sql.pyi,sha256=ZwVia3SUHrW7eB98r3vHYT_jhgkSWHRZqA2srYDHVbc,2295
|
|
16
|
-
apache_airflow_providers_common_sql-1.
|
|
17
|
-
apache_airflow_providers_common_sql-1.
|
|
18
|
-
apache_airflow_providers_common_sql-1.
|
|
19
|
-
apache_airflow_providers_common_sql-1.
|
|
16
|
+
apache_airflow_providers_common_sql-1.12.0rc1.dist-info/entry_points.txt,sha256=h8UXRp2crPuGmYVYRM5oe168qIh7g-4t2QQbVMizKjI,106
|
|
17
|
+
apache_airflow_providers_common_sql-1.12.0rc1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
18
|
+
apache_airflow_providers_common_sql-1.12.0rc1.dist-info/METADATA,sha256=dWCb63rDgZyHzMdykloxRc6SLZuRbBINj1-u-2flqnk,6118
|
|
19
|
+
apache_airflow_providers_common_sql-1.12.0rc1.dist-info/RECORD,,
|
|
File without changes
|