This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 0fe1041cc6 remove deprecations snowflake (#39729)
0fe1041cc6 is described below
commit 0fe1041cc631404571c431f8013979955d7f862d
Author: Bowrna <[email protected]>
AuthorDate: Mon May 27 15:32:38 2024 +0530
remove deprecations snowflake (#39729)
---
.../operators/snowflake.rst | 13 ++++++++-----
tests/always/test_example_dags.py | 1 -
tests/system/providers/snowflake/example_snowflake.py | 17 ++++++++++-------
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/docs/apache-airflow-providers-snowflake/operators/snowflake.rst
b/docs/apache-airflow-providers-snowflake/operators/snowflake.rst
index 5a94f5b87e..0014489604 100644
--- a/docs/apache-airflow-providers-snowflake/operators/snowflake.rst
+++ b/docs/apache-airflow-providers-snowflake/operators/snowflake.rst
@@ -17,17 +17,20 @@
.. _howto/operator:SnowflakeOperator:
-SnowflakeOperator
-=================
+SQLExecuteQueryOperator to connect to Snowflake
+===============================================
-Use the :class:`SnowflakeOperator
<airflow.providers.snowflake.operators.snowflake>` to execute
+Use the :class:`SQLExecuteQueryOperator
<airflow.providers.common.sql.operators.sql>` to execute
SQL commands in a `Snowflake <https://docs.snowflake.com/en/>`__ database.
+.. warning::
+ Previously, SnowflakeOperator was used to perform this kind of operation.
But at the moment SnowflakeOperator is deprecated and will be removed in future
versions of the provider. Please consider to switch to SQLExecuteQueryOperator
as soon as possible.
+
Using the Operator
^^^^^^^^^^^^^^^^^^
-Use the ``snowflake_conn_id`` argument to connect to your Snowflake instance
where
+Use the ``conn_id`` argument to connect to your Snowflake instance where
the connection metadata is structured as follows:
.. list-table:: Snowflake Airflow Connection Metadata
@@ -45,7 +48,7 @@ the connection metadata is structured as follows:
* - Extra: dictionary
- ``warehouse``, ``account``, ``database``, ``region``, ``role``,
``authenticator``
-An example usage of the SnowflakeOperator is as follows:
+An example usage of the SQLExecuteQueryOperator to connect to Snowflake is as
follows:
.. exampleinclude::
/../../tests/system/providers/snowflake/example_snowflake.py
:language: python
diff --git a/tests/always/test_example_dags.py
b/tests/always/test_example_dags.py
index 88db9a0556..6affbe7aa5 100644
--- a/tests/always/test_example_dags.py
+++ b/tests/always/test_example_dags.py
@@ -61,7 +61,6 @@ IGNORE_AIRFLOW_PROVIDER_DEPRECATION_WARNING: tuple[str, ...]
= (
# Deprecated Operators/Hooks, which replaced by common.sql Operators/Hooks
"tests/system/providers/jdbc/example_jdbc_queries.py",
"tests/system/providers/microsoft/mssql/example_mssql.py",
- "tests/system/providers/snowflake/example_snowflake.py",
"tests/system/providers/trino/example_trino.py",
)
diff --git a/tests/system/providers/snowflake/example_snowflake.py
b/tests/system/providers/snowflake/example_snowflake.py
index 48e524e437..1a6f12080d 100644
--- a/tests/system/providers/snowflake/example_snowflake.py
+++ b/tests/system/providers/snowflake/example_snowflake.py
@@ -25,7 +25,8 @@ import os
from datetime import datetime
from airflow import DAG
-from airflow.providers.snowflake.operators.snowflake import SnowflakeOperator,
SnowflakeSqlApiOperator
+from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
+from airflow.providers.snowflake.operators.snowflake import
SnowflakeSqlApiOperator
SNOWFLAKE_CONN_ID = "my_snowflake_conn"
SNOWFLAKE_SAMPLE_TABLE = "sample_table"
@@ -44,29 +45,31 @@ DAG_ID = "example_snowflake"
with DAG(
DAG_ID,
start_date=datetime(2021, 1, 1),
- default_args={"snowflake_conn_id": SNOWFLAKE_CONN_ID},
+ default_args={"snowflake_conn_id": SNOWFLAKE_CONN_ID, "conn_id":
SNOWFLAKE_CONN_ID},
tags=["example"],
schedule="@once",
catchup=False,
) as dag:
# [START howto_operator_snowflake]
- snowflake_op_sql_str = SnowflakeOperator(task_id="snowflake_op_sql_str",
sql=CREATE_TABLE_SQL_STRING)
+ snowflake_op_sql_str = SQLExecuteQueryOperator(
+ task_id="snowflake_op_sql_str", sql=CREATE_TABLE_SQL_STRING
+ )
- snowflake_op_with_params = SnowflakeOperator(
+ snowflake_op_with_params = SQLExecuteQueryOperator(
task_id="snowflake_op_with_params",
sql=SQL_INSERT_STATEMENT,
parameters={"id": 56},
)
- snowflake_op_sql_list = SnowflakeOperator(task_id="snowflake_op_sql_list",
sql=SQL_LIST)
+ snowflake_op_sql_list =
SQLExecuteQueryOperator(task_id="snowflake_op_sql_list", sql=SQL_LIST)
- snowflake_op_sql_multiple_stmts = SnowflakeOperator(
+ snowflake_op_sql_multiple_stmts = SQLExecuteQueryOperator(
task_id="snowflake_op_sql_multiple_stmts",
sql=SQL_MULTIPLE_STMTS,
split_statements=True,
)
- snowflake_op_template_file = SnowflakeOperator(
+ snowflake_op_template_file = SQLExecuteQueryOperator(
task_id="snowflake_op_template_file",
sql="example_snowflake_snowflake_op_template_file.sql",
)