Skip to content

Cherry-pick apache/datafusion#27099 - #218

Merged
LiaCastaneda merged 1 commit into
branch-55from
lia.castaneda/cherry-pick/apache-pr-27099-20261119
Nov 19, 2026
Merged

LiaCastaneda merged 1 commit into
branch-55from
lia.castaneda/cherry-pick/apache-pr-27099-20261119

Conversation

@LiaCastaneda

Copy link
Copy Markdown

cherry-picks apache#27099

Adapted to branch-55, which lacks three upstream changes the PR was written on top of:

  • SPDX license headers: kept branch-55's headers.
  • SubstraitConsumerContext parameter: dropped from the calls the PR adds.
  • Nullability-aware intersect_rel: set_rel.rs keeps using LogicalPlanBuilder::intersect, as branch-55 does today.

The struct literal renaming logic and tests are unchanged. cargo test -p datafusion-substrait and clippy pass.

…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)
@LiaCastaneda
LiaCastaneda merged commit 6f1eb95 into branch-55 Nov 19, 2026
65 of 67 checks passed
@LiaCastaneda
LiaCastaneda deleted the lia.castaneda/cherry-pick/apache-pr-27099-20261119 branch November 19, 2026 10:52
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.07350% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.21%. Comparing base (b0023d3) to head (e464d9b).
⚠️ Report is 1 commits behind head on branch-55.

Files with missing lines Patch % Lines
...ubstrait/src/logical_plan/consumer/expr/literal.rs 81.85% 24 Missing and 19 partials ⚠️
...substrait/src/logical_plan/consumer/rel/set_rel.rs 82.60% 13 Missing and 11 partials ⚠️
...substrait/src/logical_plan/consumer/expr/nested.rs 84.84% 2 Missing and 3 partials ⚠️
.../src/logical_plan/consumer/expr/scalar_function.rs 92.00% 1 Missing and 1 partial ⚠️
...src/logical_plan/consumer/expr/singular_or_list.rs 75.00% 0 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants