apache-airflow-providers-snowflake 6.3.0rc1__tar.gz → 6.3.0rc2__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.
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/PKG-INFO +2 -2
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/changelog.rst +6 -1
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/provider.yaml +4 -1
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/pyproject.toml +2 -2
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/hooks/snowflake.py +2 -2
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/utils/openlineage.py +43 -15
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/hooks/test_snowflake.py +2 -2
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/hooks/test_snowflake_sql_api.py +1 -1
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/utils/test_openlineage.py +25 -7
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/README.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/.latest-doc-only-change.txt +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/commits.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/conf.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/connections/snowflake.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/decorators/index.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/decorators/snowpark.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/index.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/installing-providers-from-sources.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/integration-logos/Snowflake.png +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/operators/copy_into_snowflake.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/operators/index.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/operators/snowflake.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/operators/snowpark.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/docs/security.rst +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/LICENSE +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/decorators/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/decorators/snowpark.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/get_provider_info.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/hooks/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/hooks/snowflake_sql_api.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/operators/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/operators/snowflake.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/operators/snowpark.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/transfers/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/transfers/copy_into_snowflake.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/triggers/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/triggers/snowflake_trigger.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/utils/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/utils/common.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/utils/snowpark.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/utils/sql_api_generate_jwt.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/src/airflow/providers/snowflake/version_compat.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/conftest.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/system/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/system/snowflake/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/system/snowflake/example_copy_into_snowflake.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/system/snowflake/example_snowflake.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/system/snowflake/example_snowflake_snowflake_op_template_file.sql +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/system/snowflake/example_snowpark_decorator.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/system/snowflake/example_snowpark_operator.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/decorators/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/decorators/test_snowpark.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/hooks/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/hooks/test_sql.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/operators/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/operators/test_snowflake.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/operators/test_snowflake_sql.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/operators/test_snowpark.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/transfers/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/transfers/test_copy_into_snowflake.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/triggers/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/triggers/test_snowflake.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/utils/__init__.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/utils/test_common.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/utils/test_snowpark.py +0 -0
- {apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/tests/unit/snowflake/utils/test_sql_api_generate_jwt.py +0 -0
{apache_airflow_providers_snowflake-6.3.0rc1 → apache_airflow_providers_snowflake-6.3.0rc2}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apache-airflow-providers-snowflake
|
|
3
|
-
Version: 6.3.
|
|
3
|
+
Version: 6.3.0rc2
|
|
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,7 +28,7 @@ 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
33
|
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-snowflake/6.3.0/changelog.html
|
|
34
34
|
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-snowflake/6.3.0
|
|
@@ -53,9 +53,11 @@ Features
|
|
|
53
53
|
Bug Fixes
|
|
54
54
|
~~~~~~~~~
|
|
55
55
|
|
|
56
|
-
* ``Fix SnowflakeSqlApiHook backwards compatibility for get_oauth_token method (#49482)``
|
|
57
56
|
* ``make 'private_key_content' in snowflake connection to be a base64 encoded string (#49467)``
|
|
57
|
+
* ``Fix SnowflakeSqlApiHook backwards compatibility for get_oauth_token method (#49482)``
|
|
58
58
|
* ``Fix mypy for get_oauth_token signature in SnowflakeSqlApiHook (#49449)``
|
|
59
|
+
* ``Fix infinite recursive call of _get_conn_params while getting oauth token from snowflake (#50344)``
|
|
60
|
+
* ``Fix: adjust dag_run extraction for Airflow 3 in OL utils (#50346)``
|
|
59
61
|
|
|
60
62
|
Misc
|
|
61
63
|
~~~~
|
|
@@ -64,10 +66,13 @@ Misc
|
|
|
64
66
|
* ``Bump min Airflow version in providers to 2.10 (#49843)``
|
|
65
67
|
* ``enhance: logs SQL before execution in 'snowflake' and 'databricks_sql' (#48942)``
|
|
66
68
|
* ``chore: import paths use the stable functions (#49460)``
|
|
69
|
+
* ``add root parent information to OpenLineage events (#49237)``
|
|
67
70
|
|
|
68
71
|
.. Below changes are excluded from the changelog. Move them to
|
|
69
72
|
appropriate section above if needed. Do not delete the lines(!):
|
|
70
73
|
* ``Avoid committing history for providers (#49907)``
|
|
74
|
+
* ``Update description of provider.yaml dependencies (#50231)``
|
|
75
|
+
* ``Prepare ad hoc release for providers May 2025 (#50166)``
|
|
71
76
|
|
|
72
77
|
6.2.2
|
|
73
78
|
.....
|
|
@@ -23,7 +23,10 @@ description: |
|
|
|
23
23
|
|
|
24
24
|
state: ready
|
|
25
25
|
source-date-epoch: 1746344752
|
|
26
|
-
#
|
|
26
|
+
# Note that those versions are maintained by release manager - do not update them manually
|
|
27
|
+
# with the exception of case where other provider in sources has >= new provider version.
|
|
28
|
+
# In such case adding >= NEW_VERSION and bumping to NEW_VERSION in a provider have
|
|
29
|
+
# to be done in the same PR
|
|
27
30
|
versions:
|
|
28
31
|
- 6.3.0
|
|
29
32
|
- 6.2.2
|
|
@@ -25,7 +25,7 @@ build-backend = "flit_core.buildapi"
|
|
|
25
25
|
|
|
26
26
|
[project]
|
|
27
27
|
name = "apache-airflow-providers-snowflake"
|
|
28
|
-
version = "6.3.
|
|
28
|
+
version = "6.3.0rc2"
|
|
29
29
|
description = "Provider package apache-airflow-providers-snowflake for Apache Airflow"
|
|
30
30
|
readme = "README.rst"
|
|
31
31
|
authors = [
|
|
@@ -75,7 +75,7 @@ dependencies = [
|
|
|
75
75
|
# Any change in the dependencies is preserved when the file is regenerated
|
|
76
76
|
[project.optional-dependencies]
|
|
77
77
|
"openlineage" = [
|
|
78
|
-
"apache-airflow-providers-openlineage"
|
|
78
|
+
"apache-airflow-providers-openlineage>=2.3.0rc1"
|
|
79
79
|
]
|
|
80
80
|
|
|
81
81
|
[dependency-groups]
|
|
@@ -191,7 +191,7 @@ class SnowflakeHook(DbApiHook):
|
|
|
191
191
|
|
|
192
192
|
@property
|
|
193
193
|
def account_identifier(self) -> str:
|
|
194
|
-
"""
|
|
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"{
|
|
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.
|
|
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,
|
|
@@ -860,7 +860,7 @@ class TestPytestSnowflakeHook:
|
|
|
860
860
|
hook.get_openlineage_database_info = lambda x: mock.MagicMock(authority="auth", scheme="scheme")
|
|
861
861
|
|
|
862
862
|
expected_err = (
|
|
863
|
-
"OpenLineage provider version `1.99.0` is lower than required `2.
|
|
863
|
+
"OpenLineage provider version `1.99.0` is lower than required `2.3.0`, "
|
|
864
864
|
"skipping function `emit_openlineage_events_for_snowflake_queries` execution"
|
|
865
865
|
)
|
|
866
866
|
with pytest.raises(AirflowOptionalProviderFeatureException, match=expected_err):
|
|
@@ -908,7 +908,7 @@ class TestPytestSnowflakeHook:
|
|
|
908
908
|
hook = SnowflakeHook(snowflake_conn_id="mock_conn_id")
|
|
909
909
|
hook.get_oauth_token(conn_config=CONN_PARAMS_OAUTH)
|
|
910
910
|
requests_post.assert_called_once_with(
|
|
911
|
-
f"https://{CONN_PARAMS_OAUTH['account']}.
|
|
911
|
+
f"https://{CONN_PARAMS_OAUTH['account']}.snowflakecomputing.com/oauth/token-request",
|
|
912
912
|
data={
|
|
913
913
|
"grant_type": "refresh_token",
|
|
914
914
|
"refresh_token": CONN_PARAMS_OAUTH["refresh_token"],
|
|
@@ -368,7 +368,7 @@ class TestSnowflakeSqlApiHook:
|
|
|
368
368
|
with pytest.warns(expected_warning=AirflowProviderDeprecationWarning):
|
|
369
369
|
hook.get_oauth_token(CONN_PARAMS_OAUTH)
|
|
370
370
|
requests_post.assert_called_once_with(
|
|
371
|
-
f"https://{CONN_PARAMS_OAUTH['account']}.
|
|
371
|
+
f"https://{CONN_PARAMS_OAUTH['account']}.snowflakecomputing.com/oauth/token-request",
|
|
372
372
|
data={
|
|
373
373
|
"grant_type": "refresh_token",
|
|
374
374
|
"refresh_token": CONN_PARAMS_OAUTH["refresh_token"],
|
|
@@ -304,9 +304,10 @@ def test_create_snowflake_event_pair_success(mock_generate_uuid, is_successful):
|
|
|
304
304
|
assert start_event.job == end_event.job
|
|
305
305
|
|
|
306
306
|
|
|
307
|
+
@mock.patch("importlib.metadata.version", return_value="2.3.0")
|
|
307
308
|
@mock.patch("openlineage.client.uuid.generate_new_uuid")
|
|
308
309
|
@mock.patch("airflow.utils.timezone.utcnow")
|
|
309
|
-
def test_emit_openlineage_events_for_snowflake_queries_with_hook(mock_now, mock_generate_uuid):
|
|
310
|
+
def test_emit_openlineage_events_for_snowflake_queries_with_hook(mock_now, mock_generate_uuid, mock_version):
|
|
310
311
|
fake_uuid = "01958e68-03a2-79e3-9ae9-26865cc40e2f"
|
|
311
312
|
mock_generate_uuid.return_value = fake_uuid
|
|
312
313
|
|
|
@@ -316,6 +317,7 @@ def test_emit_openlineage_events_for_snowflake_queries_with_hook(mock_now, mock_
|
|
|
316
317
|
query_ids = ["query1", "query2", "query3"]
|
|
317
318
|
original_query_ids = copy.deepcopy(query_ids)
|
|
318
319
|
logical_date = timezone.datetime(2025, 1, 1)
|
|
320
|
+
mock_dagrun = mock.MagicMock(logical_date=logical_date, clear_number=0)
|
|
319
321
|
mock_ti = mock.MagicMock(
|
|
320
322
|
dag_id="dag_id",
|
|
321
323
|
task_id="task_id",
|
|
@@ -323,8 +325,9 @@ def test_emit_openlineage_events_for_snowflake_queries_with_hook(mock_now, mock_
|
|
|
323
325
|
try_number=1,
|
|
324
326
|
logical_date=logical_date,
|
|
325
327
|
state=TaskInstanceState.FAILED, # This will be query default state if no metadata found
|
|
328
|
+
dag_run=mock_dagrun,
|
|
326
329
|
)
|
|
327
|
-
mock_ti.get_template_context.return_value = {"dag_run":
|
|
330
|
+
mock_ti.get_template_context.return_value = {"dag_run": mock_dagrun}
|
|
328
331
|
|
|
329
332
|
fake_metadata = {
|
|
330
333
|
"query1": {
|
|
@@ -387,6 +390,10 @@ def test_emit_openlineage_events_for_snowflake_queries_with_hook(mock_now, mock_
|
|
|
387
390
|
"parent": parent_run.ParentRunFacet(
|
|
388
391
|
run=parent_run.Run(runId="01941f29-7c00-7087-8906-40e512c257bd"),
|
|
389
392
|
job=parent_run.Job(namespace=namespace(), name="dag_id.task_id"),
|
|
393
|
+
root=parent_run.Root(
|
|
394
|
+
run=parent_run.RootRun(runId="01941f29-7c00-743e-b109-28b18d0a19c5"),
|
|
395
|
+
job=parent_run.RootJob(namespace=namespace(), name="dag_id"),
|
|
396
|
+
),
|
|
390
397
|
),
|
|
391
398
|
"custom_run": "value_run",
|
|
392
399
|
}
|
|
@@ -535,9 +542,12 @@ def test_emit_openlineage_events_for_snowflake_queries_with_hook(mock_now, mock_
|
|
|
535
542
|
assert fake_client.emit.call_args_list == expected_calls
|
|
536
543
|
|
|
537
544
|
|
|
545
|
+
@mock.patch("importlib.metadata.version", return_value="2.3.0")
|
|
538
546
|
@mock.patch("openlineage.client.uuid.generate_new_uuid")
|
|
539
547
|
@mock.patch("airflow.utils.timezone.utcnow")
|
|
540
|
-
def test_emit_openlineage_events_for_snowflake_queries_without_hook(
|
|
548
|
+
def test_emit_openlineage_events_for_snowflake_queries_without_hook(
|
|
549
|
+
mock_now, mock_generate_uuid, mock_version
|
|
550
|
+
):
|
|
541
551
|
fake_uuid = "01958e68-03a2-79e3-9ae9-26865cc40e2f"
|
|
542
552
|
mock_generate_uuid.return_value = fake_uuid
|
|
543
553
|
|
|
@@ -554,8 +564,11 @@ def test_emit_openlineage_events_for_snowflake_queries_without_hook(mock_now, mo
|
|
|
554
564
|
try_number=1,
|
|
555
565
|
logical_date=logical_date,
|
|
556
566
|
state=TaskInstanceState.SUCCESS, # This will be query default state if no metadata found
|
|
567
|
+
dag_run=mock.MagicMock(logical_date=logical_date, clear_number=0),
|
|
557
568
|
)
|
|
558
|
-
mock_ti.get_template_context.return_value = {
|
|
569
|
+
mock_ti.get_template_context.return_value = {
|
|
570
|
+
"dag_run": mock.MagicMock(logical_date=logical_date, clear_number=0)
|
|
571
|
+
}
|
|
559
572
|
|
|
560
573
|
additional_run_facets = {"custom_run": "value_run"}
|
|
561
574
|
additional_job_facets = {"custom_job": "value_job"}
|
|
@@ -593,6 +606,10 @@ def test_emit_openlineage_events_for_snowflake_queries_without_hook(mock_now, mo
|
|
|
593
606
|
"parent": parent_run.ParentRunFacet(
|
|
594
607
|
run=parent_run.Run(runId="01941f29-7c00-7087-8906-40e512c257bd"),
|
|
595
608
|
job=parent_run.Job(namespace=namespace(), name="dag_id.task_id"),
|
|
609
|
+
root=parent_run.Root(
|
|
610
|
+
run=parent_run.RootRun(runId="01941f29-7c00-743e-b109-28b18d0a19c5"),
|
|
611
|
+
job=parent_run.RootJob(namespace=namespace(), name="dag_id"),
|
|
612
|
+
),
|
|
596
613
|
),
|
|
597
614
|
"custom_run": "value_run",
|
|
598
615
|
}
|
|
@@ -643,7 +660,8 @@ def test_emit_openlineage_events_for_snowflake_queries_without_hook(mock_now, mo
|
|
|
643
660
|
assert fake_client.emit.call_args_list == expected_calls
|
|
644
661
|
|
|
645
662
|
|
|
646
|
-
|
|
663
|
+
@mock.patch("importlib.metadata.version", return_value="2.3.0")
|
|
664
|
+
def test_emit_openlineage_events_for_snowflake_queries_without_query_ids(mock_version):
|
|
647
665
|
query_ids = []
|
|
648
666
|
original_query_ids = copy.deepcopy(query_ids)
|
|
649
667
|
|
|
@@ -666,7 +684,7 @@ def test_emit_openlineage_events_for_snowflake_queries_without_query_ids():
|
|
|
666
684
|
fake_client.emit.assert_not_called() # No events should be emitted
|
|
667
685
|
|
|
668
686
|
|
|
669
|
-
# emit_openlineage_events_for_snowflake_queries requires OL provider 2.
|
|
687
|
+
# emit_openlineage_events_for_snowflake_queries requires OL provider 2.3.0
|
|
670
688
|
@mock.patch("importlib.metadata.version", return_value="1.99.0")
|
|
671
689
|
def test_emit_openlineage_events_with_old_openlineage_provider(mock_version):
|
|
672
690
|
query_ids = ["q1", "q2"]
|
|
@@ -682,7 +700,7 @@ def test_emit_openlineage_events_with_old_openlineage_provider(mock_version):
|
|
|
682
700
|
return_value=fake_listener,
|
|
683
701
|
):
|
|
684
702
|
expected_err = (
|
|
685
|
-
"OpenLineage provider version `1.99.0` is lower than required `2.
|
|
703
|
+
"OpenLineage provider version `1.99.0` is lower than required `2.3.0`, "
|
|
686
704
|
"skipping function `emit_openlineage_events_for_snowflake_queries` execution"
|
|
687
705
|
)
|
|
688
706
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|