[SQL] Fix lambda handling of struct fields #6642
Conversation
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
mythical-fred
left a comment
There was a problem hiding this comment.
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: overridesallowLambdaClosure()to returnfalsein theHAVING-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 withexpression.is(DBSPArrayExpression.class)and falls back to a plainSqlUnsafecast when the source isn't a literal array. Previously this would have thrown aClassCastExceptioninside.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.
Fixes #6354
This uses a new Calcite version, which includes a couple of PRs fixing this bug. This PR only contains validation tests.
Checklist