You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/11/25 16:53:56 UTC

[GitHub] [airflow] JavierLopezT commented on a change in pull request #11350: Allow execution of multiple sql statements in SnowflakeHook

JavierLopezT commented on a change in pull request #11350:
URL: https://github.com/apache/airflow/pull/11350#discussion_r530517569



##########
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:
       I have updated the code using execute_string and adding the previous method for not breaking backwards compatibility in case you were using a list of queries




----------------------------------------------------------------
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:
users@infra.apache.org