Skip to content

Teach row group pruning about struct field predicates#21003

Open
friendlymatthew wants to merge 1 commit intoapache:mainfrom
pydantic:friendlymatthew/struct-field-row-group-pruning
Open

Teach row group pruning about struct field predicates#21003
friendlymatthew wants to merge 1 commit intoapache:mainfrom
pydantic:friendlymatthew/struct-field-row-group-pruning

Conversation

@friendlymatthew
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

This PR enables Parquet row group pruning for predicates on struct fields like WHERE s['value']> 5

Previously, the pruning predicate system only understood top level column references. When it encountered a struct field access via get_field, it marked the expression as unhandled and conservatively kept every row group, even though Parquet stores valid min/max stats for each leaf column in the file metadata. This meant queries filtering on struct fields always read all row groups, missing a significant optimization opportunity on struct heavy tables (like Variant!)

This optimization introduces PruningColumn which wraps a Column that carries an optional field path for nested struct access. The pruning expression builder now recognizes get_Field expressions, extracts the field path, and threads it through the statistics lookup pipeline

On the Parquet side, RowGroupPruningStatistics resolves the field path to the corresponding leaf column index in the Parquet schema and uses apache/arrow-rs#9540 to fetch the correct row group stats

Copy link
Contributor Author

@friendlymatthew friendlymatthew left a comment

Choose a reason for hiding this comment

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

self review

Comment on lines +55 to +71
impl From<Column> for PruningColumn {
fn from(column: Column) -> Self {
Self {
column,
field_path: vec![],
}
}
}

impl From<&Column> for PruningColumn {
fn from(column: &Column) -> Self {
Self {
column: column.clone(),
field_path: vec![],
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you can see from the diff of this PR, it introduces a lot of the same breaking change where we once accepted a Column and now require a PruningColumn

Hopefully these convenience methods help

Comment on lines +624 to +628
return Ok(StatisticsConverter::from_column_index(
leaf_idx,
arrow_field,
self.parquet_schema,
)?);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@friendlymatthew friendlymatthew force-pushed the friendlymatthew/struct-field-row-group-pruning branch from 7873e80 to 55ef323 Compare March 17, 2026 16:19
@github-actions github-actions bot added common Related to common crate datasource Changes to the datasource crate labels Mar 17, 2026
@mbutrovich mbutrovich self-requested a review March 18, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate datasource Changes to the datasource crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support row group pruning for struct field predicates

1 participant