Skip to content

Plan struct colon access as get_field - #25373

Open
osipovartem wants to merge 5 commits into
apache:mainfrom
Embucket:upstream-struct-colon-get-field
Open

osipovartem wants to merge 5 commits into
apache:mainfrom
Embucket:upstream-struct-colon-get-field

Conversation

@osipovartem

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes no issue.

Rationale for this change

SqlToRel::parse_json_access represents SQL colon access as a colon binary operator. For an Arrow Struct, that expression currently retains the complete Struct type and reaches an unsupported physical binary operator instead of accessing the requested field.

What changes are included in this PR?

NestedFunctionPlanner now lowers a static colon access on a Struct to the existing vectorized get_field UDF. Nested paths become nested get_field calls, which the existing simplifier can flatten and push toward scan leaves. Non-Struct colon expressions remain available to other planners.

The tests cover nested Struct access and the non-Struct fallback.

Are there any user-facing changes?

SQL JSON-style access on typed Struct expressions can now be planned and executed through get_field.

How was this change tested?

  • cargo test -p datafusion-functions-nested planner::tests --lib (2 passed)
  • cargo fmt --all -- --check

A package clippy run reached an unrelated pre-existing from_iter_instead_of_collect warning in datafusion/common/src/scalar/mod.rs; the changed crate passed this same focused clippy command on the DataFusion 55 fork.

@github-actions github-actions Bot added the functions Changes to functions implementation label Sep 16, 2026
@codecov-commenter

codecov-commenter commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.51807% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.66%. Comparing base (7570366) to head (16b92e3).
⚠️ Report is 166 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/sql/src/expr/mod.rs 79.51% 8 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25373      +/-   ##
==========================================
+ Coverage   82.45%   82.66%   +0.20%     
==========================================
  Files        1140     1147       +7     
  Lines      436589   446494    +9905     
  Branches   436589   446494    +9905     
==========================================
+ Hits       359996   369089    +9093     
- Misses      54838    54997     +159     
- Partials    21755    22408     +653     

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

@github-actions github-actions Bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) and removed functions Changes to functions implementation labels Sep 22, 2026
@osipovartem
osipovartem force-pushed the upstream-struct-colon-get-field branch from 2dd5ed9 to 529a724 Compare September 22, 2026 23:04
@osipovartem
osipovartem force-pushed the upstream-struct-colon-get-field branch from 529a724 to 87cf279 Compare September 23, 2026 07:10
@github-actions github-actions Bot added the core Core DataFusion crate label Sep 23, 2026

@kosiew kosiew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@osipovartem,

Thanks for working on this. The Struct colon-path lowering looks good overall. I left one non-blocking suggestion to strengthen the regression coverage.

+---+
");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a case where the registered colon planner returns PlannerResult::Original for a Struct path? That would verify that a planner can defer colon handling and the built-in Struct-path lowering still produces the expected field access.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added test_deferred_struct_colon_operator in 16b92e3. It confirms the registered planner sees : and returns Original, then verifies built-in Struct field access returns 1. The six focused ExprPlanner tests pass locally.

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

Labels

core Core DataFusion crate sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants