Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export data to local system from snowflake cloud data warehouse?

I am using snowflake cloud datawarehouse, which is like teradata that hosts data. I am able run queries and get results on the web UI itself. But I am unclear how can one export the results to a local PC so that we can report based on the data.

Thanks in advance

like image 206
Jeevan Krishna Avatar asked May 21 '15 05:05

Jeevan Krishna


1 Answers

You have 2 options which both use sfsql which is based on henplus. The first option is to export the result of your query to a S3 staging file as shown below:

CREATE STAGE my_stage URL='s3://loading/files/' CREDENTIALS=(AWS_KEY_ID=‘****' AWS_SECRET_KEY=‘****’);
COPY INTO @my_stage/dump
FROM  (select * from orderstiny limit 5) file_format=(format_name=‘csv' compression=‘gzip'');

The other option is to capture the sql result into a file.

test.sql:

set-property column-delimiter ","; 
set-property sql-result-showheader off;
set-property sql-result-showfooter off;

select current_date() from dual;

$ ./sfsql < test.sql > result.txt

For more details and help, login to your snowflake account and access the online documentation or post your question to Snowflake support via the Snowflake support portal which is accessible through the Snowflake help section. Help -> Support Portal.

Hope this helps.

like image 110
Olivier Miranda Avatar answered Nov 22 '22 10:11

Olivier Miranda