Skip to content

introduce StatisticsConverter::from_column_index - #9540

Merged
alamb merged 3 commits into
apache:mainfrom
pydantic:friendlymatthew/statistics-converter-from-col-index
Jun 22, 2026
Merged

introduce StatisticsConverter::from_column_index#9540
alamb merged 3 commits into
apache:mainfrom
pydantic:friendlymatthew/statistics-converter-from-col-index

Conversation

@friendlymatthew

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

This PR adds a constructor StatisticsConverter::from_column_index that bypasses schema resolution and accepts a pre-resolved leaf column index directly

Datafusion's pruning predicate system needs stats for struct fields to support predicate pushdown on expressions like WHERE my_struct.field > 67. Datafusion already resolves struct fields to Parquet leaf indices elsewhere, but has no way to pass that index to StatisticsConverter

@github-actions github-actions Bot added the parquet Changes to the parquet crate label Mar 11, 2026
@friendlymatthew

Copy link
Copy Markdown
Contributor Author

Related to apache/datafusion#20871

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @friendlymatthew -- sorry for the delayed review

})
}

/// Create a new `StatisticsConverter` from a Parquet leaf column index directly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @friendlymatthew -- this makes sense to me.

However, I think we need at least some basic tests showing this working (aka create a Parquet file with a struct column and then read the statistics out of it using this API)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. You may also like this! apache/datafusion#21003 (comment)

@alamb
alamb marked this pull request as draft March 18, 2026 19:27
@alamb

alamb commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Marking as draft as I think this PR is no longer waiting on feedback and I am trying to make it easier to find PRs in need of review. Please mark it as ready for review when it is ready for another look

@friendlymatthew
friendlymatthew force-pushed the friendlymatthew/statistics-converter-from-col-index branch from a987c9e to 5d327c7 Compare June 22, 2026 08:19
@friendlymatthew
friendlymatthew force-pushed the friendlymatthew/statistics-converter-from-col-index branch from 5d327c7 to 99d05b1 Compare June 22, 2026 08:23
@friendlymatthew
friendlymatthew marked this pull request as ready for review June 22, 2026 08:24
@friendlymatthew

Copy link
Copy Markdown
Contributor Author

cc @kumarUjjawal @alamb

) -> Result<Self> {
if parquet_column_index >= parquet_schema.columns().len() {
return Err(arrow_err!(format!(
"Parquet column index {} out of bounds, max {}",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max reads as "highest allowed index", but it's actually the column count (count 1 → only index 0 is valid).

Comment thread parquet/src/arrow/arrow_reader/statistics.rs
@@ -2899,6 +2899,52 @@ mod test {
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we extend the test to add:

  • a non-Int32 leaf (e.g. Date64 or Decimal) to confirm physical_type is threaded correctly, and
  • an out-of-bounds index to cover the new error branch.
  • A page-level check (data_page_mins/maxes) would be nice to have

@kumarUjjawal kumarUjjawal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @friendlymatthew

Looks good 👍

Comment thread parquet/src/arrow/arrow_reader/statistics.rs
@alamb

alamb commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for the review and help @kumarUjjawal 🙏 -- very much appreciated

Thank you for the API and tests @friendlymatthew

@alamb
alamb merged commit eba6d1d into apache:main Jun 22, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StatisticsConverter does not support nested fields (e.g. struct fields)

3 participants