Video | Snowflake | Data engineering | Data prep

How to Load data into a Snowflake Database from AWS S3 | Learning Snowflake

I'm learning Snowflake myself, so I'll show you how to load S3 data and every mistake I made getting there.

Part ofGetting Started with Snowflake
  • Set up structure first: use CREATE OR REPLACE to make a database, a dedicated external staging schema, and an external stage pointing to your S3 URL (a public bucket needs no credentials, but enterprise setups require keys and encryption).
  • You can query files directly in S3 without loading them by aliasing the stage and selecting positional columns (t.$1, t.$2), which lets you preview data and discover the real delimiter.
  • Create a reusable named file format (TYPE = CSV, FIELD_DELIMITER = '|', SKIP_HEADER = 1) and reference it in later queries instead of re-specifying options each time.
  • File formats are schema-specific: a format created in one schema isn't visible from another, and the COPY INTO context must reference fully-qualified stage paths like database.schema.stage.
  • COPY INTO can load either directly from an external location or from a SELECT statement, letting you apply transformations at load time.

In this video, I show you how to load data from a stage that holds data in AWS S3 into a table in Snowflake. This is an end-to-end tutorial, including the troubleshooting I had to do to get my SQL working.

Resources I mention in the video: Link to GitHub with the SQL https://bit.ly/3OeANzy Create table https://bit.ly/3tEJ6eu Create stage https://bit.ly/3XnBAmb Querying data stored in staged files https://bit.ly/3V0zE1n Copy into https://bit.ly/3EFWfdG File format https://bit.ly/3AqPQka

Timestamps: 0:00 Intro 0:29 Setting up 0:44 Comments and overview 1:48 Create a database in Snowflake 3:34 Create a schema in Snowflake 5:17 Create a stage in Snowflake 9:45 View metadata of your stage 11:22 View the files in your stage 12:42 How to query the data in your stage 19:50 File formats in Snowflake 24:33 Preview with a transformation 28:39 Create Table in Snowflake 33:11 Copy data into the table in Snowflake 36:04 A long spell of troubleshooting 42:25 The other way to copy into in Snowflake 45:30 Query our data in Snowflake 46:51 Outro ‍