Skip to content

Support dotted field access on struct lambda parameters in SQL exprs - #25177

Draft
shehab-ali wants to merge 1 commit into
apache:mainfrom
shehab-ali:shehab/lambda-var
Draft

Support dotted field access on struct lambda parameters in SQL exprs#25177
shehab-ali wants to merge 1 commit into
apache:mainfrom
shehab-ali:shehab/lambda-var

Conversation

@shehab-ali

@shehab-ali shehab-ali commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • Closes #.

Rationale for this change

Struct-valued lambda parameters cannot currently be accessed using dotted field syntax. For example, the following query fails because record.rule_action is resolved as a table-qualified column instead of field access on the lambda parameter:

SELECT array_transform(
  records,
  record -> record.rule_action
);

What changes are included in this PR?

When a compound identifier begins with an active lambda parameter, resolve the root as a lambda variable and plan each remaining identifier as named struct-field access.
This supports expressions such as:

record.rule_action
record.metadata.rule_action
record.items[1]

Field access is planned through the configured expression planners, consistent with existing field-access handling.

What is the testing strategy for this PR?

Added sqllogictest coverage in array/array_transform.slt for:

  • Direct field access on a struct-valued lambda parameter.
  • Field access followed by list indexing.
  • Chained field access through nested structs.

Are there any user-facing changes?

no

@github-actions github-actions Bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels Sep 10, 2026
@codecov-commenter

codecov-commenter commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.90%. Comparing base (5747e87) to head (4e1c42e).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/sql/src/expr/identifier.rs 85.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #25177    +/-   ##
========================================
  Coverage   81.90%   81.90%            
========================================
  Files        1132     1132            
  Lines      420155   420590   +435     
  Branches   420155   420590   +435     
========================================
+ Hits       344126   344499   +373     
- Misses      55742    55771    +29     
- Partials    20287    20320    +33     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants