apache-airflow-providers-snowflake 6.3.0rc1__py3-none-any.whl → 6.3.1rc1__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.

Potentially problematic release.


This version of apache-airflow-providers-snowflake might be problematic. Click here for more details.

@@ -29,7 +29,7 @@ from airflow import __version__ as airflow_version
29
29
 
30
30
  __all__ = ["__version__"]
31
31
 
32
- __version__ = "6.3.0"
32
+ __version__ = "6.3.1"
33
33
 
34
34
  if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
35
35
  "2.10.0"
@@ -191,7 +191,7 @@ class SnowflakeHook(DbApiHook):
191
191
 
192
192
  @property
193
193
  def account_identifier(self) -> str:
194
- """Returns snowflake account identifier."""
194
+ """Get snowflake account identifier."""
195
195
  conn_config = self._get_conn_params
196
196
  account_identifier = f"https://{conn_config['account']}"
197
197
 
@@ -205,7 +205,7 @@ class SnowflakeHook(DbApiHook):
205
205
  if conn_config is None:
206
206
  conn_config = self._get_conn_params
207
207
 
208
- url = f"{self.account_identifier}.snowflakecomputing.com/oauth/token-request"
208
+ url = f"https://{conn_config['account']}.snowflakecomputing.com/oauth/token-request"
209
209
 
210
210
  data = {
211
211
  "grant_type": "refresh_token",
@@ -97,6 +97,28 @@ def fix_snowflake_sqlalchemy_uri(uri: str) -> str:
97
97
  return urlunparse((parts.scheme, hostname, parts.path, parts.params, parts.query, parts.fragment))
98
98
 
99
99
 
100
+ def _get_logical_date(task_instance):
101
+ # todo: remove when min airflow version >= 3.0
102
+ if AIRFLOW_V_3_0_PLUS:
103
+ dagrun = task_instance.get_template_context()["dag_run"]
104
+ return dagrun.logical_date or dagrun.run_after
105
+
106
+ if hasattr(task_instance, "logical_date"):
107
+ date = task_instance.logical_date
108
+ else:
109
+ date = task_instance.execution_date
110
+
111
+ return date
112
+
113
+
114
+ def _get_dag_run_clear_number(task_instance):
115
+ # todo: remove when min airflow version >= 3.0
116
+ if AIRFLOW_V_3_0_PLUS:
117
+ dagrun = task_instance.get_template_context()["dag_run"]
118
+ return dagrun.clear_number
119
+ return task_instance.dag_run.clear_number
120
+
121
+
100
122
  # todo: move this run_id logic into OpenLineage's listener to avoid differences
101
123
  def _get_ol_run_id(task_instance) -> str:
102
124
  """
@@ -108,29 +130,27 @@ def _get_ol_run_id(task_instance) -> str:
108
130
  """
109
131
  from airflow.providers.openlineage.plugins.adapter import OpenLineageAdapter
110
132
 
111
- def _get_logical_date():
112
- # todo: remove when min airflow version >= 3.0
113
- if AIRFLOW_V_3_0_PLUS:
114
- dagrun = task_instance.get_template_context()["dag_run"]
115
- return dagrun.logical_date or dagrun.run_after
116
-
117
- if hasattr(task_instance, "logical_date"):
118
- date = task_instance.logical_date
119
- else:
120
- date = task_instance.execution_date
121
-
122
- return date
123
-
124
133
  # Generate same OL run id as is generated for current task instance
125
134
  return OpenLineageAdapter.build_task_instance_run_id(
126
135
  dag_id=task_instance.dag_id,
127
136
  task_id=task_instance.task_id,
128
- logical_date=_get_logical_date(),
137
+ logical_date=_get_logical_date(task_instance),
129
138
  try_number=task_instance.try_number,
130
139
  map_index=task_instance.map_index,
131
140
  )
132
141
 
133
142
 
143
+ # todo: move this run_id logic into OpenLineage's listener to avoid differences
144
+ def _get_ol_dag_run_id(task_instance) -> str:
145
+ from airflow.providers.openlineage.plugins.adapter import OpenLineageAdapter
146
+
147
+ return OpenLineageAdapter.build_dag_run_id(
148
+ dag_id=task_instance.dag_id,
149
+ logical_date=_get_logical_date(task_instance),
150
+ clear_number=_get_dag_run_clear_number(task_instance),
151
+ )
152
+
153
+
134
154
  def _get_parent_run_facet(task_instance):
135
155
  """
136
156
  Retrieve the ParentRunFacet associated with a specific Airflow task instance.
@@ -144,6 +164,7 @@ def _get_parent_run_facet(task_instance):
144
164
  from airflow.providers.openlineage.conf import namespace
145
165
 
146
166
  parent_run_id = _get_ol_run_id(task_instance)
167
+ root_parent_run_id = _get_ol_dag_run_id(task_instance)
147
168
 
148
169
  return parent_run.ParentRunFacet(
149
170
  run=parent_run.Run(runId=parent_run_id),
@@ -151,6 +172,13 @@ def _get_parent_run_facet(task_instance):
151
172
  namespace=namespace(),
152
173
  name=f"{task_instance.dag_id}.{task_instance.task_id}",
153
174
  ),
175
+ root=parent_run.Root(
176
+ run=parent_run.RootRun(runId=root_parent_run_id),
177
+ job=parent_run.RootJob(
178
+ name=task_instance.dag_id,
179
+ namespace=namespace(),
180
+ ),
181
+ ),
154
182
  )
155
183
 
156
184
 
@@ -218,7 +246,7 @@ def _create_snowflake_event_pair(
218
246
  return start, end
219
247
 
220
248
 
221
- @require_openlineage_version(provider_min_version="2.0.0")
249
+ @require_openlineage_version(provider_min_version="2.3.0")
222
250
  def emit_openlineage_events_for_snowflake_queries(
223
251
  query_ids: list[str],
224
252
  query_source_namespace: str,
@@ -252,6 +280,7 @@ def emit_openlineage_events_for_snowflake_queries(
252
280
  from airflow.providers.common.compat.openlineage.facet import (
253
281
  ErrorMessageRunFacet,
254
282
  ExternalQueryRunFacet,
283
+ RunFacet,
255
284
  SQLJobFacet,
256
285
  )
257
286
  from airflow.providers.openlineage.conf import namespace
@@ -273,7 +302,7 @@ def emit_openlineage_events_for_snowflake_queries(
273
302
  # If real metadata is unavailable, we send events with eventTime=now
274
303
  default_event_time = timezone.utcnow()
275
304
  # If no query metadata is provided, we use task_instance's state when checking for success
276
- default_state = str(task_instance.state) if hasattr(task_instance, "state") else ""
305
+ default_state = task_instance.state.value if hasattr(task_instance, "state") else ""
277
306
 
278
307
  common_run_facets = {"parent": _get_parent_run_facet(task_instance)}
279
308
  common_job_facets: dict[str, JobFacet] = {
@@ -296,12 +325,11 @@ def emit_openlineage_events_for_snowflake_queries(
296
325
  query_metadata if query_metadata else "not found",
297
326
  )
298
327
 
299
- # TODO(potiuk): likely typing here needs to be fixed
300
- query_specific_run_facets = { # type : ignore[assignment]
328
+ query_specific_run_facets: dict[str, RunFacet] = {
301
329
  "externalQuery": ExternalQueryRunFacet(externalQueryId=query_id, source=query_source_namespace)
302
330
  }
303
331
  if query_metadata.get("ERROR_MESSAGE"):
304
- query_specific_run_facets["error"] = ErrorMessageRunFacet( # type: ignore[assignment]
332
+ query_specific_run_facets["error"] = ErrorMessageRunFacet(
305
333
  message=f"{query_metadata.get('ERROR_CODE')} : {query_metadata['ERROR_MESSAGE']}",
306
334
  programmingLanguage="SQL",
307
335
  )
@@ -324,9 +352,9 @@ def emit_openlineage_events_for_snowflake_queries(
324
352
  events.extend(event_batch)
325
353
 
326
354
  log.debug("Generated %s OpenLineage events; emitting now.", len(events))
327
- client = get_openlineage_listener().adapter.get_or_create_openlineage_client()
355
+ adapter = get_openlineage_listener().adapter
328
356
  for event in events:
329
- client.emit(event)
357
+ adapter.emit(event)
330
358
 
331
359
  log.info("OpenLineage has successfully finished processing information about Snowflake queries.")
332
360
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apache-airflow-providers-snowflake
3
- Version: 6.3.0rc1
3
+ Version: 6.3.1rc1
4
4
  Summary: Provider package apache-airflow-providers-snowflake for Apache Airflow
5
5
  Keywords: airflow-provider,snowflake,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
@@ -28,10 +28,10 @@ Requires-Dist: pyarrow>=14.0.1
28
28
  Requires-Dist: snowflake-connector-python>=3.7.1
29
29
  Requires-Dist: snowflake-sqlalchemy>=1.4.0
30
30
  Requires-Dist: snowflake-snowpark-python>=1.17.0;python_version<'3.12'
31
- Requires-Dist: apache-airflow-providers-openlineage ; extra == "openlineage"
31
+ Requires-Dist: apache-airflow-providers-openlineage>=2.3.0rc1 ; extra == "openlineage"
32
32
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
33
- Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-snowflake/6.3.0/changelog.html
34
- Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-snowflake/6.3.0
33
+ Project-URL: Changelog, https://airflow.staged.apache.org/docs/apache-airflow-providers-snowflake/6.3.1/changelog.html
34
+ Project-URL: Documentation, https://airflow.staged.apache.org/docs/apache-airflow-providers-snowflake/6.3.1
35
35
  Project-URL: Mastodon, https://fosstodon.org/@airflow
36
36
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
37
37
  Project-URL: Source Code, https://github.com/apache/airflow
@@ -63,7 +63,7 @@ Provides-Extra: openlineage
63
63
 
64
64
  Package ``apache-airflow-providers-snowflake``
65
65
 
66
- Release: ``6.3.0``
66
+ Release: ``6.3.1``
67
67
 
68
68
 
69
69
  `Snowflake <https://www.snowflake.com/>`__
@@ -76,7 +76,7 @@ This is a provider package for ``snowflake`` provider. All classes for this prov
76
76
  are in ``airflow.providers.snowflake`` 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-snowflake/6.3.0/>`_.
79
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-snowflake/6.3.1/>`_.
80
80
 
81
81
  Installation
82
82
  ------------
@@ -125,5 +125,5 @@ Dependent package
125
125
  ================================================================================================================== =================
126
126
 
127
127
  The changelog for the provider package can be found in the
128
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-snowflake/6.3.0/changelog.html>`_.
128
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-snowflake/6.3.1/changelog.html>`_.
129
129
 
@@ -1,11 +1,11 @@
1
1
  airflow/providers/snowflake/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
2
- airflow/providers/snowflake/__init__.py,sha256=bV-absjYLO_SPfvPyRwm7orXAY2ssUaMnwtRxzd8frk,1498
2
+ airflow/providers/snowflake/__init__.py,sha256=QsK4vg_MkprBynxoW0TPaDLqVXgU_0-k0VW6Zabo7gk,1498
3
3
  airflow/providers/snowflake/get_provider_info.py,sha256=NdNRMfulBbpD-I4yFRr8U533m9djD18ijEMvuxOp4_g,3875
4
4
  airflow/providers/snowflake/version_compat.py,sha256=j5PCtXvZ71aBjixu-EFTNtVDPsngzzs7os0ZQDgFVDk,1536
5
5
  airflow/providers/snowflake/decorators/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
6
6
  airflow/providers/snowflake/decorators/snowpark.py,sha256=tKXOjP8m8SEIu0jx2KSrd0n3jGMaIKDOwG2lMkvk3cI,5523
7
7
  airflow/providers/snowflake/hooks/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
8
- airflow/providers/snowflake/hooks/snowflake.py,sha256=2dlbnxu-0h1BrlNgdHyXQ69PVeutxijeBUBPNwF8dEg,28022
8
+ airflow/providers/snowflake/hooks/snowflake.py,sha256=9OH16CYnnJ0-ayAg1D7OdZusEf5lSGjQurWifptp97k,28025
9
9
  airflow/providers/snowflake/hooks/snowflake_sql_api.py,sha256=-J0mPcdDc9wbB7DcnZfnXJN7H62nbR_NK5WQJxeKZjE,14532
10
10
  airflow/providers/snowflake/operators/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
11
11
  airflow/providers/snowflake/operators/snowflake.py,sha256=5MisB-bKqUFM9t5Ky913UqewoHlq3k3mCv4bnc-VY7g,22657
@@ -16,10 +16,10 @@ airflow/providers/snowflake/triggers/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOF
16
16
  airflow/providers/snowflake/triggers/snowflake_trigger.py,sha256=38tkByMyjbVbSt-69YL8EzRBQT4rhwuOKHgbwHfULL0,4250
17
17
  airflow/providers/snowflake/utils/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
18
18
  airflow/providers/snowflake/utils/common.py,sha256=DG-KLy2KpZWAqZqm_XIECm8lmdoUlzwkXv9onmkQThc,1644
19
- airflow/providers/snowflake/utils/openlineage.py,sha256=joZ0ENJXF6I-BQ5EnVeaAYvz2C1Jtp_4pkPvYeJZheI,13510
19
+ airflow/providers/snowflake/utils/openlineage.py,sha256=QjbN76qjboTvpQZtoi0g7s3R9LwutRtD7HZ3DEVLbyY,14372
20
20
  airflow/providers/snowflake/utils/snowpark.py,sha256=9kzWRkdgoNQ8f3Wnr92LdZylMpcpRasxefpOXrM30Cw,1602
21
21
  airflow/providers/snowflake/utils/sql_api_generate_jwt.py,sha256=9mR-vHIquv60tfAni87f6FAjKsiRHUDDrsVhzw4M9vM,6762
22
- apache_airflow_providers_snowflake-6.3.0rc1.dist-info/entry_points.txt,sha256=bCrl5J1PXUMzbgnrKYho61rkbL2gHRT4I6f_1jlxAX4,105
23
- apache_airflow_providers_snowflake-6.3.0rc1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
24
- apache_airflow_providers_snowflake-6.3.0rc1.dist-info/METADATA,sha256=7KYZ4V22kQjTg3Mtds9fRGXEq9J-SCPzyg_HjJRYUzs,6218
25
- apache_airflow_providers_snowflake-6.3.0rc1.dist-info/RECORD,,
22
+ apache_airflow_providers_snowflake-6.3.1rc1.dist-info/entry_points.txt,sha256=bCrl5J1PXUMzbgnrKYho61rkbL2gHRT4I6f_1jlxAX4,105
23
+ apache_airflow_providers_snowflake-6.3.1rc1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
24
+ apache_airflow_providers_snowflake-6.3.1rc1.dist-info/METADATA,sha256=0pkDl6pLL8SvxNML46vEzwwQ1IP7TzRKYlbJ2MtTkzI,6242
25
+ apache_airflow_providers_snowflake-6.3.1rc1.dist-info/RECORD,,