Skip to content

fix(plan): support nested correlated subqueries - #24537

Merged
mergify[bot] merged 7 commits into
matrixorigin:mainfrom
ck89119:issue-23110
May 23, 2026
Merged

fix(plan): support nested correlated subqueries#24537
mergify[bot] merged 7 commits into
matrixorigin:mainfrom
ck89119:issue-23110

Conversation

@ck89119

@ck89119 ck89119 commented May 22, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #23110

What this PR does / why we need it:

  • Extends nested correlated subquery flattening to ANY and ALL by allowing their deep correlated predicates to be pulled up.
  • Appends deep correlated filters after ANY/ALL mark joins, matching the existing EXISTS/IN handling.
  • Adds planner and BVT coverage for two-level correlated ANY/ALL subqueries.

Validation:

  • go test ./pkg/sql/plan -run TestSubQuery -count=1
  • go test ./pkg/sql/plan -count=1
  • make
  • make static-check
  • git diff --check
  • npx markdownlint-cli CLAUDE_TODO_2026-05-22.md
  • Rebuilt mo-service; focused execution of the new BVT block returned expected rows.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels May 22, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label May 22, 2026
@ck89119 ck89119 changed the title fix(plan): support nested correlated any and all subqueries fix(plan): support nested correlated subqueries May 22, 2026

@aunjgr aunjgr 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.

Review: nested correlated subqueries

Approve.

The deep-correlation handling is constrained to supported subquery types, guards unsafe pull-up cases that still contain inner columns, and appends lifted deep-correlated filters in a controlled way after mark join creation. Added tests cover EXISTS/NOT EXISTS/IN/NOT IN/ANY/ALL nested correlated cases plus an explicit guarded error path.

No blocking issue found.

@mergify

mergify Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-05-23 17:47 UTC · Rule: main
  • Checks passed · in-place
  • Merged2026-05-23 18:46 UTC · at afccc0678f750713620ccb9c3f86487e6d6b020a · squash

This pull request spent 59 minutes 5 seconds in the queue, including 58 minutes 37 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage

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

Labels

kind/bug Something isn't working kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants