What you will be able to do
- Create an external table over staged files and keep its metadata in step with the stage
- Create an Iceberg table and choose its EXTERNAL_VOLUME and CATALOG
- Choose between a view, a secure view and a materialized view for a given requirement
1.External tables over staged files
An external table lets you query files in an external stage as if they were a Snowflake table, without loading them. The files stay in your cloud storage, and Snowflake neither stores nor manages that stage. What Snowflake keeps is file-level metadata such as file names and version identifiers. External tables can read any format that COPY INTO <table> supports, except XML.
You can create an external table without knowing the schema of the files, because every external table has the same three built-in columns:
| Column | What it holds |
|---|---|
| VALUE | A VARIANT column holding one row of the external file; SELECT * always returns it |
| METADATA$FILENAME | Name and stage path of the staged file the row came from |
| METADATA$FILE_ROW_NUMBER | Row number of the record within its staged file |
If you know the schema, you can add virtual columns defined as expressions over VALUE and the pseudocolumns. The file data must then match the declared types, which gives you type checking over files you don't control. Columns can be added and dropped with ALTER TABLE, but the three built-in columns can't be dropped. Masking policies and row access policies work on external tables as they do on native ones.
External tables can only be read. You can query and join them and build views on them, but INSERT, UPDATE and DELETE are not allowed. Storage versioning such as S3 versioning isn't supported. A file that fails during a scan is skipped, so a query can return partial results without failing. Queries are usually slower than on native tables. For repeated or complex queries, put a materialized view on top. For Parquet data that needs the best performance, Iceberg tables are the recommended alternative.
| Format | Recommended size range |
|---|---|
| Parquet files | 256 - 512 MB |
| Parquet row groups | 16 - 256 MB |
| All other supported file formats | 16 - 256 MB |
Checkpoint 1 of 7· Check yourself
A team keeps raw event files in an S3 external stage and exposes them as an external table. Some records are malformed, and the role that owns the external table runs an UPDATE against it to fix them. What happens?
External tables can only be read. Owning the table doesn't allow INSERT, UPDATE or DELETE, and Snowflake never writes back to the staged files. You can still query and join the table and build views on it.
“External tables are read-only. You can’t perform data manipulation language (DML) operations on external tables.”Source: docs.snowflake.com
Checkpoint 2 of 7· Exam question
An analytics team wants to run SQL directly over Parquet files in an Amazon S3 external stage without loading them into Snowflake. Select TWO statements that accurately describe external tables.(Select 2)
Correct answers: D, E — Each row exposes a VALUE variant column holding the file record, and METADATA$FILENAME identifies the staged file it came from.; A materialized view can be created over the external table to speed up repeated queries against the staged files in S3.
- A. Incorrect. External tables are read-only, so DML statements are rejected and the staged files can only be changed outside Snowflake.
- B. Incorrect. The data stays in your cloud storage outside Snowflake's control, so Time Travel and Fail-safe do not apply to external table contents.
- C. Incorrect. External tables only store file metadata in Snowflake, and each query still reads the files from the external stage location.
- D. Correct. External tables always return the semi-structured VALUE column plus pseudocolumns such as METADATA$FILENAME, which let queries trace rows back to files.
- E. Correct. Materialized views are supported on external tables and store precomputed results inside Snowflake, which improves performance for repeated queries.
Sources1
2.Partitioning and refreshing external table metadata
Partitioning is the main way to make external tables faster. It requires files organised under logical paths, such as by date or country. A partition column is defined as an expression that parses METADATA$FILENAME, so a query that filters on it reads only the matching slice of files instead of the whole data set.
CREATE EXTERNAL TABLE
<table_name>
( <part_col_name> <col_type> AS <part_expr> )
[ , ... ]
[ PARTITION BY ( <part_col_name> [, <part_col_name> ... ] ) ]
..You choose how partitions are added when you create the table, and you can't change it later. With expression-based partitions, Snowflake adds partitions whenever the metadata is refreshed. With PARTITION_TYPE = USER_SPECIFIED, the owner adds each partition with ALTER EXTERNAL TABLE … ADD PARTITION, an approach often used to stay in sync with a Hive or AWS Glue metastore. User-specified tables can't be refreshed at all, automatically or manually.
A refresh compares the metadata with the stage path. New files are added, changed files are updated, and files that have gone are removed. Snowflake refreshes once when the table is created. After that you have two options, and each is billed differently:
| Method | How it is triggered | How it is billed |
|---|---|---|
| Automatic | Cloud event notifications, such as S3 event notifications, GCS Pub/Sub or Azure Event Grid | Appears as Snowpipe charges; grows with the number of files added |
| Manual | ALTER EXTERNAL TABLE … REFRESH | Small cloud services charge; Delta Lake external tables need a virtual warehouse |
On S3 the setup steps run in this order:
- Create a named stage on the bucket.
- Create the external table on that stage.
- Refresh it manually, which also checks the table definition.
- Configure the bucket's event notification.
- Refresh manually once more to pick up files that arrived in between.
- Grant query access to the other roles that need it.
Delta Lake external tables (TABLE_FORMAT = DELTA) have their own limits. They support only manual refresh and are due to be deprecated. Snowflake recommends migrating them to Iceberg tables.
Checkpoint 3 of 7· Put it in order
You are setting up an external table on an S3 bucket so that its metadata refreshes automatically from event notifications. Put the setup steps in the order Snowflake gives them.
- 1.Run ALTER EXTERNAL TABLE … REFRESH manually again to pick up files that arrived in between
- 2.Create a named stage that references the S3 bucket
- 3.Run ALTER EXTERNAL TABLE … REFRESH manually, which also checks the table definition
- 4.Create the external table on that named stage
- 5.Grant query access on the external table to the other roles that need it
- 6.Configure an event notification for the S3 bucket
The table needs a stage before it can exist, and the first manual refresh checks the definition. Files can land after that refresh but before the event notification is in place, so a second manual refresh closes that gap. After it, S3 notifications keep the metadata in sync automatically.
“to synchronize the metadata with any changes that occurred after Step 3. Thereafter, the S3 event notifications trigger the metadata refresh automatically.”Source: docs.snowflake.com
Checkpoint 4 of 7· Check yourself
An external table was created with PARTITION_TYPE = USER_SPECIFIED so it stays in sync with an AWS Glue catalog. New files have landed in the stage, and an engineer runs ALTER EXTERNAL TABLE … REFRESH to register them. What is the result?
Tables with user-specified partitions support neither automatic nor manual refresh, so the owner adds partitions with ADD PARTITION. The partitioning method is fixed when the table is created and can't be changed afterwards.
“Attempting to manually refresh this type of external table produces a user error.”Source: docs.snowflake.com
Sources1
3.Iceberg tables: choosing EXTERNAL_VOLUME and CATALOG
Iceberg tables suit data lakes that you can't, or don't want to, store inside Snowflake. They give that data the performance and query behaviour of Snowflake tables. They follow the Apache Iceberg open table format over Parquet files, which brings ACID transactions, schema evolution, hidden partitioning and table snapshots. Unlike external tables, they are full tables you can write to, and two choices made at creation decide how much of Snowflake they get.
EXTERNAL_VOLUME decides where the files are stored. With EXTERNAL_VOLUME = SNOWFLAKE_MANAGED, Snowflake stores and manages the files and bills you for the storage, and permanent tables get Fail-safe. If you name your own external volume, an account-level object that holds the storage credentials (see External volumes), the files live in your S3, GCS or Azure storage. Your cloud provider then bills the storage, protecting the data is your job, and there is no Fail-safe. One volume can serve many tables.
CATALOG decides who tracks the table's current metadata. If Snowflake is the catalog, you get a Snowflake-managed Iceberg table. It has full platform support, Snowflake handles compaction and other maintenance, and it can be replicated. If an external catalog such as AWS Glue, Snowflake Open Catalog or another remote Iceberg REST catalog owns the table, you need a catalog integration, and Snowflake's platform support is limited.
CREATE ICEBERG TABLE my_delta_table_1 BASE_LOCATION = 'delta-ext-table-1' EXTERNAL_VOLUME = 'delta_migration_ext_vol' CATALOG = 'delta_catalog_integration';Snowflake builds the table's full storage path by appending BASE_LOCATION to the volume's STORAGE_BASE_URL. That means one volume rooted at s3://my-bucket/ can serve tables under several subfolders.
| Aspect | Snowflake as catalog | External catalog |
|---|---|---|
| Read and write access | Yes | Yes |
| Snowflake platform support | Full | Limited |
| Catalog integration needed | No (only to sync with Open Catalog) | Yes |
| Replication for tables | Supported | Not listed |
| Snowflake Open Catalog | Sync the table so other engines can query it | Query or write tables managed by Open Catalog |
Checkpoint 5 of 7· Fill the gap
This statement creates an Iceberg table over Delta files in S3. The table's current metadata is tracked by an external catalog through the catalog integration delta_catalog_integration, not by Snowflake. Which parameter goes in the blank?
CREATE ICEBERG TABLE my_delta_table_1 BASE_LOCATION = 'delta-ext-table-1' EXTERNAL_VOLUME = 'delta_migration_ext_vol' ? = 'delta_catalog_integration';CATALOG decides who tracks the table's current metadata. When an external catalog owns the table, CATALOG names a catalog integration. EXTERNAL_VOLUME handles storage, and BASE_LOCATION is appended to the volume's STORAGE_BASE_URL. TABLE_FORMAT and PARTITION_TYPE are external-table parameters.
Source: docs.snowflake.comCheckpoint 6 of 7· Check yourself
Your security team requires Fail-safe protection for a new permanent Iceberg table, and nobody wants to manage a cloud storage bucket for it. Which creation choice meets both requirements?
EXTERNAL_VOLUME decides who stores the files and whether Fail-safe applies. With SNOWFLAKE_MANAGED, Snowflake stores and bills for the files, and permanent tables get Fail-safe. With your own external volume, protecting the data is your job and there is no Fail-safe. That holds whichever catalog tracks the metadata.
“Snowflake storage (EXTERNAL_VOLUME = SNOWFLAKE_MANAGED): Snowflake stores and manages the files for you. Permanent tables are protected by Fail-safe.”Source: docs.snowflake.com
4.Views, secure views and materialized views
A view is a saved query, and the two variants change different things. Secure changes who can see how the view works. Materialized changes when the query runs.
A standard view has two weaknesses for sensitive data. First, other users can see its definition through various commands and interfaces. Second, some internal optimizations read the underlying base tables, and user code such as a UDF could use that to expose rows the view is meant to hide. A secure view removes both. Only users granted the role that owns the view can see its definition and details, and the risky optimizations are switched off. The cost is speed, because secure views can run more slowly. Use them for views that exist to protect data, not for views created only to make queries easier to write. Both standard and materialized views can be made secure.
A materialized view stores its results in advance, and the optimizer can redirect queries on the base table to it. In this case Snowflake can rewrite the query internally as a query on mv2 that filters only on column_2 = Y, because every row in mv2 already matches column_1 = X. Aggregates work in a similar way: a materialized view grouped by two columns can answer a query grouped by just one of them. Materialized views do come with limitations on what you can create, and Snowflake notes these may change in future versions.
Materialized views pay off most on external tables. External tables are slow to query, and a materialized view on one can be much faster for a frequent or complex query. It reflects only the files the external table's metadata knows about, so keep that metadata refreshed, or the view will miss newly arrived files.
Checkpoint 7 of 7· Check yourself
Analysts query a materialized view built on an external table over an S3 stage. Yesterday's files are in the bucket, but their rows don't appear in the view. Nobody has configured event notifications for the bucket. What fixes this?
A materialized view on an external table includes only the files that the external table's metadata knows about. Without event notifications, a manual ALTER EXTERNAL TABLE … REFRESH must register the new files before the view can show their rows. Making the view secure only hides its definition and turns off some optimizations. A standard view would read the same out-of-date metadata.
“Refresh the file-level metadata in any queried external tables so that your materialized views reflect the current set of files”Source: docs.snowflake.com
Sources
(4)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“The external stage is not part of Snowflake, so Snowflake doesn’t store or manage the stage.”
↩︎ External tables over staged files“External tables can access data stored in any format that the COPY INTO <table> command supports, except XML.”
↩︎ External tables over staged files“A VARIANT type column that represents a single row in the external file.”
↩︎ External tables over staged files“the file is skipped and scanning continues on the next file”
↩︎ External tables over staged files“To improve query performance, you can use a materialized view based on an external table.”
↩︎ External tables over staged files“You can protect an external table by using a masking policy and a row access policy.”
↩︎ External tables over staged files“After an external table is created, the method by which partitions are added can’t be changed.”
↩︎ Partitioning and refreshing external table metadata“Automatically refreshing an external table with user-defined partitions isn’t supported.”
↩︎ Partitioning and refreshing external table metadata“By default, the metadata is refreshed automatically when the object is created.”
↩︎ Partitioning and refreshing external table metadata“This overhead charge appears as Snowpipe charges in your billing statement”
↩︎ Partitioning and refreshing external table metadata“manual refreshes of external tables enhanced with Delta Lake rely on user-managed compute resources (that is, a virtual warehouse)”
↩︎ Partitioning and refreshing external table metadata“This feature is still supported but will be deprecated in a future release.”
↩︎ Partitioning and refreshing external table metadata“To determine the full storage location for the table, Snowflake appends the BASE_LOCATION to the STORAGE_BASE_URL of the external volume”
↩︎ Iceberg tables: choosing EXTERNAL_VOLUME and CATALOG“Refresh the file-level metadata in any queried external tables so that your materialized views reflect the current set of files”
↩︎ Views, secure views and materialized views“External tables are read-only. You can’t perform data manipulation language (DML) operations on external tables.”
↩︎ Exam trap 1“External tables are read-only. You can’t perform data manipulation language (DML) operations on external tables.”
↩︎ Checkpoint“to synchronize the metadata with any changes that occurred after Step 3. Thereafter, the S3 event notifications trigger the metadata refresh automatically.”
↩︎ Checkpoint“Attempting to manually refresh this type of external table produces a user error.”
↩︎ Checkpoint - 2.
“Snowflake storage (EXTERNAL_VOLUME = SNOWFLAKE_MANAGED): Snowflake stores and manages the files for you.”
↩︎ Iceberg tables: choosing EXTERNAL_VOLUME and CATALOG“Snowflake doesn’t provide Fail-safe for these tables, and your cloud provider bills you for storage.”
↩︎ Iceberg tables: choosing EXTERNAL_VOLUME and CATALOG“Snowflake handles all lifecycle maintenance, such as compaction, for the table.”
↩︎ Iceberg tables: choosing EXTERNAL_VOLUME and CATALOG“An Iceberg table that uses an external catalog provides limited Snowflake platform support.”
↩︎ Iceberg tables: choosing EXTERNAL_VOLUME and CATALOG“you need a catalog integration if your table is managed by AWS Glue”
↩︎ Iceberg tables: choosing EXTERNAL_VOLUME and CATALOG“Snowflake storage (EXTERNAL_VOLUME = SNOWFLAKE_MANAGED): Snowflake stores and manages the files for you. Permanent tables are protected by Fail-safe.”
↩︎ Checkpoint - 3.
“the view definition and details are visible only to authorized users (that is, users who are granted the role that owns the view)”
↩︎ Views, secure views and materialized views“Secure views do not utilize these optimizations, ensuring that users have no access to the underlying data.”
↩︎ Views, secure views and materialized views“Secure views can execute more slowly”
↩︎ Views, secure views and materialized views“This topic covers concepts and syntax for defining views and materialized views as secure.”
↩︎ Views, secure views and materialized views“Secure views should not be used for views that are defined solely for query convenience”
↩︎ Exam trap 2 - 4.
“the materialized view’s definition already requires that all rows match column_1 = X.”
↩︎ Views, secure views and materialized views“These are current limitations; some of them might be removed or changed in future versions.”
↩︎ Views, secure views and materialized views