redash icon indicating copy to clipboard operation
redash copied to clipboard

Snowflake: multiple SQL statements

Open ibogretsov opened this issue 4 years ago • 2 comments
trafficstars

Issue Summary

Hello, We are migrating from the Redshift to the Snowflake. We ran into one problem. Snowflake does not support the multiple statements in one API call.

Steps to Reproduce

For example in the worksheet we have queries:

select * from t1;
select * from t2;

Push Execute and receive next error message: 000006 (0A000): Multiple SQL statements in a single API call are not supported; use one API call per statement instead. This restriction makes it impossible to use temporary tables in the Redash for the Snowflake. This is a big problem for us, because our analytics use temporary tables to store intermediate data in these tables.

I've investigated the Redash source code for the Snowflake query runner and the Snowflake documentation for snowflake.connector for python. I found that, yeah, cursor object's method execute, which is used in Redash, supports running only one query. But there is execute_string method of snowflake connection object which allows to run many SQL statements. It just splits sql query by delimiter, runs one by one and returns list of cursors.

So, for the general Redash way to execute multiple sql statements (result only for the last query) need to get and parse data only from the last cursor.

ibogretsov avatar Mar 18 '21 13:03 ibogretsov

+1

motoy3d avatar Aug 05 '22 04:08 motoy3d

Thanks is for bumping this. We're happy to merge a fix for this. If you're interested in making this contribution please let me know as I'm happy to provide guidance.

susodapop avatar Aug 07 '22 14:08 susodapop

+1. Can be solved using snowflake-connector-python v 2.9.0

yonatang-cyera avatar Dec 19 '22 11:12 yonatang-cyera