apache-airflow-providers-common-sql 1.11.1rc1__tar.gz → 1.12.0rc1__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 (18) hide show
  1. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/PKG-INFO +9 -8
  2. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/README.rst +4 -4
  3. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/__init__.py +1 -1
  4. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/get_provider_info.py +2 -1
  5. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/hooks/sql.py +31 -18
  6. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/operators/sql.py +7 -6
  7. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/sensors/sql.py +1 -1
  8. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/pyproject.toml +5 -4
  9. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/LICENSE +0 -0
  10. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/README_API.md +0 -0
  11. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/doc/adr/0001-record-architecture-decisions.md +0 -0
  12. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/doc/adr/0002-return-common-data-structure-from-dbapihook-derived-hooks.md +0 -0
  13. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/hooks/__init__.py +0 -0
  14. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/hooks/sql.pyi +0 -0
  15. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/operators/__init__.py +0 -0
  16. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/operators/sql.pyi +0 -0
  17. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/sensors/__init__.py +0 -0
  18. {apache_airflow_providers_common_sql-1.11.1rc1 → apache_airflow_providers_common_sql-1.12.0rc1}/airflow/providers/common/sql/sensors/sql.pyi +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: apache-airflow-providers-common-sql
3
- Version: 1.11.1rc1
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.0.dev0
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.11.1/changelog.html
30
- Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.11.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.11.1.rc1``
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.11.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.11.1/changelog.html>`_.
138
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0/changelog.html>`_.
@@ -42,7 +42,7 @@
42
42
 
43
43
  Package ``apache-airflow-providers-common-sql``
44
44
 
45
- Release: ``1.11.1.rc1``
45
+ Release: ``1.12.0.rc1``
46
46
 
47
47
 
48
48
  `Common SQL Provider <https://en.wikipedia.org/wiki/SQL>`__
@@ -55,7 +55,7 @@ This is a provider package for ``common.sql`` provider. All classes for this pro
55
55
  are in ``airflow.providers.common.sql`` python package.
56
56
 
57
57
  You can find package information and changelog for the provider
58
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.11.1/>`_.
58
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0/>`_.
59
59
 
60
60
  Installation
61
61
  ------------
@@ -64,7 +64,7 @@ You can install this package on top of an existing Airflow 2 installation (see `
64
64
  for the minimum Airflow version supported) via
65
65
  ``pip install apache-airflow-providers-common-sql``
66
66
 
67
- The package supports the following python versions: 3.8,3.9,3.10,3.11
67
+ The package supports the following python versions: 3.8,3.9,3.10,3.11,3.12
68
68
 
69
69
  Requirements
70
70
  ------------
@@ -97,4 +97,4 @@ Dependent package
97
97
  ============================================================================================================== ===============
98
98
 
99
99
  The changelog for the provider package can be found in the
100
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.11.1/changelog.html>`_.
100
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0/changelog.html>`_.
@@ -27,7 +27,7 @@ import packaging.version
27
27
 
28
28
  __all__ = ["__version__"]
29
29
 
30
- __version__ = "1.11.1"
30
+ __version__ = "1.12.0"
31
31
 
32
32
  try:
33
33
  from airflow import __version__ as airflow_version
@@ -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": 1709555283,
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 AirflowException, AirflowProviderDeprecationWarning
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) -> str:
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 Exception(
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 Exception(
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",
@@ -28,7 +28,7 @@ build-backend = "flit_core.buildapi"
28
28
 
29
29
  [project]
30
30
  name = "apache-airflow-providers-common-sql"
31
- version = "1.11.1.rc1"
31
+ version = "1.12.0.rc1"
32
32
  description = "Provider package apache-airflow-providers-common-sql for Apache Airflow"
33
33
  readme = "README.rst"
34
34
  authors = [
@@ -51,18 +51,19 @@ classifiers = [
51
51
  "Programming Language :: Python :: 3.9",
52
52
  "Programming Language :: Python :: 3.10",
53
53
  "Programming Language :: Python :: 3.11",
54
+ "Programming Language :: Python :: 3.12",
54
55
  "Topic :: System :: Monitoring",
55
56
  ]
56
57
  requires-python = "~=3.8"
57
58
  dependencies = [
58
- "apache-airflow>=2.6.0.dev0",
59
+ "apache-airflow>=2.6.0rc0",
59
60
  "more-itertools>=9.0.0",
60
61
  "sqlparse>=0.4.2",
61
62
  ]
62
63
 
63
64
  [project.urls]
64
- "Documentation" = "https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.11.1"
65
- "Changelog" = "https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.11.1/changelog.html"
65
+ "Documentation" = "https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0"
66
+ "Changelog" = "https://airflow.apache.org/docs/apache-airflow-providers-common-sql/1.12.0/changelog.html"
66
67
  "Bug Tracker" = "https://github.com/apache/airflow/issues"
67
68
  "Source Code" = "https://github.com/apache/airflow"
68
69
  "Slack Chat" = "https://s.apache.org/airflow-slack"