Skip to content

fix: cast lambda variables to their declared type instead of erroring… - #186

Merged
LiaCastaneda merged 1 commit into
branch-55from
lia/cherry-pick-lambda-dict-encoding-fix
Sep 25, 2026
Merged

LiaCastaneda merged 1 commit into
branch-55from
lia/cherry-pick-lambda-dict-encoding-fix

Conversation

@LiaCastaneda

Copy link
Copy Markdown

Cherry-picks apache#25418

…apache#25418)

## Which issue does this PR close?

- Closes apache#25411

## Rationale for this change

`create_physical_expr` required an `Expr::LambdaVariable`'s field to
equal the planning schema's field and returned a plan error otherwise.
The two can legitimately differ when a plan producer records a type that
Substrait cannot express, such as dictionary encoding or a string view
(Utf8view), since the recorded field and the field derived by
`lambda_parameters` come from independent sources.

## What changes are included in this PR?

Cast the variable to the recorded type instead, so the declared type is
enforced rather than asserted. This is the same approach already used
for `ScalarFunction` arguments, which the `TypeCoercion` analyzer casts
to their coerced types instead of requiring them to match. Incompatible
types still fail, as a cast error.

## What is the testing strategy for this PR?

I added

- Unit tests covering dictionary-encoded and `Utf8View` list elements
with the lambda variable declared as plain `Utf8`, plus plan-shape tests
pinning that the cast is inserted on a mismatch and omitted when the
types already agree.
- A Substrait integration test with a plan whose read schema declares a
dictionary-encoded list element while the lambda carries its own plain
`Utf8` parameter type.

## Are there any user-facing changes?

No, this is a bug fix

(cherry picked from commit 5da95ac)
@codecov-commenter

codecov-commenter commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.30159% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.18%. Comparing base (7269807) to head (125f720).

Files with missing lines Patch % Lines
datafusion/functions-nested/src/array_any_match.rs 91.07% 3 Missing and 2 partials ⚠️
datafusion/optimizer/src/analyzer/type_coercion.rs 33.33% 0 Missing and 2 partials ⚠️
datafusion/expr/src/higher_order_function.rs 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           branch-55     #186   +/-   ##
==========================================
  Coverage      81.18%   81.18%           
==========================================
  Files           1111     1111           
  Lines         387373   387430   +57     
  Branches      387373   387430   +57     
==========================================
+ Hits          314496   314552   +56     
+ Misses         54374    54372    -2     
- Partials       18503    18506    +3     

☔ 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.

@LiaCastaneda

Copy link
Copy Markdown
Author

ci is failing bc of unrelated connection issues

thread 'test_s3_url_fallback' (10705) panicked at datafusion-cli/tests/cli_integration.rs:672:25:
called `Result::unwrap()` on an `Err` value: "Failed to start MinIO container. Ensure Docker is running and accessible: failed to pull the image 'minio/minio:RELEASE.2025-02-28T09-55-16Z', error: Docker responded with status code 404: pull access denied for minio/minio, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"

@LiaCastaneda
LiaCastaneda merged commit ae427aa into branch-55 Sep 25, 2026
68 of 70 checks passed
@LiaCastaneda
LiaCastaneda deleted the lia/cherry-pick-lambda-dict-encoding-fix branch September 25, 2026 09:28
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