Zero to Snowflake: Staging Explained

Data

Zero to Snowflake: Staging Explained

This series takes you from zero to hero with the latest and greatest cloud data warehousing platform, Snowflake.

A critical part of any Snowflake database is the storage of the data. Snowflake is capable of both storing data within the environment and accessing data that is stored in other cloud storage environments. Regardless of whether the data is stored internally or externally, the location the data is stored in is known as a stage. In turn, the process of uploading files into one of these stages is known as staging.

Types of Snowflake Stages

Snowflake allows for several types of stage:

  • External stages are storage locations outside the Snowflake environment in another cloud storage location. This could be either Amazon S3 storage or Microsoft Azure storage, allowing for greater flexibility for potential web hosting and ELT solutions prior to accessing the data in Snowflake. The drawback with these stages is that the storage location may be in a different region from your Snowflake environment, which may impact data loading speeds.
  • User stages are personal storage locations for each user. These stages are unique to the user, meaning no other user can access the stage. Each user has a user stage allocated by default, and these cannot be altered or dropped.
  • Table stages are storage locations held within a table object. This is helpful when files only need to be loaded into that specific table, and these stages will achieve that result fastest. However, they are limited to that one table, and the files cannot be accessed by other tables.
  • Internal named stages are storage location objects within a Snowflake database/schema. Because they are database objects, the same security permissions apply as with any other database objects. These stages are not created automatically, unlike user and table stages. However, they do provide greater flexibility for loading files into multiple tables and/or allowing multiple users to access the same stage.

Notice that it is only possible to create external stages and internal named stages, as the other two types of stage are automatically created and managed by Snowflake itself.

Creating a Stage via the User Interface

We are going to create a stage within our Demo_DB database. To begin, we open this database in Snowflake and select Stages from the navigation menu. This page lists all stages existing within the database. As we have not created any yet, this list is blank:

Select Create… to begin creating a stage. The first choice is whether the stage should be an internal named stage (managed by Snowflake) or external stage (existing in Amazon S3 or Microsoft Azure storage):

The simplest of these options is the internal named stage managed by Snowflake. If this option is selected, the only requirements are a name for the stage, the schema it will belong to and any comments. Remember that all object names must adhere to Snowflake’s object naming syntax:

External stages require more information as a connection is being established to another storage environment. In addition to a name, schema and comment, you will need to provide the location of the stage along with any authentication credentials.

For Amazon S3:

For Microsoft Azure:

Creating a Stage with Code

Similar to databases, schemas and indeed all objects and user interface commands in Snowflake, we can create stages using SQL code. It is worth remembering that a great feature of Snowflake is that each action taken in the user interface can also be performed using SQL code, and Snowflake tells you exactly what this code is when you select the Show SQL option.

To create an internal named stage called Demo_Stage, we execute following code:

Similarly, we can create external stages to Amazon S3 and Microsoft Azure storage.

For Amazon S3:

For Microsoft Azure:

Learn more about stages in Snowflake’s documentation.

Loading Data

Once we have a database, schema and stage, we can begin staging data and loading it into tables in our database. Depending on your preference, you can do this either via the user interface or using code via SnowSQL, both options we cover in this series. Find the right resource for you!

More About the Author

Chris Hastie

Data Engineer
Zero to Snowflake: Automated Clustering in Snowflake One of Snowflake’s key selling points is automated clustering. However, it’s not immediately clear what this actually ...
Zero to Snowflake: The Nuances of Cloning One of the fantastic features in Snowflake is the support of zero-copy cloning. This is the capability to duplicate an object while ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

black. lives. matter.