Skip to content

fix(sql): resolve dotted field access on lambda parameters (#27088) - #27232

Open
Hrushikesh-ramilla wants to merge 1 commit into
apache:mainfrom
Hrushikesh-ramilla:fix-lambda-field-access
Open

Hrushikesh-ramilla wants to merge 1 commit into
apache:mainfrom
Hrushikesh-ramilla:fix-lambda-field-access

Conversation

@Hrushikesh-ramilla

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

When an identifier path such as e.rule_action is evaluated in the body of a lambda function (where e is a struct lambda parameter), the SQL planner produced Schema error: No field named e.rule_action.

This happened because sql_compound_identifier_to_expr only searched the input schema and outer query schemas for e.rule_action (treating e as a table or qualifier), falling back to a relation-qualified column Column::new("e", "rule_action"). Unlike sql_identifier_to_expr (which checks planner_context.lambda_parameters() first), sql_compound_identifier_to_expr never checked for active lambda parameters.

What changes are included in this PR?

  • In datafusion/sql/src/expr/identifier.rs: updated sql_compound_identifier_to_expr to check planner_context.lambda_parameters() for ids[0] before attempting table-schema resolution.
  • For matching lambda parameters, constructs Expr::LambdaVariable and iterates over any remaining nested identifiers (ids[1..]), resolving each field access through try_plan_field_access.
  • In datafusion/sql/src/expr/mod.rs: widened try_plan_field_access visibility to pub(super).
  • In datafusion/sqllogictest/test_files/array/array_transform.slt: added test coverage for dotted field access, expressions over dotted fields, and multi-level nested struct field access.

What is the testing strategy for this PR?

  • Added regression test cases in datafusion/sqllogictest/test_files/array/array_transform.slt.
  • Verified all 607 tests in datafusion-sql pass.
  • Verified sqllogictests -- array_transform passes.

Are there any user-facing changes?

No.

@github-actions github-actions Bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels Nov 8, 2026
@nuno-faria nuno-faria added the Prolific Author author opened PRs or issues in more than 20 repositories in the last 30 days label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Prolific Author author opened PRs or issues in more than 20 repositories in the last 30 days sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL planner doesn't resolve dotted field access on lambda parameters

2 participants