apache-airflow-providers-common-sql 1.26.0rc1__py3-none-any.whl → 1.27.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 +3 -3
- airflow/providers/common/sql/hooks/sql.py +21 -7
- airflow/providers/common/sql/hooks/sql.pyi +62 -5
- airflow/providers/common/sql/operators/sql.py +5 -0
- {apache_airflow_providers_common_sql-1.26.0rc1.dist-info → apache_airflow_providers_common_sql-1.27.0rc1.dist-info}/METADATA +8 -8
- {apache_airflow_providers_common_sql-1.26.0rc1.dist-info → apache_airflow_providers_common_sql-1.27.0rc1.dist-info}/RECORD +8 -8
- {apache_airflow_providers_common_sql-1.26.0rc1.dist-info → apache_airflow_providers_common_sql-1.27.0rc1.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_common_sql-1.26.0rc1.dist-info → apache_airflow_providers_common_sql-1.27.0rc1.dist-info}/entry_points.txt +0 -0
|
@@ -29,11 +29,11 @@ from airflow import __version__ as airflow_version
|
|
|
29
29
|
|
|
30
30
|
__all__ = ["__version__"]
|
|
31
31
|
|
|
32
|
-
__version__ = "1.
|
|
32
|
+
__version__ = "1.27.0"
|
|
33
33
|
|
|
34
34
|
if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
|
|
35
|
-
"2.
|
|
35
|
+
"2.10.0"
|
|
36
36
|
):
|
|
37
37
|
raise RuntimeError(
|
|
38
|
-
f"The package `apache-airflow-providers-common-sql:{__version__}` needs Apache Airflow 2.
|
|
38
|
+
f"The package `apache-airflow-providers-common-sql:{__version__}` needs Apache Airflow 2.10.0+"
|
|
39
39
|
)
|
|
@@ -37,8 +37,8 @@ import sqlparse
|
|
|
37
37
|
from deprecated import deprecated
|
|
38
38
|
from methodtools import lru_cache
|
|
39
39
|
from more_itertools import chunked
|
|
40
|
-
from sqlalchemy import create_engine
|
|
41
|
-
from sqlalchemy.engine import
|
|
40
|
+
from sqlalchemy import create_engine, inspect
|
|
41
|
+
from sqlalchemy.engine import make_url
|
|
42
42
|
from sqlalchemy.exc import ArgumentError, NoSuchModuleError
|
|
43
43
|
from typing_extensions import Literal
|
|
44
44
|
|
|
@@ -56,7 +56,7 @@ from airflow.utils.module_loading import import_string
|
|
|
56
56
|
if TYPE_CHECKING:
|
|
57
57
|
from pandas import DataFrame
|
|
58
58
|
from polars import DataFrame as PolarsDataFrame
|
|
59
|
-
from sqlalchemy.engine import URL
|
|
59
|
+
from sqlalchemy.engine import URL, Engine, Inspector
|
|
60
60
|
|
|
61
61
|
from airflow.models import Connection
|
|
62
62
|
from airflow.providers.openlineage.extractors import OperatorLineage
|
|
@@ -307,7 +307,7 @@ class DbApiHook(BaseHook):
|
|
|
307
307
|
msg = "`sqlalchemy_url` property should be implemented in the provider subclass."
|
|
308
308
|
raise NotImplementedError(msg)
|
|
309
309
|
|
|
310
|
-
def get_sqlalchemy_engine(self, engine_kwargs=None):
|
|
310
|
+
def get_sqlalchemy_engine(self, engine_kwargs=None) -> Engine:
|
|
311
311
|
"""
|
|
312
312
|
Get an sqlalchemy_engine object.
|
|
313
313
|
|
|
@@ -328,7 +328,7 @@ class DbApiHook(BaseHook):
|
|
|
328
328
|
|
|
329
329
|
@property
|
|
330
330
|
def inspector(self) -> Inspector:
|
|
331
|
-
return
|
|
331
|
+
return inspect(self.get_sqlalchemy_engine())
|
|
332
332
|
|
|
333
333
|
@cached_property
|
|
334
334
|
def dialect_name(self) -> str:
|
|
@@ -890,7 +890,14 @@ class DbApiHook(BaseHook):
|
|
|
890
890
|
)
|
|
891
891
|
sql = self._generate_insert_sql(table, values[0], target_fields, replace, **kwargs)
|
|
892
892
|
self.log.debug("Generated sql: %s", sql)
|
|
893
|
-
|
|
893
|
+
|
|
894
|
+
try:
|
|
895
|
+
cur.executemany(sql, values)
|
|
896
|
+
except Exception as e:
|
|
897
|
+
self.log.error("Generated sql: %s", sql)
|
|
898
|
+
self.log.error("Parameters: %s", values)
|
|
899
|
+
raise e
|
|
900
|
+
|
|
894
901
|
conn.commit()
|
|
895
902
|
nb_rows += len(chunked_rows)
|
|
896
903
|
self.log.info("Loaded %s rows into %s so far", nb_rows, table)
|
|
@@ -899,7 +906,14 @@ class DbApiHook(BaseHook):
|
|
|
899
906
|
values = self._serialize_cells(row, conn)
|
|
900
907
|
sql = self._generate_insert_sql(table, values, target_fields, replace, **kwargs)
|
|
901
908
|
self.log.debug("Generated sql: %s", sql)
|
|
902
|
-
|
|
909
|
+
|
|
910
|
+
try:
|
|
911
|
+
cur.execute(sql, values)
|
|
912
|
+
except Exception as e:
|
|
913
|
+
self.log.error("Generated sql: %s", sql)
|
|
914
|
+
self.log.error("Parameters: %s", values)
|
|
915
|
+
raise e
|
|
916
|
+
|
|
903
917
|
if commit_every and i % commit_every == 0:
|
|
904
918
|
conn.commit()
|
|
905
919
|
self.log.info("Loaded %s rows into %s so far", i, table)
|
|
@@ -37,8 +37,10 @@ from functools import cached_property as cached_property
|
|
|
37
37
|
from typing import Any, Callable, Protocol, TypeVar, overload
|
|
38
38
|
|
|
39
39
|
from _typeshed import Incomplete as Incomplete
|
|
40
|
-
from pandas import DataFrame as
|
|
41
|
-
from
|
|
40
|
+
from pandas import DataFrame as PandasDataFrame
|
|
41
|
+
from polars import DataFrame as PolarsDataFrame
|
|
42
|
+
from sqlalchemy.engine import URL as URL, Engine as Engine, Inspector as Inspector
|
|
43
|
+
from typing_extensions import Literal
|
|
42
44
|
|
|
43
45
|
from airflow.hooks.base import BaseHook as BaseHook
|
|
44
46
|
from airflow.models import Connection as Connection
|
|
@@ -93,7 +95,7 @@ class DbApiHook(BaseHook):
|
|
|
93
95
|
def get_uri(self) -> str: ...
|
|
94
96
|
@property
|
|
95
97
|
def sqlalchemy_url(self) -> URL: ...
|
|
96
|
-
def get_sqlalchemy_engine(self, engine_kwargs: Incomplete | None = None): ...
|
|
98
|
+
def get_sqlalchemy_engine(self, engine_kwargs: Incomplete | None = None) -> Engine: ...
|
|
97
99
|
@property
|
|
98
100
|
def inspector(self) -> Inspector: ...
|
|
99
101
|
@cached_property
|
|
@@ -105,10 +107,65 @@ class DbApiHook(BaseHook):
|
|
|
105
107
|
def get_reserved_words(self, dialect_name: str) -> set[str]: ...
|
|
106
108
|
def get_pandas_df(
|
|
107
109
|
self, sql, parameters: list | tuple | Mapping[str, Any] | None = None, **kwargs
|
|
108
|
-
) ->
|
|
110
|
+
) -> PandasDataFrame: ...
|
|
109
111
|
def get_pandas_df_by_chunks(
|
|
110
112
|
self, sql, parameters: list | tuple | Mapping[str, Any] | None = None, *, chunksize: int, **kwargs
|
|
111
|
-
) -> Generator[
|
|
113
|
+
) -> Generator[PandasDataFrame, None, None]: ...
|
|
114
|
+
@overload
|
|
115
|
+
def get_df(
|
|
116
|
+
self,
|
|
117
|
+
sql: str | list[str],
|
|
118
|
+
parameters: list | tuple | Mapping[str, Any] | None = None,
|
|
119
|
+
*,
|
|
120
|
+
df_type: Literal["pandas"] = "pandas",
|
|
121
|
+
**kwargs: Any,
|
|
122
|
+
) -> PandasDataFrame: ...
|
|
123
|
+
@overload
|
|
124
|
+
def get_df(
|
|
125
|
+
self,
|
|
126
|
+
sql: str | list[str],
|
|
127
|
+
parameters: list | tuple | Mapping[str, Any] | None = None,
|
|
128
|
+
*,
|
|
129
|
+
df_type: Literal["polars"] = "polars",
|
|
130
|
+
**kwargs: Any,
|
|
131
|
+
) -> PolarsDataFrame: ...
|
|
132
|
+
@overload
|
|
133
|
+
def get_df( # fallback overload
|
|
134
|
+
self,
|
|
135
|
+
sql: str | list[str],
|
|
136
|
+
parameters: list | tuple | Mapping[str, Any] | None = None,
|
|
137
|
+
*,
|
|
138
|
+
df_type: Literal["pandas", "polars"] = "pandas",
|
|
139
|
+
) -> PandasDataFrame | PolarsDataFrame: ...
|
|
140
|
+
@overload
|
|
141
|
+
def get_df_by_chunks(
|
|
142
|
+
self,
|
|
143
|
+
sql,
|
|
144
|
+
parameters: list | tuple | Mapping[str, Any] | None = None,
|
|
145
|
+
*,
|
|
146
|
+
chunksize: int,
|
|
147
|
+
df_type: Literal["pandas"] = "pandas",
|
|
148
|
+
**kwargs,
|
|
149
|
+
) -> Generator[PandasDataFrame, None, None]: ...
|
|
150
|
+
@overload
|
|
151
|
+
def get_df_by_chunks(
|
|
152
|
+
self,
|
|
153
|
+
sql,
|
|
154
|
+
parameters: list | tuple | Mapping[str, Any] | None = None,
|
|
155
|
+
*,
|
|
156
|
+
chunksize: int,
|
|
157
|
+
df_type: Literal["polars"],
|
|
158
|
+
**kwargs,
|
|
159
|
+
) -> Generator[PolarsDataFrame, None, None]: ...
|
|
160
|
+
@overload
|
|
161
|
+
def get_df_by_chunks( # fallback overload
|
|
162
|
+
self,
|
|
163
|
+
sql,
|
|
164
|
+
parameters: list | tuple | Mapping[str, Any] | None = None,
|
|
165
|
+
*,
|
|
166
|
+
chunksize: int,
|
|
167
|
+
df_type: Literal["pandas", "polars"] = "pandas",
|
|
168
|
+
) -> Generator[PandasDataFrame | PolarsDataFrame, None, None]: ...
|
|
112
169
|
def get_records(
|
|
113
170
|
self, sql: str | list[str], parameters: Iterable | Mapping[str, Any] | None = None
|
|
114
171
|
) -> Any: ...
|
|
@@ -161,7 +161,12 @@ class BaseSQLOperator(BaseOperator):
|
|
|
161
161
|
:param hook_params: hook parameters
|
|
162
162
|
:return: default hook for this connection
|
|
163
163
|
"""
|
|
164
|
+
hook_params = hook_params or {}
|
|
164
165
|
connection = BaseHook.get_connection(conn_id)
|
|
166
|
+
conn_params = connection.extra_dejson
|
|
167
|
+
for conn_param in conn_params:
|
|
168
|
+
if conn_param not in hook_params:
|
|
169
|
+
hook_params[conn_param] = conn_params[conn_param]
|
|
165
170
|
return connection.get_hook(hook_params=hook_params)
|
|
166
171
|
|
|
167
172
|
@cached_property
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apache-airflow-providers-common-sql
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.27.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>
|
|
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.12
|
|
22
22
|
Classifier: Topic :: System :: Monitoring
|
|
23
|
-
Requires-Dist: apache-airflow>=2.
|
|
23
|
+
Requires-Dist: apache-airflow>=2.10.0rc1
|
|
24
24
|
Requires-Dist: sqlparse>=0.5.1
|
|
25
25
|
Requires-Dist: more-itertools>=9.0.0
|
|
26
26
|
Requires-Dist: methodtools>=0.4.7
|
|
@@ -28,8 +28,8 @@ Requires-Dist: apache-airflow-providers-openlineage ; extra == "openlineage"
|
|
|
28
28
|
Requires-Dist: pandas>=2.1.2,<2.2 ; extra == "pandas"
|
|
29
29
|
Requires-Dist: polars>=1.26.0 ; extra == "polars"
|
|
30
30
|
Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
|
|
31
|
-
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.
|
|
32
|
-
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.
|
|
31
|
+
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.27.0/changelog.html
|
|
32
|
+
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.27.0
|
|
33
33
|
Project-URL: Mastodon, https://fosstodon.org/@airflow
|
|
34
34
|
Project-URL: Slack Chat, https://s.apache.org/airflow-slack
|
|
35
35
|
Project-URL: Source Code, https://github.com/apache/airflow
|
|
@@ -63,7 +63,7 @@ Provides-Extra: polars
|
|
|
63
63
|
|
|
64
64
|
Package ``apache-airflow-providers-common-sql``
|
|
65
65
|
|
|
66
|
-
Release: ``1.
|
|
66
|
+
Release: ``1.27.0``
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
`Common SQL Provider <https://en.wikipedia.org/wiki/SQL>`__
|
|
@@ -76,7 +76,7 @@ This is a provider package for ``common.sql`` provider. All classes for this pro
|
|
|
76
76
|
are in ``airflow.providers.common.sql`` python package.
|
|
77
77
|
|
|
78
78
|
You can find package information and changelog for the provider
|
|
79
|
-
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.
|
|
79
|
+
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.27.0/>`_.
|
|
80
80
|
|
|
81
81
|
Installation
|
|
82
82
|
------------
|
|
@@ -93,7 +93,7 @@ Requirements
|
|
|
93
93
|
================== ==================
|
|
94
94
|
PIP package Version required
|
|
95
95
|
================== ==================
|
|
96
|
-
``apache-airflow`` ``>=2.
|
|
96
|
+
``apache-airflow`` ``>=2.10.0``
|
|
97
97
|
``sqlparse`` ``>=0.5.1``
|
|
98
98
|
``more-itertools`` ``>=9.0.0``
|
|
99
99
|
``methodtools`` ``>=0.4.7``
|
|
@@ -119,5 +119,5 @@ Dependent package
|
|
|
119
119
|
============================================================================================================== ===============
|
|
120
120
|
|
|
121
121
|
The changelog for the provider package can be found in the
|
|
122
|
-
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.
|
|
122
|
+
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.27.0/changelog.html>`_.
|
|
123
123
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
airflow/providers/common/sql/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
|
|
2
2
|
airflow/providers/common/sql/README_API.md,sha256=CxhaS8EedZ4dcbLUPC4-GLCMaY3OH96oHxXttUGU06E,5932
|
|
3
|
-
airflow/providers/common/sql/__init__.py,sha256=
|
|
3
|
+
airflow/providers/common/sql/__init__.py,sha256=1fjlO-pK_nT17oF_-bhTA0xjWEMvmFYDYrXVDAfJy4M,1500
|
|
4
4
|
airflow/providers/common/sql/get_provider_info.py,sha256=xCPXLKFA_1ilhGa0aB3E9ggdHtn9Do7Eb469begpZag,2767
|
|
5
5
|
airflow/providers/common/sql/get_provider_info.pyi,sha256=0mydJPGQScnPpoa9-ohHVJFngFH6Lsk22KS243PE-gw,1596
|
|
6
6
|
airflow/providers/common/sql/dialects/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
@@ -12,19 +12,19 @@ airflow/providers/common/sql/doc/adr/0003-introduce-notion-of-dialects-in-dbapih
|
|
|
12
12
|
airflow/providers/common/sql/hooks/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
13
13
|
airflow/providers/common/sql/hooks/handlers.py,sha256=XjvycIQsGpDrtg6RFACczybW_dER97RR6Z6B_S6jf6Y,3399
|
|
14
14
|
airflow/providers/common/sql/hooks/handlers.pyi,sha256=3UDOBxvFi5dLzRlF2yCwlj8LuYgDFSKNLmCHhF_Qfik,1827
|
|
15
|
-
airflow/providers/common/sql/hooks/sql.py,sha256=
|
|
16
|
-
airflow/providers/common/sql/hooks/sql.pyi,sha256=
|
|
15
|
+
airflow/providers/common/sql/hooks/sql.py,sha256=1zgwVrP93mtwRGa4SmgMcj1Vhq82YSGfEkYT-2zD9ZA,42358
|
|
16
|
+
airflow/providers/common/sql/hooks/sql.pyi,sha256=cQWV2jQ6IEnOp3Ajbg220AbXu2gn5aPQa5F77Wilg30,8565
|
|
17
17
|
airflow/providers/common/sql/operators/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
18
18
|
airflow/providers/common/sql/operators/generic_transfer.py,sha256=EEKKMcOOLl0vyjXRHBI6UuoFLqpHpeHEj9zwMTrNAA4,8336
|
|
19
19
|
airflow/providers/common/sql/operators/generic_transfer.pyi,sha256=rhuCB7KSm_NutW8m3BNQmaoiUPDXp1fTrSeoR0Jr4dU,3330
|
|
20
|
-
airflow/providers/common/sql/operators/sql.py,sha256=
|
|
20
|
+
airflow/providers/common/sql/operators/sql.py,sha256=DZNljvIwDgSwUpmCWZoe1O8xulY8BURCzvP78t9q--I,50157
|
|
21
21
|
airflow/providers/common/sql/sensors/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
22
22
|
airflow/providers/common/sql/sensors/sql.py,sha256=iYcE8vxLbya8GncOydjceAhu43uoGsN7wqjeYFQ-cak,5471
|
|
23
23
|
airflow/providers/common/sql/sensors/sql.pyi,sha256=GiOk2qD0PO5HWISgTTdOJQLC9b2ItzvQr68adXIbjGQ,2530
|
|
24
24
|
airflow/providers/common/sql/triggers/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
25
25
|
airflow/providers/common/sql/triggers/sql.py,sha256=C6BEhJdypE_hrvrWU_jxJuOi5FbpQG4xJ0EYPn_fqR0,3665
|
|
26
26
|
airflow/providers/common/sql/triggers/sql.pyi,sha256=7wVgfqUPJB7egsWwbZtwZV3TFm7DuKLclWetNInCM5w,1986
|
|
27
|
-
apache_airflow_providers_common_sql-1.
|
|
28
|
-
apache_airflow_providers_common_sql-1.
|
|
29
|
-
apache_airflow_providers_common_sql-1.
|
|
30
|
-
apache_airflow_providers_common_sql-1.
|
|
27
|
+
apache_airflow_providers_common_sql-1.27.0rc1.dist-info/entry_points.txt,sha256=h8UXRp2crPuGmYVYRM5oe168qIh7g-4t2QQbVMizKjI,106
|
|
28
|
+
apache_airflow_providers_common_sql-1.27.0rc1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
29
|
+
apache_airflow_providers_common_sql-1.27.0rc1.dist-info/METADATA,sha256=jrfkGHOgkIXYbAiIF41X4s9qmxzIg-qJzzimugZDa9s,5352
|
|
30
|
+
apache_airflow_providers_common_sql-1.27.0rc1.dist-info/RECORD,,
|
|
File without changes
|