← Back to Pull requests

feat: expose bloom filter, page index and sorting metadata in parquet… #25638

Open
diegoQuinas opened this pull request with 172 lines diff across 3 files
View on GitHub
diegoQuinas diegoQuinas commented on Sep 23, 2026 00:41 UTC
Author

…_metadata

Add footer fields already present on ColumnChunkMetaData and RowGroupMetaData to the datafusion-cli parquet_metadata table function.

Which issue does this PR close?

This PR closes one of the three items of the issue #25499

What changes are included in this PR?

It changes datafusion-cli main and functions file, also it updates the docs for the new columns

What is the testing strategy for this PR?

This feature is covered by the unit tests and snapshot tests of datafusion-cli
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

Briefly describe how this PR is tested, and point to the specific tests you added. For example: 'This new feature is covered by the sqllogictest cases added in foo.slt'.

If this PR does not add tests, explain why. For example, if the change is already covered by existing tests, please mention it.

You should also check the codecov bot reply on this PR to confirm the changed code is exercised.
-->

Are there any user-facing changes?

Yes, there are user-facing changes that require documentation (also included in this PR)

No, no breaking changes to public APIs, (beware that the datafusion-cli will exponse more fields in the output)
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.

If there are any breaking changes to public APIs, please add the api change label.
-->

Diff: 172 lines (+132 / -40) across 3 files Reviewer: rgbuilds Review duration: 104785m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.44) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 172 lines diff across 3 files
0.44
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 5 substantive comment(s)
0.89
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
84%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.308
Real PR Conversation Timeline
10 items
codecov-commenter codecov-commenter commented on Sep 23, 2026 01:07 UTC
Contributor

Codecov Report


:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 82.79%. Comparing base (334f293) to head (91e6e55).

<details><summary>Additional details and impacted files</summary>

@@            Coverage Diff             @@
##             main   #25638      +/-   ##
==========================================
- Coverage   82.79%   82.79%   -0.01%     
==========================================
  Files        1149     1149              
  Lines      451645   451645              
  Branches   451645   451645              
==========================================
- Hits       373940   373929      -11     
- Misses      54929    54939      +10     
- Partials    22776    22777       +1     

</details>

:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
<details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    rgbuilds rgbuilds commented on code on Sep 24, 2026 06:13 UTC
    Code Review
    datafusion-cli/src/main.rs:1
    @@ -599,11 +599,11 @@ mod tests {
             let rbs = df.collect().await?;
     
             assert_snapshot!(batches_to_string(&rbs),@r#"
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    -        | filename                                                        | row_group_id | row_group_num_rows | row_group_num_columns | row_group_bytes | column_id | file_offset | num_values | path_in_schema | type       | stats_min | stats_max | stats_null_count | stats_distinct_count | stats_min_value | stats_max_value | compression        | encodings                | index_page_offset | dictionary_page_offset | data_page_offset | total_compressed_size | total_uncompressed_size |
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    -        | ../parquet-testing/data/data_index_bloom_encoding_stats.parquet | 0            | 14                 | 1                     | 163             | 0         | 4           | 14         | "String"       | BYTE_ARRAY | Hello     | today     | 0                |                      | Hello           | today           | GZIP(GzipLevel(6)) | [PLAIN, RLE, BIT_PACKED] |                   |                        | 4                | 152                   | 163                     |
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    +        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+-----------------+-------------------+-----------------------+
    +        | filename                                                        | row_group_id | row_group_num_rows | row_group_num_columns | row_group_bytes | column_id | file_offset | num_values | path_in_schema | type       | stats_min | stats_max | stats_null_count | stats_distinct_count | stats_min_value | stats_max_value | compression        | encodings                | index_page_offset | dictionary_page_offset | data_page_offset | total_compressed_size | total_uncompressed_size | bloom_filter_offset | bloom_filter_length | column_index_offset | column_index_length | offset_index_offset | offset_index_length | sorting_columns | row_group_ordinal | row_group_file_offset |
    +        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+-----------------+-------------------+-----------------------+
    +        | ../parquet-testing/data/data_index_bloom_encoding_stats.parquet | 0            | 14                 | 1                     | 163             | 0         | 4           | 14         | "String"       | BYTE_ARRAY | Hello     | today     | 0                |                      | Hello           | today           | GZIP(GzipLevel(6)) | [PLAIN, RLE, BIT_PACKED] |                   |                        | 4                | 152                   | 163                     | 192                 |                     | 156                 | 25                  | 181                 | 11                  |                 | 0                 | 4                     |

    The updated snapshots exercise several of the new footer fields (bloom_filter_offset=192, column/offset index offset+length, row_group_ordinal, row_group_file_offset), but bloom_filter_length and sorting_columns stay NULL/empty in both fixtures. That is expected for data_index_bloom_encoding_stats.parquet — parquet-testing documents it as having Bloom/page-index metadata without bloom_filter_length.

    Because both Some paths stay unobserved, a regression that always pushed None for bloom_filter_length (lines 449–450) or sorting_columns (lines 457–458) would still pass.

    parquet-testing already has fixtures for the missing cases:

  • data/data_index_bloom_encoding_with_length.parquet — same file with bloom_filter_length populated

  • data/sort_columns.parquet — two row groups with writer-declared sorting columns
  • Would it be useful to add a focused SELECT/snapshot against those files so extraction of the length (i32 → i64) and format!("{cols:?}") formatting are actually locked in?

    diegoQuinas diegoQuinas commented on code on Sep 24, 2026 19:34 UTC
    Code Review
    datafusion-cli/src/main.rs:1
    @@ -599,11 +599,11 @@ mod tests {
             let rbs = df.collect().await?;
     
             assert_snapshot!(batches_to_string(&rbs),@r#"
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    -        | filename                                                        | row_group_id | row_group_num_rows | row_group_num_columns | row_group_bytes | column_id | file_offset | num_values | path_in_schema | type       | stats_min | stats_max | stats_null_count | stats_distinct_count | stats_min_value | stats_max_value | compression        | encodings                | index_page_offset | dictionary_page_offset | data_page_offset | total_compressed_size | total_uncompressed_size |
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    -        | ../parquet-testing/data/data_index_bloom_encoding_stats.parquet | 0            | 14                 | 1                     | 163             | 0         | 4           | 14         | "String"       | BYTE_ARRAY | Hello     | today     | 0                |                      | Hello           | today           | GZIP(GzipLevel(6)) | [PLAIN, RLE, BIT_PACKED] |                   |                        | 4                | 152                   | 163                     |
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    +        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+-----------------+-------------------+-----------------------+
    +        | filename                                                        | row_group_id | row_group_num_rows | row_group_num_columns | row_group_bytes | column_id | file_offset | num_values | path_in_schema | type       | stats_min | stats_max | stats_null_count | stats_distinct_count | stats_min_value | stats_max_value | compression        | encodings                | index_page_offset | dictionary_page_offset | data_page_offset | total_compressed_size | total_uncompressed_size | bloom_filter_offset | bloom_filter_length | column_index_offset | column_index_length | offset_index_offset | offset_index_length | sorting_columns | row_group_ordinal | row_group_file_offset |
    +        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+-----------------+-------------------+-----------------------+
    +        | ../parquet-testing/data/data_index_bloom_encoding_stats.parquet | 0            | 14                 | 1                     | 163             | 0         | 4           | 14         | "String"       | BYTE_ARRAY | Hello     | today     | 0                |                      | Hello           | today           | GZIP(GzipLevel(6)) | [PLAIN, RLE, BIT_PACKED] |                   |                        | 4                | 152                   | 163                     | 192                 |                     | 156                 | 25                  | 181                 | 11                  |                 | 0                 | 4                     |

    >> Would it be useful to add a focused SELECT/snapshot against those files so extraction of the length (i32 → i64) and format!("{cols:?}") formatting are actually locked in?

    Okay, of course. I'll add the focused snapshot

    rgbuilds rgbuilds approved these changes on Sep 25, 2026 04:45 UTC
    Approved Reviewer

    Thanks for adding the positive-path coverage for bloom_filter_length and sorting_columns. That addresses my earlier comment. I reviewed the updated diff and test snapshots, and the CLI test job passed on the current PR head. Looks good to me.

    nuno-faria nuno-faria commented on code on Oct 10, 2026 18:53 UTC
    Code Review
    datafusion-cli/src/functions.rs:1
    @@ -363,6 +363,15 @@ impl TableFunctionImpl for ParquetMetadataFunc {
                 Field::new("data_page_offset", DataType::Int64, true),
                 Field::new("total_compressed_size", DataType::Int64, true),
                 Field::new("total_uncompressed_size", DataType::Int64, true),
    +            Field::new("bloom_filter_offset", DataType::Int64, true),
    +            Field::new("bloom_filter_length", DataType::Int64, true),
    +            Field::new("column_index_offset", DataType::Int64, true),
    +            Field::new("column_index_length", DataType::Int64, true),
    +            Field::new("offset_index_offset", DataType::Int64, true),
    +            Field::new("offset_index_length", DataType::Int64, true),
    +            Field::new("sorting_columns", DataType::Utf8, true),
    +            Field::new("row_group_ordinal", DataType::Int64, true),
    +            Field::new("row_group_file_offset", DataType::Int64, true),

    Since these metrics are based on the row group, it might be better to move them near to the other row group metrics (i.e., after row_group_bytes).

    nuno-faria nuno-faria commented on code on Oct 10, 2026 18:53 UTC
    Code Review
    datafusion-cli/src/functions.rs:1
    @@ -430,6 +449,19 @@ impl TableFunctionImpl for ParquetMetadataFunc {
                     data_page_offset_arr.push(column.data_page_offset());
                     total_compressed_size_arr.push(column.compressed_size());
                     total_uncompressed_size_arr.push(column.uncompressed_size());
    +                bloom_filter_offset_arr.push(column.bloom_filter_offset());
    +                bloom_filter_length_arr
    +                    .push(column.bloom_filter_length().map(|v| v as i64));
    +                column_index_offset_arr.push(column.column_index_offset());
    +                column_index_length_arr
    +                    .push(column.column_index_length().map(|v| v as i64));
    +                offset_index_offset_arr.push(column.offset_index_offset());
    +                offset_index_length_arr
    +                    .push(column.offset_index_length().map(|v| v as i64));
    +                sorting_columns_arr
    +                    .push(row_group.sorting_columns().map(|cols| format!("{cols:?}")));
    +                row_group_ordinal_arr.push(row_group.ordinal().map(|v| v as i64));

    Is there a difference between the ordinal and the existing row_group_id?

    nuno-faria nuno-faria commented on code on Oct 10, 2026 18:59 UTC
    Code Review
    datafusion-cli/src/main.rs:1
    @@ -609,11 +609,51 @@ mod tests {
             let rbs = df.collect().await?;
     
             assert_snapshot!(batches_to_string(&rbs),@r#"
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    -        | filename                                                        | row_group_id | row_group_num_rows | row_group_num_columns | row_group_bytes | column_id | file_offset | num_values | path_in_schema | type       | stats_min | stats_max | stats_null_count | stats_distinct_count | stats_min_value | stats_max_value | compression        | encodings                | index_page_offset | dictionary_page_offset | data_page_offset | total_compressed_size | total_uncompressed_size |
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    -        | ../parquet-testing/data/data_index_bloom_encoding_stats.parquet | 0            | 14                 | 1                     | 163             | 0         | 4           | 14         | "String"       | BYTE_ARRAY | Hello     | today     | 0                |                      | Hello           | today           | GZIP(GzipLevel(6)) | [PLAIN, RLE, BIT_PACKED] |                   |                        | 4                | 152                   | 163                     |
    -        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+
    +        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+-----------------+-------------------+-----------------------+
    +        | filename                                                        | row_group_id | row_group_num_rows | row_group_num_columns | row_group_bytes | column_id | file_offset | num_values | path_in_schema | type       | stats_min | stats_max | stats_null_count | stats_distinct_count | stats_min_value | stats_max_value | compression        | encodings                | index_page_offset | dictionary_page_offset | data_page_offset | total_compressed_size | total_uncompressed_size | bloom_filter_offset | bloom_filter_length | column_index_offset | column_index_length | offset_index_offset | offset_index_length | sorting_columns | row_group_ordinal | row_group_file_offset |
    +        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+-----------------+-------------------+-----------------------+
    +        | ../parquet-testing/data/data_index_bloom_encoding_stats.parquet | 0            | 14                 | 1                     | 163             | 0         | 4           | 14         | "String"       | BYTE_ARRAY | Hello     | today     | 0                |                      | Hello           | today           | GZIP(GzipLevel(6)) | [PLAIN, RLE, BIT_PACKED] |                   |                        | 4                | 152                   | 163                     | 192                 |                     | 156                 | 25                  | 181                 | 11                  |                 | 0                 | 4                     |
    +        +-----------------------------------------------------------------+--------------+--------------------+-----------------------+-----------------+-----------+-------------+------------+----------------+------------+-----------+-----------+------------------+----------------------+-----------------+-----------------+--------------------+--------------------------+-------------------+------------------------+------------------+-----------------------+-------------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+-----------------+-------------------+-----------------------+
    +        "#);
    +
    +        Ok(())
    +    }
    +
    +    /// `bloom_filter_length` and `sorting_columns` are absent from the other
    +    /// fixtures. These files populate them so a regression that always emits
    +    /// NULL still fails.
    +    #[tokio::test]
    +    async fn test_parquet_metadata_bloom_length_and_sorting_columns()
    +    -> Result<(), DataFusionError> {
    +        let ctx = SessionContext::new();
    +        ctx.register_udtf("parquet_metadata", Arc::new(ParquetMetadataFunc {}));
    +
    +        let sql = "SELECT path_in_schema, bloom_filter_offset, bloom_filter_length \
    +            FROM parquet_metadata('../parquet-testing/data/data_index_bloom_encoding_with_length.parquet')";
    +        let df = ctx.sql(sql).await?;
    +        let rbs = df.collect().await?;
    +        assert_snapshot!(batches_to_string(&rbs), @r#"
    +        +----------------+---------------------+---------------------+
    +        | path_in_schema | bloom_filter_offset | bloom_filter_length |
    +        +----------------+---------------------+---------------------+
    +        | "String"       | 253                 | 2064                |
    +        +----------------+---------------------+---------------------+
    +        "#);
    +
    +        let sql = "SELECT row_group_id, column_id, path_in_schema, sorting_columns \
    +            FROM parquet_metadata('../parquet-testing/data/sort_columns.parquet') \
    +            ORDER BY row_group_id, column_id";
    +        let df = ctx.sql(sql).await?;
    +        let rbs = df.collect().await?;
    +        assert_snapshot!(batches_to_string(&rbs), @r#"
    +        +--------------+-----------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
    +        | row_group_id | column_id | path_in_schema | sorting_columns                                                                                                                                |
    +        +--------------+-----------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------+
    +        | 0            | 0         | "a"            | [SortingColumn { column_idx: 0, descending: true, nulls_first: true }, SortingColumn { column_idx: 1, descending: false, nulls_first: false }] |

    I think the current sorting_columns is difficult to read. To me at least I would prefer the column names instead. E.g.:
    [SortingColumn { column_idx: 0, descending: true, nulls_first: true }, SortingColumn { column_idx: 1, descending: false, nulls_first: false }]
    vs
    col1 DESC NULLS FIRST, col2 ASC

    nuno-faria nuno-faria commented on Oct 10, 2026 19:01 UTC
    Reviewer

    Thanks @diegoQuinas, I have some requests below.
    cc: @kumarUjjawal @alamb since you've reviewed the other PR.

    github-actions[bot] github-actions[bot] commented on Oct 26, 2026 01:28 UTC
    Bot

    Marked as draft after 14 days without activity: merge conflicts.

    Please address these items and mark Ready for review when ready.

    Reviewers
    Assignees
    diegoQuinas diegoQuinas
    Labels
    risk: low confidence: 84.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.8% (MEDIUM) · Higher = larger blast radius
    43.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.9% · Lower = rushed or shallow review
    84.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.6% · Safe to merge
    6.6%