Skip to content

fix(common): visit scalar subqueries when attaching plans#1756

Merged
Theodus merged 1 commit intomainfrom
theodus/planning
Feb 13, 2026
Merged

fix(common): visit scalar subqueries when attaching plans#1756
Theodus merged 1 commit intomainfrom
theodus/planning

Conversation

@Theodus
Copy link
Member

@Theodus Theodus commented Feb 13, 2026

Fixes panic when queries contain scalar subqueries in expressions (e.g., LEAST((SELECT MAX(...)), (SELECT MAX(...)))).

The bug: DetachedLogicalPlan::attach_to() used transform() which only visits direct plan children, leaving PlanningTable providers unvisited inside scalar subquery expressions. This caused panics during physical planning when PlanningTable::scan() was called.

The fix: Use transform_with_subqueries() to visit all LogicalPlan nodes including those embedded in expressions.

Fixes panic when queries contain scalar subqueries in expressions (e.g.,
LEAST((SELECT MAX(...)), (SELECT MAX(...)))).

The bug: DetachedLogicalPlan::attach_to() used transform() which only
visits direct plan children, leaving PlanningTable providers unvisited
inside scalar subquery expressions. This caused panics during physical
planning when PlanningTable::scan() was called.

The fix: Use transform_with_subqueries() to visit all LogicalPlan nodes
including those embedded in expressions.
@Theodus Theodus changed the title fix(common): visit scalar subqueries when attaching detached plans fix(common): visit scalar subqueries when attaching plans Feb 13, 2026
Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

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

LGTM ✅

@Theodus Theodus merged commit ac2e1ec into main Feb 13, 2026
7 checks passed
@Theodus Theodus deleted the theodus/planning branch February 13, 2026 18:25
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