forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
json_result_force_utf8_encoding
specification in `providers.s…
…nowflake.hooks.SnowflakeHook` extra dict (apache#44264) * Allow json_result_force_utf8_encoding specification in SnowflakeHook extra dict * Use a set for the not in
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,7 @@ class TestPytestSnowflakeHook: | |
"extra__snowflake__region": "af_region", | ||
"extra__snowflake__role": "af_role", | ||
"extra__snowflake__insecure_mode": "True", | ||
"extra__snowflake__json_result_force_utf8_decoding": "True", | ||
"extra__snowflake__client_request_mfa_token": "True", | ||
}, | ||
}, | ||
|
@@ -158,6 +159,7 @@ class TestPytestSnowflakeHook: | |
"user": "user", | ||
"warehouse": "af_wh", | ||
"insecure_mode": True, | ||
"json_result_force_utf8_decoding": True, | ||
"client_request_mfa_token": True, | ||
}, | ||
), | ||
|
@@ -171,6 +173,7 @@ class TestPytestSnowflakeHook: | |
"extra__snowflake__region": "af_region", | ||
"extra__snowflake__role": "af_role", | ||
"extra__snowflake__insecure_mode": "False", | ||
"extra__snowflake__json_result_force_utf8_decoding": "False", | ||
"extra__snowflake__client_request_mfa_token": "False", | ||
}, | ||
}, | ||
|
@@ -247,6 +250,7 @@ class TestPytestSnowflakeHook: | |
"extra": { | ||
**BASE_CONNECTION_KWARGS["extra"], | ||
"extra__snowflake__insecure_mode": False, | ||
"extra__snowflake__json_result_force_utf8_decoding": True, | ||
"extra__snowflake__client_request_mfa_token": False, | ||
}, | ||
}, | ||
|
@@ -266,6 +270,7 @@ class TestPytestSnowflakeHook: | |
"session_parameters": None, | ||
"user": "user", | ||
"warehouse": "af_wh", | ||
"json_result_force_utf8_decoding": True, | ||
}, | ||
), | ||
], | ||
|
@@ -473,6 +478,23 @@ def test_get_sqlalchemy_engine_should_support_insecure_mode(self): | |
) | ||
assert mock_create_engine.return_value == conn | ||
|
||
def test_get_sqlalchemy_engine_should_support_json_result_force_utf8_decoding(self): | ||
connection_kwargs = deepcopy(BASE_CONNECTION_KWARGS) | ||
connection_kwargs["extra"]["extra__snowflake__json_result_force_utf8_decoding"] = "True" | ||
|
||
with ( | ||
mock.patch.dict("os.environ", AIRFLOW_CONN_TEST_CONN=Connection(**connection_kwargs).get_uri()), | ||
mock.patch("airflow.providers.snowflake.hooks.snowflake.create_engine") as mock_create_engine, | ||
): | ||
hook = SnowflakeHook(snowflake_conn_id="test_conn") | ||
conn = hook.get_sqlalchemy_engine() | ||
mock_create_engine.assert_called_once_with( | ||
"snowflake://user:[email protected]_region/db/public" | ||
"?application=AIRFLOW&authenticator=snowflake&role=af_role&warehouse=af_wh", | ||
connect_args={"json_result_force_utf8_decoding": True}, | ||
) | ||
assert mock_create_engine.return_value == conn | ||
|
||
def test_get_sqlalchemy_engine_should_support_session_parameters(self): | ||
connection_kwargs = deepcopy(BASE_CONNECTION_KWARGS) | ||
connection_kwargs["extra"]["session_parameters"] = {"TEST_PARAM": "AA", "TEST_PARAM_B": 123} | ||
|