Setup

Pre-requisites #

Snowflake #

Unloading into Amazon S3 #

Create a Cloud Storage Integration #

https://docs.snowflake.com/en/sql-reference/sql/create-stage

-- External stage
CREATE OR REPLACE STAGE IF NOT EXISTS  <external_stage_name>
  URL = '<protocol>://<bucket>[/<path>/]'
CREDENTIALS = (AWS_KEY_ID = '<string>' AWS_SECRET_KEY = '<string>'  )
FILE_FORMAT = (TYPE = PARQUET  COMPRESSION=NONE )

First, create a cloud storage integration

For example:

CREATE STORAGE INTEGRATION s3_int
  TYPE = EXTERNAL_STAGE
  STORAGE_PROVIDER = 'S3'
  ENABLED = TRUE
  STORAGE_AWS_ROLE_ARN = 'arn:aws:iam::001234567890:role/myrole'
  STORAGE_ALLOWED_LOCATIONS = ('*')
  STORAGE_BLOCKED_LOCATIONS = ('s3://mybucket1/mypath1/sensitivedata/', 's3://mybucket2/mypath2/sensitivedata/');

Unloading data directly into an S3 bucket¶ #

Then use the COPY INTO command to copy the data from the Snowflake database table into an S3 bucket

Example:

COPY INTO s3://mybucket/unload/ 
FROM mytable 
storage_integration = s3_int
FILE_FORMAT = parquet;