Skip to content

fix(core): round-trip subqueries in extended expressions - #1470

Open
benbellick wants to merge 1 commit into
mainfrom
benbellick/fix/extended-expression-subqueries
Open

benbellick wants to merge 1 commit into
mainfrom
benbellick/fix/extended-expression-subqueries

Conversation

@benbellick

Copy link
Copy Markdown
Member

Extended-expression converters have no relation converter, so subqueries cannot round-trip. Share relation and expression conversion within the container, and resolve base-schema types through its extension declarations.

Extracted from #1453 while keeping spec v0.106.0.

Use relation converters for subquery inputs and share the container resolver across expressions and relations. Resolve base-schema types using the extended expression declarations.
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Extended expressions now preserve inline scalar subqueries when converted between supported formats, including subqueries with filters.
    • Conversion now uses the expression’s available function and extension information, helping keep subquery types and expressions consistent throughout the round trip.

Extended-expression conversion now obtains converters and detached subtrees through relation converters. A round-trip test covers an expression reference containing a scalar subquery.

Changes: Extended expression conversion

Layer / File(s) Summary
Relation-converter wiring and scalar-subquery coverage
core/src/main/java/io/substrait/relation/ProtoRelConverter.java, core/src/main/java/io/substrait/extendedexpression/ExtendedExpressionProtoConverter.java, core/src/main/java/io/substrait/extendedexpression/ProtoExtendedExpressionConverter.java, core/src/test/java/io/substrait/extendedexpression/ExtendedExpressionRoundTripTest.java
ProtoRelConverter adds a factory for extended-expression conversion. The extended-expression converters use relation-provided converters and detached subtrees. A round-trip test covers an inline scalar subquery.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ProtoExtendedExpressionConverter
  participant ProtoRelConverter
  participant ProtoExpressionConverter
  ProtoExtendedExpressionConverter->>ProtoRelConverter: Create converter for extended expression
  ProtoRelConverter-->>ProtoExtendedExpressionConverter: Provide detached subtrees
  ProtoExtendedExpressionConverter->>ProtoExpressionConverter: Convert expression with relation converter and detached subtrees
Loading

Possibly related PRs

  • substrait-io/substrait-java#1453: This PR is extracted from #1453, which adds extended-expression support for detached targets and extension bindings. Its subquery conversion changes use the same converter path.

Suggested reviewers: nielspardon, bvolpato

Merge Risk: Minimal · up to 43e82

This change lets subqueries inside extended expressions survive conversion to and from the protobuf form. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title is a valid Conventional Commit (fix(core): ...) and names the main change: subqueries in extended expressions now round-trip. The raw summary shows the core edits: a shared relation converte…
Description check Passed The description gives the problem (extended-expression converters lack a relation converter, so subqueries cannot round-trip) and the approach (share relation and expression conversion within the cont…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title is a valid Conventional Commit (fix(core): ...) and names the main change: subqueries in extended expressions now round-trip. The raw summary shows the core edits: a shared relation converter for the extended expression, a new ProtoRelConverter.forExtendedExpression factory, and a round-trip test for a scalar subquery. The title is specific and matches the changeset.

Full details: Description check

Explanation

The description gives the problem (extended-expression converters lack a relation converter, so subqueries cannot round-trip) and the approach (share relation and expression conversion within the container, and resolve base-schema types through its extension declarations). It also notes the origin (extracted from #1453) and the spec version (v0.106.0). The repository template asks for a Conventional Commit title and a rationale, and the description supplies a rationale. It does not state a breaking-change footer, which the template only requires when the change is breaking, and the change does not appear to be breaking. The description is brief but covers the essentials.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d0226c6 and 43e82ef.

Files selected for processing: 4

  • core/src/main/java/io/substrait/extendedexpression/ExtendedExpressionProtoConverter.java
  • core/src/main/java/io/substrait/extendedexpression/ProtoExtendedExpressionConverter.java
  • core/src/main/java/io/substrait/relation/ProtoRelConverter.java
  • core/src/test/java/io/substrait/extendedexpression/ExtendedExpressionRoundTripTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@benbellick
benbellick marked this pull request as ready for review December 3, 2026 22:59
@benbellick
benbellick requested a review from bvolpato December 3, 2026 22:59
bvolpato added a commit to bvolpato/substrait-java that referenced this pull request Dec 4, 2026
Leave the Spark fix from substrait-io#1434 to substrait-io#1471. Keep the PlanRel check separate from the subquery converter so substrait-io#1470 can land first without a merge conflict.
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.

2 participants