To Nha Notes | June 8, 2023, 4:29 p.m.
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:
Queried using a standard SELECT statement.
Loaded into a table, along with the regular data columns, using COPY INTO <table>. For general information about querying staged data files, see Querying Data in Staged Files.
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.