Рет қаралды 1,498
Prerequisite:
----------------------
Configuring a Snowflake Storage Integration to Access Amazon S3
• Configuring a Snowflak...
Refreshing External Snowflake Tables Automatically for Amazon S3
• Refreshing External Sn...
Code:
-----------
Step 1: Create IAM role for Snowflake
Step 2:Execute below queries in Snowflake
drop database if exists s3_to_snowflake;
--Database Creation
create database if not exists s3_to_snowflake;
--Specify the active/current database for the session.
use s3_to_snowflake;
--Specify the role
use role ACCOUNTADMIN;
Step 3:Create s3 bucket--demoytsnsautomation
Step 4:Execute below queries in Snowflake --
--Storage Integration Creation
create or replace storage integration s3_int
TYPE = EXTERNAL_STAGE
STORAGE_PROVIDER = S3
ENABLED = TRUE
STORAGE_AWS_ROLE_ARN = ''
STORAGE_ALLOWED_LOCATIONS = ('s3://{}')
COMMENT = 'Testing Snowflake getting refresh or not';
--Describe the Integration Object
DESC INTEGRATION s3_int;
--External Stage Creation
create stage mystage
url = 's3://demosnowflakesns'
storage_integration = s3_int;
list @mystage;
--File Format Creation
create or replace file format my_csv_format
type = csv field_delimiter = ',' skip_header = 1
field_optionally_enclosed_by = '"'
null_if = ('NULL', 'null')
empty_field_as_null = true;
Step 5:Create SNS Topic --demoytsnsautomation
Access Policy --Make a copy
Step 6:Execute below query in Snowflake & update SNS access policy--
select system$get_aws_sns_iam_policy('{}');
Step 7:Create event notification for s3
Step 8:
--Table Creation
create or replace external table s3_to_snowflake.PUBLIC.Iris_dataset (Id number(10,0) as (Value:c1::int),sepal_length number(10,5) as (Value:c2::number(10,5)),
sepal_width number(10,4) as (Value:c3::number(10,4)),petal_length number(10,3) as (Value:c4::number(10,3)),
petal_width number(10,4) as (Value:c5::number(10,4)), CLASS_NAME varchar(20) as (Value:c6::varchar)) with location = @mystage file_format ='my_csv_format'
aws_sns_topic = '';
select * from s3_to_snowflake.PUBLIC.Iris_dataset;
Check this playlist for more AWS Projects in Big Data domain:
• Demystifying Data Engi...