- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2026 04:20 AM
Good Day @smoortema ,
Delta stores per-file statistics (min, max, null count, row count) for columns enabled for data skipping. You can read those directly from the transaction log.
Step 1: Get the table location
DESCRIBE DETAIL catalog.schema.my_table;
Copy the location value — you'll need it in the next query.
Step 2: Query file-level stats for your clustering columns
WITH raw_log AS (
SELECT
add.path AS file_path,
add.stats AS stats_json
FROM json.`s3://bucket/path/my_table/_delta_log/*.json`
WHERE add IS NOT NULL
),
parsed AS (
SELECT
file_path,
from_json(
stats_json,
'numRecords LONG,
minValues MAP<STRING,STRING>,
maxValues MAP<STRING,STRING>,
nullCount MAP<STRING,LONG>'
) AS s
FROM raw_log
)
SELECT
file_path,
s.numRecords AS rows_in_file,
CAST(s.minValues['c1'] AS <type>) AS min_c1,
CAST(s.maxValues['c1'] AS <type>) AS max_c1,
CAST(s.minValues['c2'] AS <type>) AS min_c2,
CAST(s.maxValues['c2'] AS <type>) AS max_c2,
CAST(s.minValues['c3'] AS <type>) AS min_c3,
CAST(s.maxValues['c3'] AS <type>) AS max_c3
FROM parsed;
Replace s3://bucket/path/my_table with your actual location, and <type> with the real SQL types for each column (e.g. INT, DATE, TIMESTAMP).
You'll get one row per data file showing the min/max range for each clustering column.
Worth flagging: stats only exist for columns configured for data skipping — by default the first N columns, or those set explicitly via delta.dataSkippingStatsColumns. Columns with types like VARIANT won't have min/max stats.
Hope this helps, Louis.