Skip to content

[SQL] Fix lambda handling of struct fields #6642

Merged
mihaibudiu merged 1 commit into
feldera:mainfrom
mihaibudiu:issue6354
Jul 16, 2026
Merged

[SQL] Fix lambda handling of struct fields #6642
mihaibudiu merged 1 commit into
feldera:mainfrom
mihaibudiu:issue6354

Conversation

@mihaibudiu

Copy link
Copy Markdown
Contributor

Fixes #6354

This uses a new Calcite version, which includes a couple of PRs fixing this bug. This PR only contains validation tests.

Checklist

  • Unit tests added/updated

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>

@mythical-fred mythical-fred left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, clean fix for #6354. Bumps CALCITE_NEXT_COMMIT to pick up the upstream lambda-field-resolution fix, plus two small companion changes:

  • SqlToRelCompiler.java: overrides allowLambdaClosure() to return false in the HAVING-alias validator context, so lambda-capture semantics don't fire in a place that never had them. Consistent with keeping alias resolution scoped.
  • DBSPZSetExpression.castRecursive: guards the array branch with expression.is(DBSPArrayExpression.class) and falls back to a plain SqlUnsafe cast when the source isn't a literal array. Previously this would have thrown a ClassCastException inside .to(DBSPArrayExpression.class); the new fallback matches how other type branches handle non-literal inputs.

The regression test in Regression3Tests.java#issue6453 exercises the reported failure (TRANSFORM(arr, x -> x.name) where arr is ROW(...) ARRAY) across six well-chosen shapes: single-element, multi-element, empty (via the ARRAY_REMOVE(ARRAY[NULL], NULL) idiom for ROW-typed empty arrays), array with NULL element, repeated values, and a longer array. Also runs the same expected output with the explicit (x).name field-access form, which pins down that both parses now resolve the field the same way. Good coverage for a fix whose logic mostly lives upstream in Calcite.

Commit is signed off, one commit, no AI trailers. CI main check is green at f0079bbd; mergeable_state=blocked is the usual approvals gate rather than a failure.

APPROVE.

@mihaibudiu
mihaibudiu requested a review from lalithsuresh July 16, 2026 15:59
@mihaibudiu
mihaibudiu added this pull request to the merge queue Jul 16, 2026
Merged via the queue into feldera:main with commit 1ad73ae Jul 16, 2026
1 check passed
@mihaibudiu
mihaibudiu deleted the issue6354 branch July 16, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SQL] Lambda function does not correctly resolve field names

3 participants