liveBook · Manning

Metadata$file_row_number

As explained in Snowflake Data Engineering

metadata$file_row_number is a Snowflake staged-file metadata column containing the source row number within its file.

metadata$file_row_number is a Snowflake staged-file metadata column that records the row number of each record within its source file. It can be selected during ingestion and retained in a target table when source ordering matters. section 2.3

Use the column to:

  • Identify a record’s position in its individual source file. section 2.3 section 3.4.1
  • Preserve source ordering information when loading records into a target table. section 2.3
  • Expose file-position metadata alongside parsed columns in an external table. section 3.4.1

Selecting the source row number

Query staged records with their source position, for example: SELECT $1, $2, $3, $4, $5, metadata$file_row_number AS source_row_number FROM @ORDERS_STAGE; section 2.3

How Snowflake Data Engineering covers it

How deep it goes
Defines the per-file row number and applies it in staged-file queries and external-table metadata, without deeper implementation detail.
Examples
Uses staged-file SELECT queries and external-table definitions as the concrete application patterns.
What it assumes
Assumes familiarity with Snowflake stages, staged-file queries, and file formats; introduces metadata columns through those operations.
What you can do after
Apply it via SQL to retain and inspect each record’s position within its source file.
How it connects
Connects staged files, target tables, external tables, file formats, and metadata$filename.

This explainer was generated by Manning's knowledge graph from the text of Snowflake Data Engineering. The section links point to the parts of the book it draws on.