Conversation
…er pushdown Add `datafusion/core/tests/fuzz_cases/leaf_pushdown_fuzz.rs`. It generates seeded SQL over struct typed tables and runs each query two times: with `datafusion.optimizer.enable_leaf_expression_pushdown` on and off. The two results must agree. A second test compares `datafusion.execution.parquet.pushdown_filters` on and off over the same tables written to Parquet. Shapes that fail on `main` today are behind a named `const` switch with a link to the issue. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The swap shape (b AS a, a AS b) fails for a different reason than the same-name computed column: it is apache#25446, which is open, while apache#25414 has a fix. With one switch for both, the fix for the first one cannot be verified by this test. The swap shape now has its own switch, off until the issue is fixed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #25453 +/- ##
==========================================
- Coverage 82.33% 82.33% -0.01%
==========================================
Files 1137 1137
Lines 432498 432498
Branches 432498 432498
==========================================
- Hits 356115 356107 -8
- Misses 54844 54851 +7
- Partials 21539 21540 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
ExtractLeafExpressionsandPushDownLeafProjections(the optiondatafusion.optimizer.enable_leaf_expression_pushdown, defaulttrue) move expressions such ass['b']out of a filter, sort, limit, aggregate or join, and push them towards the scan. The rules resolve columns by name. When a plan holds two columns with the same name, or a column that is computed from a column of the same name, the rules can drop a projection or merge the wrong pair. The user sees wrong rows or a planning error, with the default configuration.The rules had 10 bug fixes since February 2026. Users or an ad-hoc fuzzer found all of them. The 520 sqllogictest files found none, because they do not build these shapes.
A differential test finds this class cheaply: run the same query with the option on and off, and compare the rows. This is a fixed-seed differential regression suite rather than a fuzzer that accumulates coverage; the seeds are the same on every run so a failure is reproducible with one command. Bugs of the class this test covers:
optimize_projectionsfails with "No field named ..." when join keys containget_field(ExtractLeafExpressions) #22895:optimize_projectionsfails with "No field named ..." when the join keys hold aget_field. Planning error.push_down_leaf_projectionsfails for a self join. Planning error.The harness reproduces the two open bugs today. With
INCLUDE_SAME_NAME_ALIAS_SHAPES = true, 526 of 3000 seeds fail (476 planning errors, 50 silent wrong results). WithINCLUDE_FALSE_BRANCH_UNION_SHAPES = true, 404 of 3000 seeds fail.What changes are included in this PR?
One new file,
datafusion/core/tests/fuzz_cases/leaf_pushdown_fuzz.rs.The generator builds SQL over three wide tables and one narrow table. Every table has
Int32columns, aUtf8column and twoStructcolumns. Two struct fields have the same name as a top level column. The generated shapes are:s['f']inSELECT,WHERE,ORDER BY,GROUP BY,HAVING,JOIN ONand underLIMIT.INandEXISTSsubqueries,UNION ALL.named_struct(...)built in a subquery and read above.arrow_field(a)used bare and through['f']in the same query.random()in a subquery projection, read two times above. The two runs cannot be compared with each other, so the query reports its own consistency in one boolean column.Each query runs in two
SessionContexts built from the same batches. The rows are sorted and compared. An error on one side only is a failure. An error on both sides is a skip, and the test fails if more than 30% of the seeds skip.Three shapes fail on
maintoday. Each one is behind a namedconstswitch with the link to its issue, so this PR is green:INCLUDE_SAME_NAME_ALIAS_SHAPESfor Wrong results: leaf expression pushdown removes a computed column that has the same name as its input column #25414.INCLUDE_FALSE_BRANCH_UNION_SHAPESfor fix: resolve pass-through columns against the input when merging an extraction projection #25412.Flip the switch to
truewhen the fix lands.What is the testing strategy for this PR?
This PR is a test. Three test entry points:
leaf_pushdown_fuzzleaf_pushdown_parquet_fuzzleaf_pushdown_parquet_schema_evolutionleaf_pushdown_fuzz_extendedcargo test --profile ci -p datafusion --features extended_tests --test fuzz -- leaf_pushdownThe whole
fuzz_casestree is already behind theextended_testsfeature, so the short tests run in the extended job together with the long one.Every case comes from a seed. A failure prints the seed, the SQL and both result sets, and names the command that replays it:
Are there any user-facing changes?
No.
Update: the swap shape (
b AS a, a AS b) fails for a different reason than the same-name computed column. It is #25446, which is open. It now has its own switch,INCLUDE_SWAP_ALIAS_SHAPES, so the fix for #25414 can be verified withINCLUDE_SAME_NAME_ALIAS_SHAPESalone. On a branch with #25445 and #25412 merged and both of those switches on, the only remaining failures are 24 of 250 seeds, all the swap shape with the ambiguity error.Known gaps from independent review, to be addressed in this PR: the generic generator only emits pass-through spellings (
c,q.c,q.c AS c,c AS c), so renames and computed columns come only from the hardcoded same-name arm;all_truepasses on an empty result; and the wholefuzz_casestree runs only in the merge-queueextended_testsjob, so the short run should move out from behind that gate.Part of the leaf-pushdown EPIC: #25459
🤖 Generated with Claude Code