Lee-W commented on code in PR #41150:
URL: https://github.com/apache/airflow/pull/41150#discussion_r1718233631
##########
airflow/providers/snowflake/hooks/snowflake_sql_api.py:
##########
@@ -158,10 +158,13 @@ def execute_query(
data = {
"statement": sql,
"resultSetMetaData": {"format": "json"},
- "database": conn_config["database"],
- "schema": conn_config["schema"],
- "warehouse": conn_config["warehouse"],
- "role": conn_config["role"],
+ # If database, schema, warehouse, role parameters have been
provided set them accordingly
+ # If either of them has been not (Parent class initializes them to
None in that case)
+ # set them to what in the Airflow connection configuration
+ "database": self.database if self.database else
conn_config["database"],
+ "schema": self.schema if self.schema else conn_config["schema"],
+ "warehouse": self.warehouse if self.warehouse else
conn_config["warehouse"],
+ "role": self.role if self.role else conn_config["role"],
Review Comment:
```suggestion
"database": self.database or conn_config["database"],
"schema": self.schema or conn_config["schema"],
"warehouse": self.warehouse or conn_config["warehouse"],
"role": self.role or conn_config["role"],
```
##########
tests/providers/snowflake/hooks/test_snowflake_sql_api.py:
##########
@@ -580,3 +587,136 @@ async def test_get_sql_api_query_status_async(
hook = SnowflakeSqlApiHook(snowflake_conn_id="test_conn")
response = await hook.get_sql_api_query_status_async("uuid")
assert response == expected_response
+
+ @pytest.mark.parametrize("hook_params", [(HOOK_PARAMS), ({})])
+ def test_hook_parameter_propagation(self, hook_params):
+ """
+ This tests the proper propagation of unpacked hook params into the
SnowflakeSqlApiHook object.
+ """
+ hook = SnowflakeSqlApiHook(snowflake_conn_id="test_conn",
**hook_params)
+ assert hook.database == hook_params.get("database", None)
+ assert hook.schema == hook_params.get("schema", None)
+ assert hook.warehouse == hook_params.get("warehouse", None)
+ assert hook.role == hook_params.get("role", None)
+
+ @pytest.mark.parametrize(
+
"test_hook_params,sql,statement_count,expected_payload,expected_response",
Review Comment:
```suggestion
"test_hook_params, sql, statement_count, expected_payload,
expected_response",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]