file_metadata Column Reference
Trace, filter, and deduplicate rows in nested IDS Lakehouse tables by using the subfields of the file_metadata struct column in Amazon Athena or Databricks SQL
file_metadata is a STRUCT column on every nested IDS Lakehouse table. It records where each row came from: which Intermediate Data Schema (IDS) JSON file produced it, which IDS type and version that file used, which organization owns it, and which pipeline run staged it into the Lakehouse. There is one logical entry per source IDS JSON file version.
Use file_metadata to filter a query to a specific IDS type, restrict results to one organization, trace a row back to its source file, or isolate everything a single pipeline run staged.
NOTEThis reference covers
file_metadataon nested IDS Lakehouse tables. Datacubes Lakehouse tables handle this information differently. As of TDP v4.4.0, theirfile_metadatacolumn isNULLfor all newly inserted rows, and four top-level columns replace it:file_metadata_file_id,file_metadata_ids_path,file_metadata_created_at, andfile_metadata_created_at_timestamp. If you query datacubes Lakehouse tables, use those columns instead. For more information, see Datacubes Lakehouse Tables Best Practices.
Access file_metadata Subfields
To access a subfield, use dot notation. The syntax is identical in Amazon Athena (Trino) and Databricks SQL.
SELECT
file_metadata.file_id,
file_metadata.ids_slug,
file_metadata.ids_version,
file_metadata.created_at
FROM my_nested_table
LIMIT 10;Field Reference
| Field | Description | Example |
|---|---|---|
event_type | The staging event that produced the row. Only insert or delete. | insert |
created_at | The time the IDS JSON file was created in the data lake, taken from the file pointer's lastModified value and falling back to the fileinfo createdAt value. This isn't the time the row was inserted into the Lakehouse. | 2025-04-29T06:35:03.000Z |
created_at_timestamp | The created_at value converted to seconds since the Unix epoch. | 1745457601 |
file_id | The file ID of the source IDS JSON file. Changes with every file version. | 9514962a-d504-4716-80f0-92c3d4df9c05 |
file_path | The fileKey of the source IDS JSON file. This is an object key in the data lake, not a filesystem path. | pharmacorp-uat/e9a73de2-.../akta_run_88.json/0.json |
ids_path | An identifier for the source IDS JSON file that stays the same across file versions, in the format tenants/{subdomain}/orgs/{org_slug}/tables/{table_name}/files/{fileKey}. Use it to group or deduplicate versions of the same logical file. | tenants/pharmacorp/orgs/pharmacorp-uat/tables/lcuv_empower_v17/files/.../0.json |
ids_namespace | The namespace of the IDS that produced the row. | common |
ids_slug | The slug of the IDS that produced the row. | lcuv-empower |
ids_version | The version of the IDS that produced the row. | v17.0.0 |
ids_schema_path | The object storage path to the IDS schema.json file. | s3://.../ids/common/lcuv-empower/v17.0.0/schema.json |
ids_parquet_file_path | The Lakehouse staging path for the parquet file that holds the IDS content. Identified by the type=ids segment. | s3://.../type=ids/.../data.parquet |
datacubes_parquet_file_path | The Lakehouse staging path for the parquet file that holds the datacubes content. Identical to ids_parquet_file_path except that the segment reads type=datacubes. | s3://.../type=datacubes/.../data.parquet |
subdomain | The subdomain of the TDP deployment that staged the row. | pharmacorp |
org_slug | The slug of the organization that owns the source file. | pharmacorp-uat |
table_name | The name of the nested Lakehouse table that contains the row. | lcuv_empower_v17 |
task_script_execution_timestamp | The time the ids-to-lakehouse task script ran, in seconds since the Unix epoch. This is the closest available value to a processing-time watermark. | 1745908544 |
pipeline_id | The ID of the ids-to-lakehouse pipeline that staged the row. | ea802af3-c605-46e6-bd95-0af5d1ec247f |
workflow_id | The ID of the ids-to-lakehouse workflow that staged the row. | 11b50a55-9fa0-4291-8983-29a00c2cac51 |
transaction_id | A UUID generated for each ids-to-lakehouse task script execution. | a0c87fd7-652d-47b0-a8ef-12b07ec561d0 |
Field Behavior to Know Before You Query
Three fields behave in ways that are easy to misread. Review these before you build queries on them.
event_type Never Contains update
event_type describes the staging event, not the outcome of the Lakehouse merge. When you reprocess a file through a raw-to-ids pipeline, the new IDS version stages as a new insert row. The Lakehouse job merges that row over the previous data, but the surviving row still reads insert.
IMPORTANTDon't write queries that expect an
updatevalue. To keep only live rows, filter onfile_metadata.event_type = 'insert'.
created_at Isn't a Change Watermark
created_at and created_at_timestamp record when the IDS JSON file was created in the data lake. The value advances when a new IDS version is created, but pipeline reruns and backfills change it in ways that break incremental reads.
WARNINGDon't use
created_atorcreated_at_timestampas a "changed since last check" watermark. Usetask_script_execution_timestampinstead, which reflects processing time. For an example, see Use a Processing-Time Watermark.
datacubes_parquet_file_path Is Populated Even Without Datacubes
ids_parquet_file_path and datacubes_parquet_file_path differ in exactly one path segment: type=ids against type=datacubes. The TDP populates datacubes_parquet_file_path for every row, including rows from IDSs that produce no datacubes. In that case, no file exists at the path.
Query Examples
The following examples cover the most common ways to use file_metadata in a query.
1. Filter to an IDS Type and Version
The syntax is identical in Athena and Databricks SQL.
WHERE file_metadata.ids_slug = 'lcuv-empower'
AND file_metadata.ids_version = 'v17.0.0'2. Filter to an Organization
WHERE file_metadata.subdomain = 'pharmacorp'
AND file_metadata.org_slug = 'pharmacorp-uat'3. Exclude Deletes
WHERE file_metadata.event_type = 'insert'4. Filter by IDS File Creation Time
Use created_at for readable string ranges, or created_at_timestamp for numeric math.
-- Amazon Athena
WHERE from_unixtime(file_metadata.created_at_timestamp)
>= timestamp '2025-04-01 00:00:00'-- Databricks SQL
WHERE timestamp_seconds(file_metadata.created_at_timestamp)
>= timestamp '2025-04-01 00:00:00'This filters on when the IDS file was created, not when the row landed in the Lakehouse. For more information, see created_at Isn't a Change Watermark.
5. Use a Processing-Time Watermark
To select rows that a pipeline processed since your last read, filter on task_script_execution_timestamp.
-- Amazon Athena
WHERE from_unixtime(file_metadata.task_script_execution_timestamp)
>= from_unixtime(:last_run_epoch)-- Databricks SQL
WHERE timestamp_seconds(file_metadata.task_script_execution_timestamp)
>= timestamp_seconds(:last_run_epoch)6. Trace a Row Back to Its Source File
SELECT
file_metadata.file_id, -- unique per IDS file version
file_metadata.file_path, -- the IDS JSON fileKey
file_metadata.ids_path -- stable across file versions
FROM my_nested_table;7. Deduplicate Across File Versions
file_id changes with every IDS version, but ids_path stays the same for the same logical file. If a query returns more than one row per logical file, keep the row with the most recent processing time. The syntax is identical in Athena and Databricks SQL.
SELECT * FROM (
SELECT *,
ROW_NUMBER() OVER (
PARTITION BY file_metadata.ids_path
ORDER BY file_metadata.task_script_execution_timestamp DESC
) AS rn
FROM my_nested_table
)
WHERE rn = 1;8. Isolate a Pipeline, Workflow, or Task Script Run
WHERE file_metadata.pipeline_id = 'ea802af3-c605-46e6-bd95-0af5d1ec247f'
OR file_metadata.workflow_id = '11b50a55-9fa0-4291-8983-29a00c2cac51'
OR file_metadata.transaction_id = 'a0c87fd7-652d-47b0-a8ef-12b07ec561d0'Because the TDP generates transaction_id for each ids-to-lakehouse task script execution, it's the most precise way to isolate everything a single run staged.
Related Resources
- Data Lakehouse Architecture
- Create Lakehouse Tables
- Query Lakehouse Tables
- Transform Data by Using Tetraflow Pipelines
- TDP Athena SQL Table Structure
Documentation Feedback
Do you have questions about our documentation or suggestions for how we can improve it? Start a discussion in TetraConnect Hub. For access, see Access the TetraConnect Hub.
NOTEFeedback isn't part of the official TetraScience product documentation. TetraScience doesn't warrant or make any guarantees about the feedback provided, including its accuracy, relevance, or reliability. All feedback is subject to the terms set forth in the TetraConnect Hub Community Guidelines.
Updated 1 day ago

