Repository navigation
Conversation
…= literal filters `FileScanConfig::add_filter_equivalence_info` turned every equality of the source's exact filter into an equivalence class. For `complex_expr = literal` that put the literal in a class, and normalization then replaced the literal inside `complex_expr` with the class's canonical expression. A partial aggregate that relied on the constant group key then failed `SanityCheckPlan`. Follow `FilterExec`: only an equality with a column on one side becomes an equivalence class, and any other equality is recorded as a constant. Closes apache#27287. Claude-Session: https://claude.ai/code/session_01USkuh48jV15LVKgyqXmCod
cetra3
added a commit
to pydantic/datafusion
that referenced
this pull request
Nov 10, 2026
…= literal filters Backport of apache#27288 (open), from its head 8c7f9b3. Claude-Session: https://claude.ai/code/session_01USkuh48jV15LVKgyqXmCod
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.
Posted by Claude (an AI assistant) on behalf of cetra3.
Which issue does this PR close?
Rationale for this change
With
datafusion.execution.parquet.pushdown_filters = true, a query that groups by aCASEkey and pins it withHAVINGfails planning with aSanityCheckPlanerror. See #27287 for adatafusion-clireproduction.The cause is in
FileScanConfig::add_filter_equivalence_info. It turns everyx = yconjunct of the source's exact filter into an equivalence class, includingcomplex_expr = literal. That puts the literal in a class.normalize_exprrewrites bottom-up, so every occurrence of the literal, including the one insidecomplex_expritself, becomes the canonical expression of the class. In #27287,b = 'y'inside theCASEbecomesb = <the CASE>. The partial aggregate requires its input ordered by the group key, becauseis_expr_constantfinds the key constant. But the normalized requirement no longer matches the class, soordering_satisfyrejects it.FilterExecalready avoids this.collect_columns_from_predicate_innerkeeps only pairs with a column on one side, with a comment that names this exact failure.FilterExecthen recordscomplex_expr = literalas a constant throughConstExpr::collect_predicate_constants. The scan path, from #25780, does not have the same guard. Since #26747, ordering checks also consult equivalent expressions, which is where the bisect in #27287 points.What changes are included in this PR?
add_filter_equivalence_info(datafusion/datasource/src/file_scan_config/mod.rs) followsFilterExec:ConstExpr::collect_predicate_constants, socomplex_expr = literalmakescomplex_expra constant without putting the literal in a class.Only the second kind of conjunct changes. I first added constants for every conjunct, as
FilterExecdoes. That changed one expected plan inpush_down_filter_regression.slt(group_clustering_mode=Partial([1])disappeared), so this PR leaves column equalities as they were.What is the testing strategy for this PR?
push_down_filter_regression.slt: the query from REGRESSION: SanityCheckPlan error for GROUP BY ... HAVING on a CASE key with parquet filter pushdown #27287, with a result assertion. It fails with theSanityCheckPlanerror without this change.datafusion-datasourceunit tests pass.Are there any user-facing changes?
The query shape in #27287 plans and runs. No public API changes.
🤖 Generated with Claude Code