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 d8bff0094ee make host/port configurable for Snowflake connections
(#44079)
d8bff0094ee is described below
commit d8bff0094ee453f4b01266b7d0cc662ff48a7f59
Author: Waldemar Hummer <[email protected]>
AuthorDate: Fri Nov 15 17:26:53 2024 -0800
make host/port configurable for Snowflake connections (#44079)
---
docs/apache-airflow-providers-snowflake/connections/snowflake.rst | 2 ++
providers/src/airflow/providers/snowflake/hooks/snowflake.py | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/docs/apache-airflow-providers-snowflake/connections/snowflake.rst
b/docs/apache-airflow-providers-snowflake/connections/snowflake.rst
index 8d4a3aad646..741d73a62e3 100644
--- a/docs/apache-airflow-providers-snowflake/connections/snowflake.rst
+++ b/docs/apache-airflow-providers-snowflake/connections/snowflake.rst
@@ -62,6 +62,8 @@ Extra (optional)
* ``private_key_content``: Specify the content of the private key file.
* ``session_parameters``: Specify `session level parameters
<https://docs.snowflake.com/en/user-guide/python-connector-example.html#setting-session-parameters>`_.
* ``insecure_mode``: Turn off OCSP certificate checks. For details, see:
`How To: Turn Off OCSP Checking in Snowflake Client Drivers - Snowflake
Community
<https://community.snowflake.com/s/article/How-to-turn-off-OCSP-checking-in-Snowflake-client-drivers>`_.
+ * ``host``: Target Snowflake hostname to connect to (e.g., for local
testing with LocalStack).
+ * ``port``: Target Snowflake port to connect to (e.g., for local testing
with LocalStack).
URI format example
^^^^^^^^^^^^^^^^^^
diff --git a/providers/src/airflow/providers/snowflake/hooks/snowflake.py
b/providers/src/airflow/providers/snowflake/hooks/snowflake.py
index 0f81f2e3840..81785338e7b 100644
--- a/providers/src/airflow/providers/snowflake/hooks/snowflake.py
+++ b/providers/src/airflow/providers/snowflake/hooks/snowflake.py
@@ -279,6 +279,14 @@ class SnowflakeHook(DbApiHook):
conn_config.pop("login", None)
conn_config.pop("password", None)
+ # configure custom target hostname and port, if specified
+ snowflake_host = extra_dict.get("host")
+ snowflake_port = extra_dict.get("port")
+ if snowflake_host:
+ conn_config["host"] = snowflake_host
+ if snowflake_port:
+ conn_config["port"] = snowflake_port
+
return conn_config
def get_uri(self) -> str: