Skip to content

test: add struct field pruning tests - #27876

Open
adriangb wants to merge 2 commits into
apache:mainfrom
adriangb:struct-field-pruning-tests
Open

adriangb wants to merge 2 commits into
apache:mainfrom
adriangb:struct-field-pruning-tests

Conversation

@adriangb

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Predicates on struct fields such as s['a'] > 5 do not prune Parquet row groups or pages today. This PR records that behavior in tests. The follow-up PR #27736 adds the pruning and updates the expected output. Its diff then shows the effect of the change directly.

What changes are included in this PR?

This PR is tests only. It does not change any behavior.

  • datafusion/sqllogictest/test_files/parquet_struct_field_pruning.slt writes Parquet files with struct columns. It records the EXPLAIN ANALYZE row group and page pruning metrics for predicates on struct fields.
  • datafusion/core/tests/parquet/struct_field_pruning.rs checks that the scan keeps a row group when a struct field has no null count statistic.

What is the testing strategy for this PR?

The PR consists of the new tests. They pass on main and record its current behavior.

Are there any user-facing changes?

No.

🤖 Generated with Claude Code

Predicates on struct fields such as `s['a'] > 5` do not prune Parquet
row groups or pages today. These tests record that behavior. A later
change adds the pruning and updates the expected output, so its diff
shows the effect.

The tests add a sqllogictest file with EXPLAIN ANALYZE pruning metrics.
They also add a core integration test for a struct field without a
null count statistic.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@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.

thank you


/// Writes `s: {a: Int64}` with rows `{a: 1}` and `{a: null}` in one row
/// group. The footer keeps the min and max of `s.a`, but not its null count.
fn struct_file_without_null_count() -> NamedTempFile {

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.

what is the purpose of hand constructing a file without null statistics?

It might be easier to understand if the test wrote a file with null statistics and then updated the statistics and rewrite the file (not sure if this is possible with the parquet API today)

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.

Also in theory we could add this setup file to the slt harness runner (or check it in) so that the tests could be entirely .slt

A reviewer asked why the test builds a file without a null count by hand. The doc comment gives the reason and the method.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants