0% found this document useful (0 votes)
41 views

Stages in Snowflake

The document discusses staging areas in Snowflake. There are two types of staging areas: external staging areas, which are cloud storage areas like AWS S3, and internal staging areas which are blob storage areas managed by Snowflake. The internal staging area can be a user stage, table stage, or named stage. User and table stages are allocated by default while a named stage is a database object that provides more flexibility.

Uploaded by

Vijay Yajurvedi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Stages in Snowflake

The document discusses staging areas in Snowflake. There are two types of staging areas: external staging areas, which are cloud storage areas like AWS S3, and internal staging areas which are blob storage areas managed by Snowflake. The internal staging area can be a user stage, table stage, or named stage. User and table stages are allocated by default while a named stage is a database object that provides more flexibility.

Uploaded by

Vijay Yajurvedi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

STAGES IN SNOWFLAKE

§ Don’t confuse staging area of snowflake with data warehouse staging area.
§ Staging area in snowflake is a blob storage area where you load all your raw
files before loading them into snowflake database.

© 2018 Slidefabric.com All rights reserved. 1


STAGES IN SNOWFLAKE
§ Which blob storage areas you can use ?

SNOWFLAKE EXTERNAL STAGING AREAS

© 2018 Slidefabric.com All rights reserved. 2


STAGES IN SNOWFLAKE
§ What if I don’t have subscription to these cloud storage areas ?

© 2018 Slidefabric.com All rights reserved. 3


STAGES IN SNOWFLAKE
§ What if I don’t have subscription to these cloud storage areas ?

Internal staging area

§ Remember this is also a blob storage, which is managed by snowflake.


© 2018 Slidefabric.com All rights reserved. 4
STAGES IN SNOWFLAKE
§ Snowflake stage is not data warehouse stages.
§ We have two types of staging areas in snowflake.
§ External staging area.
§ Internal staging area.

© 2018 Slidefabric.com All rights reserved. 5


STAGES IN SNOWFLAKE
§ Snowflake stage is not data warehouse stages.
§ We have two types of staging areas in snowflake.
§ External staging area.
§ Internal staging area.

© 2018 Slidefabric.com All rights reserved. 6


STAGES IN SNOWFLAKE
§ Configuring stages with snowflake database.

© 2018 Slidefabric.com All rights reserved. 7


EXTERNAL STAGING SNOWFLAKE
Not secure
STAGE
AWS

GCS FILE COPY


FORMAT COMMAND
AZURE Secure
INTEGRATION
OBJECT

© 2018 Slidefabric.com All rights reserved. 8


INTERNAL STAGING SNOWFLAKE
Not secure
STAGE
AWS

GCS FILE COPY


FORMAT COMMAND
AZURE Secure
INTEGRATION
OBJECT

© 2018 Slidefabric.com All rights reserved. 9


INTERNAL STAGING SNOWFLAKE
USER
STAGE
@~

TABLE
STAGE
@%

NAMED
STAGE
@

© 2018 Slidefabric.com All rights reserved. 10


USER STAGES IN SNOWFLAKE
§ Each user has a Snowflake stage allocated to them by default for storing
files. This stage is a convenient option if your files will only be accessed by a
single user but need to be copied into multiple tables.
§ Constraints
§ Multiple users require access to the files.
§ The current user does not have INSERT privileges on the tables the
data will be loaded into.

© 2018 Slidefabric.com All rights reserved. 11


TABLE STAGES IN SNOWFLAKE
§ Each table has a Snowflake stage allocated to it by default for storing files.
This stage is a convenient option if your files need to be accessible to
multiple users and only need to be copied into a single table.
§ Constraints
§ Multiple users require access to the files.
§ Unlike named stages, table stages cannot be altered or dropped.
§ Table stages do not support setting file format options. Instead, you must specify file format
and copy options as part of the COPY INTO <table> command.
§ Table stages do not support transforming data while loading it (i.e. using a query as the
source for the COPY command).
© 2018 Slidefabric.com All rights reserved. 12
NAMED STAGES IN SNOWFLAKE
§ Internal stages are named database objects that provide the greatest degree
of flexibility for data loading. Because they are database objects, the
security/access rules that apply to all objects apply
§ Users with the appropriate privileges on the stage can load data into any
table.
§ Ownership of the stage can be transferred to another role, and privileges
granted to use the stage can be modified to add or remove roles.

© 2018 Slidefabric.com All rights reserved. 13


LESSONS LEARNED
§ Syntax for creating stage objects.
§ Syntax for creating file format object.
§ Understood differences between both objects.
§ Best practice to create stage object and file format object.
§ You got high level overview of copy command.

© 2018 Slidefabric.com All rights reserved. 14


LESSONS LEARNED
§ How to use put command.
§ How to list files, remove files in staging area.
§ Split part function in snowflake.
§ Using place holders while executing copy command.
§ Performance impact and storage impact if you are not cleaning staging area.

© 2018 Slidefabric.com All rights reserved. 15


LESSONS LEARNED
§ How to use get command.
§ How to unload only selective columns to stage.
§ OVERWRITE option and creating files with different names.
§ Syntax of copy command to unload data.

© 2018 Slidefabric.com All rights reserved. 16


LESSONS LEARNED
§ Named stage is an object.
§ You can desc it and provide access control and revoke access for named
stage.
§ You can share data stored in named stage across tables.

© 2018 Slidefabric.com All rights reserved. 17


Working with Internal staging area
§ How to upload data to internal staging area.
§ Download data from internal staging area.
§ Using table stage and named stage.
§ Best practice while using internal staging.

© 2018 Slidefabric.com All rights reserved. 18

You might also like