Skip to content

test: cover mixed predicate parquet pruning - #27658

Open
rgbuilds wants to merge 2 commits into
apache:mainfrom
rgbuilds:test/parquet-mixed-predicate-pruning
Open

rgbuilds wants to merge 2 commits into
apache:mainfrom
rgbuilds:test/parquet-mixed-predicate-pruning

Conversation

@rgbuilds

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

#27415 reports that enabling datafusion.execution.collect_statistics could lose Parquet row-group pruning when a predicate combined expressions supported by statistics with an expression that statistics could not evaluate. For example:

body = 'x'
OR (
  body IS NULL
  AND tid = 1
  AND array_element(seps, 1) = ''
)

For a file where body is entirely NULL and tid is always 9, the supported predicates prove that no row can match. The non-prunable array_element term must be handled conservatively as "may match" at its own subtree, without discarding useful information from the supported sibling predicates.

The issue reproduces on the release identified in #27415, but it no longer reproduces on current main. The file-statistics pruning added by #26441 now removes the impossible file before its Parquet opener runs when statistics collection is enabled. Without collected file statistics, the existing Parquet footer path still prunes the impossible row group.

As a result, an additional production-code fix does not appear necessary on current main. This PR adds focused regression coverage for the original predicate and documents the expected behavior of both pruning paths.

What changes are included in this PR?

This PR adds prune_mixed_supported_and_unsupported_predicate_with_file_statistics to the Parquet row-group pruning integration tests.

The test creates three single-row-group Parquet files:

  1. matches: the supported predicates and array_element comparison all match. The file must be retained and the query returns its row.
  2. unsupported_does_not_match: the supported predicates can match, but the array_element comparison is false. Statistics cannot prove that, so the file must be retained and normal row filtering later removes the row.
  3. cannot_match: body is entirely NULL and tid is always 9, while the array_element comparison is true. The supported predicates alone prove that the file cannot match, so the unsupported expression must not prevent pruning.

The query runs with collect_statistics both disabled and enabled. It first checks all three files together and then checks each file independently. The individual checks ensure aggregate metrics cannot hide an incorrect implementation that prunes the conservatively retained file while retaining the actually impossible file.

The assertions cover:

  • Concrete query results for each scenario.
  • Files opened.
  • Row groups retained or pruned by Parquet statistics.
  • Complete removal of the Parquet scan when collected file statistics eliminate the only input file during planning.

No production code or public API is changed.

What is the testing strategy for this PR?

The new regression test exercises the exact mixed prunable/non-prunable predicate under both values of collect_statistics and verifies query correctness as well as pruning behavior.

The following targeted checks pass:

cargo test -p datafusion --test parquet_integration \
  row_group_pruning::prune_mixed_supported_and_unsupported_predicate_with_file_statistics \
  -- --nocapture

cargo fmt --all

cargo clippy -p datafusion --all-targets --all-features -- -D warnings

git diff --check

Are there any user-facing changes?

No. Query results, public APIs, and configuration behavior are unchanged. Current main already performs the desired pruning through the file-statistics path introduced by #26441; this PR protects that behavior with focused regression coverage.

@github-actions github-actions Bot added the core Core DataFusion crate label Nov 22, 2026
@adriangb

Copy link
Copy Markdown
Contributor

can we make these SLT test, please?

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) and removed core Core DataFusion crate labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Row group pruning with collect_statistics = true is still lost when the predicate has a non-prunable term (follow-up to #24769)

2 participants