Repository navigation
Cherry-pick apache/datafusion#27099 - #218
Merged
LiaCastaneda merged 1 commit intoNov 19, 2026
Merged
Conversation
…y are combined with (apache#27099) - Closes apache#14632. - Part of apache#27517, which explains the background and lists all the cases. A struct literal combined with a struct column fails once the plan goes through Substrait: ```sql -- s: List<Struct{a, b}> SELECT coalesce(s, []) FROM t; ``` ``` No function matches the given name and argument types 'coalesce(List(Struct("a": Utf8, "b": Utf8)), List(Struct("c0": Utf8, "c1": Utf8)))' ``` Substrait types inside expressions carry no struct field names, so the consumer names the literal's fields `c0, c1, ...`, while the column keeps its real names. DataFusion matches struct fields by name, so it can't combine the two (see apache#27517 for why the names can't be carried in the plan). When the consumer combines a struct literal with a struct column, the literal takes the column's field names, position by position, at every nesting level. Substrait matches struct fields by position, so the plan keeps its meaning. Only names and field metadata change. - Where it applies: function and window function arguments, operators, `CASE` results, `IN` lists, `Nested::List` elements, and set operation inputs (also under `LIMIT`/`ORDER BY`/`DISTINCT` and in nested set operations). apache#27517 has the full table. - Function calls are only renamed when they don't type-check otherwise: `coalesce(s, [])` needs a common type, while `named_struct('l', s, 'r', <literal>)` keeps its arguments apart, so its literal is left alone. - `roundtrip_logical_plan.rs`: a round-trip test for each case in the list above, including the apache#14632 query; the ones that need another producer's plan shape build or edit the plan directly. - `consumer_integration.rs`: a hand-written plan shaped like another producer's, `transform(coalesce(zones, []), x -> ...)`, executed and its rows checked. Each new test fails without the change; the rest of the Substrait tests still pass. Substrait plans that combine struct literals with struct columns now load and run. One behavior change: a struct literal whose fields are in a different order than the column's used to fail, and now gets its values by position (see the limitation in apache#27517). No API changes. (cherry picked from commit 3d46e42)
toutane
approved these changes
Nov 19, 2026
LiaCastaneda
deleted the
lia.castaneda/cherry-pick/apache-pr-27099-20261119
branch
November 19, 2026 10:52
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## branch-55 #218 +/- ##
===========================================
Coverage 81.21% 81.21%
===========================================
Files 1112 1112
Lines 390276 390677 +401
Branches 390276 390677 +401
===========================================
+ Hits 316950 317302 +352
- Misses 54414 54441 +27
- Partials 18912 18934 +22 ☔ 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.
cherry-picks apache#27099
Adapted to branch-55, which lacks three upstream changes the PR was written on top of:
SubstraitConsumerContextparameter: dropped from the calls the PR adds.intersect_rel:set_rel.rskeeps usingLogicalPlanBuilder::intersect, as branch-55 does today.The struct literal renaming logic and tests are unchanged.
cargo test -p datafusion-substraitand clippy pass.