eladkal commented on a change in pull request #11350:
URL: https://github.com/apache/airflow/pull/11350#discussion_r501772392
##########
File path: airflow/providers/snowflake/hooks/snowflake.py
##########
@@ -139,3 +139,13 @@ def _get_aws_credentials(self) -> Tuple[Optional[Any],
Optional[Any]]:
def set_autocommit(self, conn, autocommit: Any) -> None:
conn.autocommit(autocommit)
+
+ def run(self, sql, autocommit=False, parameters=None):
+ """Snowflake-connector doesn't allow natively the execution of
multiple SQL statements in the same call. So for
+ allowing to pass files or strings with several queries this method is
coded, that relies on run from DBApiHook"""
+ if isinstance(sql, str):
+ queries = sql.split(';')
Review comment:
Is it backward compatible?
What happens when user has single query that search text column for
substring `;` as char? I think this requires to add note about it.
What do you think about exposing `execute_string` which can handle multiple
SQLs in single string in addition to the run method of dbapi hook.
https://docs.snowflake.com/en/user-guide/python-connector-api.html#execute_string
https://github.com/snowflakedb/snowflake-connector-python/blob/master/src/snowflake/connector/connection.py#L493
##########
File path: airflow/providers/snowflake/hooks/snowflake.py
##########
@@ -139,3 +139,13 @@ def _get_aws_credentials(self) -> Tuple[Optional[Any],
Optional[Any]]:
def set_autocommit(self, conn, autocommit: Any) -> None:
conn.autocommit(autocommit)
+
+ def run(self, sql, autocommit=False, parameters=None):
+ """Snowflake-connector doesn't allow natively the execution of
multiple SQL statements in the same call. So for
+ allowing to pass files or strings with several queries this method is
coded, that relies on run from DBApiHook"""
+ if isinstance(sql, str):
+ queries = sql.split(';')
Review comment:
Is it backward compatible?
What happens when user has single query that search text column for
substring `;` as char? I think this requires to add note about it.
What do you think about exposing `execute_string` which can handle multiple
SQLs in single string in addition to the run method of dbapi hook.
https://docs.snowflake.com/en/user-guide/python-connector-api.html#execute_string
https://github.com/snowflakedb/snowflake-connector-python/blob/master/src/snowflake/connector/connection.py#L493
**Edit:** thinking about it with not sure it's possible to preserve backward
compatible as even if the hook behavior is unchanged there will still be an
open question regarding which one of the hook function the SnowflakeOperator
should use.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]