getredash / redash

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.
http://redash.io/
BSD 2-Clause "Simplified" License
26.31k stars 4.37k forks source link

Snowflake: multiple SQL statements #5429

Open ibogretsov opened 3 years ago

ibogretsov commented 3 years ago

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.

motoy3d commented 2 years ago

+1

susodapop commented 2 years ago

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.

yonatang-cyera commented 1 year ago

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