Learn how to bridge the gap between cloud storage and your Snowflake warehouse using Stages and File Formats. This hands-on lesson covers external stages for S3, GCS, and Azure Blob, file format configuration for CSV, JSON, and Parquet, and reliable bulk loading with COPY INTO.

Imagine your analytics team just received a dump of three months of customer transaction records — a collection of CSV files sitting in an Amazon S3 bucket, uploaded by your payment processor. Your Snowflake warehouse is ready. Your dbt models are waiting. But there's a gap between "files in cloud storage" and "queryable data in a table," and bridging that gap is exactly what Snowflake Stages and File Formats are designed to do.
This is one of the most practical skills a data engineer needs. Tools like Fivetran and Airbyte handle many ingestion scenarios automatically, but there are countless situations — partner data drops, batch exports, legacy system dumps, one-time migrations — where you need to load files directly from cloud storage into Snowflake yourself. Understanding how Snowflake's staging layer works gives you the control and flexibility to handle all of them.
By the end of this lesson, you'll be able to create external stages pointing to S3, GCS, and Azure Blob Storage, define file format objects that tell Snowflake how to parse your files, and use the COPY INTO command to load data reliably into your tables. You'll also understand why Snowflake's architecture separates these concerns the way it does, which will save you hours of debugging when things don't go as planned.
What you'll learn:
COPY INTO to load data, handle errors, and monitor load historyCREATE TABLE and SELECT statementsBefore we write any SQL, let's build an intuition for what a Stage actually is.
Think of Snowflake as a secure warehouse facility. Data cannot walk in through just any entrance — there's a designated loading dock. In Snowflake, that loading dock is called a Stage. A Stage is a named pointer to a location where data files live, either inside Snowflake's own managed storage or in an external cloud storage service you control.
When you run a COPY INTO command, Snowflake doesn't connect directly to your S3 bucket from some arbitrary process. Instead, it reads from the Stage object you've defined, using the credentials and configuration stored there. This design gives you clean separation between where data lives, how it's formatted, and what table it goes into.
There are two fundamental types of Stages:
Internal Stages are storage managed by Snowflake itself. You upload files to them using the PUT command from SnowSQL (Snowflake's CLI client). There are three subtypes: the User Stage (private to your user, referenced as @~), the Table Stage (attached to a specific table, referenced as @%tablename), and Named Internal Stages (explicitly created, shareable objects in your database). Internal stages are great for quick uploads or when you're scripting file transfers.
External Stages point to cloud storage you manage — an S3 bucket, a GCS bucket, or an Azure Blob container. The stage stores the connection details and credentials. This is by far the most common pattern in production data engineering, because your source data is almost always already living in cloud storage.
Key insight
A Stage is not a copy of your data. It's a reference — like a bookmark to a location. When you query or load from a stage, Snowflake reads the actual files from their source location at that moment. This means you can update files in S3 and Snowflake will read the latest versions without touching the stage definition.
Snowflake needs to know how to interpret the bytes in your files. A CSV file from your payment processor has commas separating columns and newlines ending rows — but maybe it also has a header row to skip, quoted strings with embedded commas, and a date format that looks like 2024-03-15 09:22:41.000. A JSON file from your event tracking system has an entirely different structure. Parquet files are binary and compressed.
A File Format is a named Snowflake object that captures all of these parsing instructions. By separating this configuration into its own object, you can reuse the same file format definition across multiple stages and COPY INTO commands, keeping your code DRY and your configurations consistent.
Let's create some common file formats. First, switch to the database and schema where you want to create these objects:
USE DATABASE analytics_db;
USE SCHEMA raw;
CREATE OR REPLACE FILE FORMAT csv_standard
TYPE = 'CSV'
FIELD_DELIMITER = ','
RECORD_DELIMITER = '\n'
SKIP_HEADER = 1
FIELD_OPTIONALLY_ENCLOSED_BY = '"'
NULL_IF = ('NULL', 'null', '')
EMPTY_FIELD_AS_NULL = TRUE
DATE_FORMAT = 'YYYY-MM-DD'
TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF3'
TRIM_SPACE = TRUE;
Let's walk through the important options here:
SKIP_HEADER = 1 tells Snowflake to ignore the first row, which is typically a column header rowFIELD_OPTIONALLY_ENCLOSED_BY = '"' handles quoted fields — critical for CSVs where a text field might contain a commaNULL_IF converts specific string values to SQL NULLTRIM_SPACE = TRUE removes leading and trailing whitespace from field values, which eliminates a surprisingly common class of data quality bugsCREATE OR REPLACE FILE FORMAT json_standard
TYPE = 'JSON'
STRIP_OUTER_ARRAY = TRUE
NULL_IF = ('null', '');
STRIP_OUTER_ARRAY = TRUE is worth understanding. Many JSON files exported from APIs or databases look like [{...}, {...}, {...}] — a single JSON array wrapping all the objects. This option tells Snowflake to treat each element of that outer array as a separate record. Without it, Snowflake would try to load the entire file as a single VARIANT value.
CREATE OR REPLACE FILE FORMAT parquet_standard
TYPE = 'PARQUET'
SNAPPY_COMPRESSION = TRUE;
Parquet is a columnar binary format that's extremely efficient for large datasets. It's self-describing, meaning the schema is embedded in the file itself, so you need fewer format options.
Tip
Use SHOW FILE FORMATS; in your schema to see all defined file formats and their settings. This is handy when you're inheriting a codebase and need to understand what formats already exist.
Now we can create external stages that point to your cloud storage. We'll cover all three major providers.
The most common setup. You'll need an S3 bucket, an IAM user or role with read access to that bucket, and the access key credentials.
First, create a Snowflake Storage Integration (the recommended, more secure approach over inline credentials):
CREATE OR REPLACE STORAGE INTEGRATION s3_integration
TYPE = EXTERNAL_STAGE
STORAGE_PROVIDER = 'S3'
ENABLED = TRUE
STORAGE_AWS_ROLE_ARN = 'arn:aws:iam::123456789012:role/snowflake-data-loader'
STORAGE_ALLOWED_LOCATIONS = ('s3://your-company-data-bucket/transactions/');
After running this, Snowflake generates an AWS IAM ARN and External ID that you must add to your IAM role's trust policy. Run DESC INTEGRATION s3_integration; to find the values for STORAGE_AWS_IAM_USER_ARN and STORAGE_AWS_EXTERNAL_ID, then add them to your AWS role's trust policy.
Once the integration is configured, create the stage:
CREATE OR REPLACE STAGE transactions_s3_stage
STORAGE_INTEGRATION = s3_integration
URL = 's3://your-company-data-bucket/transactions/'
FILE_FORMAT = csv_standard;
Warning
Never put AWS access keys directly in a CREATE STAGE statement using CREDENTIALS = (AWS_KEY_ID = '...' AWS_SECRET_KEY = '...') in production. Use Storage Integrations with IAM roles instead. Credentials embedded in SQL end up in query history, logs, and version control history if you're not careful. Storage Integrations also make credential rotation much simpler.
GCS stages follow the same pattern. You'll need a GCS service account with the Storage Object Viewer role on your bucket:
CREATE OR REPLACE STORAGE INTEGRATION gcs_integration
TYPE = EXTERNAL_STAGE
STORAGE_PROVIDER = 'GCS'
ENABLED = TRUE
STORAGE_ALLOWED_LOCATIONS = ('gcs://your-company-bucket/events/');
After creating the integration, run DESC INTEGRATION gcs_integration; to find the STORAGE_GCP_SERVICE_ACCOUNT value. Grant that service account access to your GCS bucket in the Google Cloud Console (IAM & Admin → IAM, then add the service account with the Storage Object Viewer role on the specific bucket).
Then create the stage:
CREATE OR REPLACE STAGE events_gcs_stage
STORAGE_INTEGRATION = gcs_integration
URL = 'gcs://your-company-bucket/events/'
FILE_FORMAT = json_standard;
For Azure, you'll need a Blob Storage container and a Storage Account:
CREATE OR REPLACE STORAGE INTEGRATION azure_integration
TYPE = EXTERNAL_STAGE
STORAGE_PROVIDER = 'AZURE'
ENABLED = TRUE
AZURE_TENANT_ID = 'your-azure-tenant-id'
STORAGE_ALLOWED_LOCATIONS = ('azure://yourcompany.blob.core.windows.net/data/');
Again, DESC INTEGRATION azure_integration; gives you the STORAGE_AZURE_CONSENT_URL and STORAGE_AZURE_MULTI_TENANT_APP_NAME. Navigate to the consent URL to grant Snowflake permission to access your Azure storage, then create the stage:
CREATE OR REPLACE STAGE orders_azure_stage
STORAGE_INTEGRATION = azure_integration
URL = 'azure://yourcompany.blob.core.windows.net/data/orders/'
FILE_FORMAT = csv_standard;
Before loading data, always list the contents of your stage to verify connectivity and see what files are available:
LIST @transactions_s3_stage;
This returns a table showing the file names, sizes, modification dates, and MD5 hashes. If you get an error here, the problem is in your storage integration or IAM configuration — not your COPY INTO command. Catching this early saves time.
You can also query files directly from a stage without loading them into a table, which is useful for validation:
-- Inspect the first few rows of a CSV file in the stage
SELECT $1, $2, $3, $4
FROM @transactions_s3_stage/transactions_2024_03.csv.gz
LIMIT 10;
Snowflake refers to positional columns in staged files as $1, $2, $3, etc. This raw inspection is invaluable for checking that your file format is correct before you run a full load.
Tip
If your files are gzip-compressed (.csv.gz), Snowflake automatically decompresses them during both listing and querying. You don't need to specify compression separately — Snowflake detects it from the file extension.
Now for the main event. COPY INTO is Snowflake's bulk loading command. First, make sure you have a target table:
CREATE OR REPLACE TABLE raw.transactions (
transaction_id VARCHAR,
customer_id VARCHAR,
transaction_date TIMESTAMP,
amount NUMBER(12, 2),
currency VARCHAR(3),
status VARCHAR(20),
merchant_name VARCHAR(255)
);
Now load from the stage:
COPY INTO raw.transactions
FROM @transactions_s3_stage
FILE_FORMAT = (FORMAT_NAME = 'csv_standard')
ON_ERROR = 'CONTINUE'
PURGE = FALSE;
A few key parameters to understand:
ON_ERROR controls what happens when a row can't be parsed. 'CONTINUE' skips bad rows and loads everything else. 'ABORT_STATEMENT' (the default) rolls back the entire load if any error occurs. 'SKIP_FILE' skips the entire file containing the error. For initial exploration, CONTINUE is forgiving; for production, ABORT_STATEMENT or SKIP_FILE with a maximum error count is safer.
PURGE = FALSE means Snowflake will not delete the source files from your stage after loading. Leave this as FALSE unless you explicitly want Snowflake to manage file cleanup.
FORCE = FALSE (the default) means Snowflake tracks which files it has already loaded and won't reload them. This is enormously useful — it means running the same COPY INTO command twice is safe and idempotent. Set FORCE = TRUE only when you deliberately want to reload a file.
You don't have to load every file in a stage at once. You can target specific files:
-- Load a specific file
COPY INTO raw.transactions
FROM @transactions_s3_stage/transactions_2024_03.csv.gz
FILE_FORMAT = (FORMAT_NAME = 'csv_standard');
-- Load files matching a pattern
COPY INTO raw.transactions
FROM @transactions_s3_stage
PATTERN = '.*transactions_2024.*\.csv\.gz'
FILE_FORMAT = (FORMAT_NAME = 'csv_standard');
The PATTERN parameter accepts regular expressions, which gives you fine-grained control over which files to load. This is essential when your stage contains a mix of file types or date partitions and you only want a specific subset.
JSON data is best loaded into a VARIANT column first, then transformed with SQL or dbt:
CREATE OR REPLACE TABLE raw.events (
raw_event VARIANT,
loaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
);
COPY INTO raw.events (raw_event)
FROM @events_gcs_stage
FILE_FORMAT = (FORMAT_NAME = 'json_standard');
This approach — load raw JSON first, transform later — aligns well with the ELT vs ETL pattern that modern data stacks favor. Once the raw JSON is in Snowflake, you can use dbt to flatten and transform it, as covered in dbt Fundamentals.
Key insight
Snowflake's COPY INTO is designed for bulk file loading, not streaming individual rows. It shines with files in the megabyte-to-gigabyte range. If you need sub-minute data freshness from event streams, look into Snowflake Dynamic Tables or Kafka integration covered in the real-time ingestion pipeline guide.
After running COPY INTO, always check what happened:
-- View the most recent copy history for your table
SELECT *
FROM TABLE(INFORMATION_SCHEMA.COPY_HISTORY(
TABLE_NAME => 'TRANSACTIONS',
START_TIME => DATEADD(HOURS, -24, CURRENT_TIMESTAMP())
));
This returns one row per file processed, with columns including STATUS (LOADED, LOAD_FAILED, PARTIALLY_LOADED), ROWS_LOADED, ROWS_PARSED, ERRORS_SEEN, and crucially FIRST_ERROR and FIRST_ERROR_LINE. When you have partially loaded files, this is your first debugging tool.
You can also check a stage's load metadata directly:
SELECT *
FROM TABLE(INFORMATION_SCHEMA.STAGE_DIRECTORY_FILE_REGISTRATION_HISTORY(
STAGE_NAME => 'transactions_s3_stage'
));
Let's tie everything together with a realistic scenario. You're a data engineer at a retail company. Your fulfillment partner drops daily order files into an S3 bucket at s3://retail-partner-data/orders/. The files are gzip-compressed CSVs with a header row, comma-delimited, and named like orders_YYYYMMDD.csv.gz.
Step 1: Create a file format for the partner's CSV files, skipping the header row and treating empty strings as NULL.
Step 2: Create a named storage integration and external stage pointing to the S3 bucket path. (Use the storage integration pattern from the S3 section above.)
Step 3: Create a target table with appropriate columns: order_id VARCHAR, customer_email VARCHAR, order_date DATE, total_amount NUMBER(10,2), shipping_status VARCHAR.
Step 4: List the stage contents to verify connectivity, then inspect the first 5 rows of a file using positional column references.
Step 5: Run a COPY INTO command loading only files matching the pattern for March 2024 (.*orders_202403.*), with ON_ERROR = 'CONTINUE'.
Step 6: Query COPY_HISTORY to see how many rows were loaded and whether any errors occurred.
Step 7: Run the same COPY INTO command again. Verify that Snowflake reports the files as already loaded (0 rows loaded the second time) — this confirms the idempotency behavior.
If you don't have an actual S3 bucket, you can practice with an internal stage: create a named internal stage with CREATE STAGE practice_stage;, upload a local CSV using the SnowSQL PUT command, and proceed from Step 3 onward.
"File not found" or empty LIST results
Your storage integration trust policy is probably misconfigured. Run DESC INTEGRATION your_integration; and double-check that the ARN and External ID in your AWS IAM trust policy exactly match the values Snowflake generated. Even a trailing space will cause this to fail silently.
Data loads but columns contain NULL unexpectedly
Your file format options don't match the actual file. Use the positional column query (SELECT $1, $2, $3 FROM @your_stage/filename LIMIT 5;) to see the raw parsed values before loading. Common culprits: wrong delimiter, missing SKIP_HEADER, or the file uses \r\n line endings instead of \n (fix with RECORD_DELIMITER = '\r\n').
COPY INTO loads 0 rows and shows files as already loaded
Snowflake's metadata layer has recorded these files as previously loaded. If you need to reload (for example, the files have been updated), use FORCE = TRUE. If the files are genuinely new, check that the file names or ETags differ from previous loads.
Timestamp parsing failures
Timestamp format mismatches are extremely common. If you see errors like Timestamp 'MM/DD/YYYY HH:MI:SS' is not recognized, your file format's TIMESTAMP_FORMAT doesn't match the actual data. Query the raw stage data, copy an example timestamp value, and adjust the format string accordingly.
JSON loads fail with "value too long" or truncation errors If your VARIANT column seems to be truncating data, check whether you're accidentally loading into a VARCHAR column instead. VARIANT columns in Snowflake can hold up to 16 MB per value — if you're hitting that limit, your JSON events are unusually large and may need to be split upstream.
Warning
If you're running COPY INTO in a production pipeline, don't use ON_ERROR = 'CONTINUE' without also querying COPY_HISTORY afterward to alert on errors. Silent row-skipping can mean thousands of missing transactions that nobody notices until a downstream report is wrong. Consider integrating this check into your Airflow DAG as a post-load validation step.
You now have a complete picture of how Snowflake's loading layer works. Stages are named pointers to file locations — either in Snowflake's own managed storage or in cloud provider buckets you control. File Formats are reusable parsing configuration objects that tell Snowflake exactly how to interpret your files. The COPY INTO command bridges the two, loading files into tables while tracking what's already been processed for safe re-runs.
The pattern you've learned here — raw files in cloud storage → external stage → COPY INTO → raw table — is the foundation of most ELT pipelines. After data lands in raw tables, the transformation work begins. If you're using dbt to do that transformation, the dbt Fundamentals lesson is your natural next stop. For teams managing many ingestion sources and wanting to think more holistically about data architecture, Data Ingestion with Fivetran, Airbyte, and Custom Connectors covers the managed connector landscape that often works alongside direct stage loading.
As your pipelines grow, you'll want to think about orchestrating these loads on a schedule — running COPY INTO nightly as new files arrive. That's where connecting this to Airflow DAGs becomes essential. And once data is in your warehouse, data modeling patterns will help you think about how to structure it for analytics consumption.
The loading dock is now open. What's coming through it is up to you.