Querying Metadata for Staged Files in Snowflake

To Nha Notes | June 8, 2023, 4:29 p.m.

Querying Metadata for Staged Files

Snowflake automatically generates metadata for files in internal (i.e. Snowflake) stages or external (Amazon S3, Google Cloud Storage, or Microsoft Azure) stages. This metadata is “stored” in virtual columns that can be:

Metadata Columns

Currently, the following metadata columns can be queried or copied into tables:

METADATA$FILENAME

Name of the staged data file the current row belongs to. Includes the path to the data file in the stage.

METADATA$FILE_ROW_NUMBER

Row number for each record in the staged data file.

METADATA$FILE_CONTENT_KEY

Checksum of the staged data file the current row belongs to.

METADATA$FILE_LAST_MODIFIED

Last modified timestamp of the staged data file the current row belongs to. Returned as TIMESTAMP_NTZ.

METADATA$START_SCAN_TIME

Start timestamp of operation for each record in the staged data file. Returned as TIMESTAMP_LTZ.

 

Reference

https://docs.snowflake.com/en/user-guide/querying-metadata