Skip to content

fix(plan): preserve prepared aggregate parameters - #26042

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-26020-prepared-aggregate-params
Jul 23, 2026
Merged

mergify[bot] merged 6 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-26020-prepared-aggregate-params

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #26020
issue #25992

What this PR does / why we need it:

Prepared aggregate and GROUP BY parameters were broken at two independent planner seams. VisitPlan skipped Node.AggList and Node.GroupBy, so parameter discovery and reset/fill rules never reached markers stored there. In addition, binder expression-equivalence maps used normal SQL formatting, where every marker is rendered as ?; distinct parser offsets therefore collided and could reuse the wrong bound expression.

This change visits aggregate/group expressions and adds an opt-in offset-aware key for planner-internal expression identity. Default SQL formatting remains unchanged, and the internal offsets are stripped before names enter the user-visible plan/EXPLAIN path.

The aggregate result-type propagation in #26019 and dynamic window-frame parameters in #25993 are separate design changes and are not included here.

Test

  • Focused RED/GREEN regressions for aggregate discovery, GROUP BY identity, nested/repeated markers, and display-name isolation
  • Visitor and formatter unit tests
  • Full pkg/sql/parsers/tree and pkg/sql/plan test packages
  • Focused -race run
  • go build -mod=readonly and go vet -mod=readonly for both changed packages
  • git diff --check

@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 the kind/bug Something isn't working label Jul 22, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Jul 22, 2026

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

Codex automated review

No findings. The latest update consistently applies the offset-aware key to GROUP BY producers and consumers and covers alias/ordinal reuse, resolving the prior review. Focused tests could not start because local CGo artifacts are absent; static review, formatting, and diff checks were clean.

@XuPeng-SH XuPeng-SH 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.

Deep review completed on the latest head. No blocking issues found.\n\nVerified correctness: parameter identity is opt-in and does not change default SQL rendering; aggregate/GROUP BY producers and consumers use the same identity key; aliases and ordinals still reuse the grouped expression; internal parameter offsets do not leak into display names; prepared-plan discovery/reset now reaches AggList and GroupBy.\n\nVerified performance/risk: the extra formatting is bind-time only and bounded by AST size; no new goroutines, waits, external resources, or unbounded state were introduced. The latest main merge-tree is conflict-free.\n\nLocal validation passed: build and vet for pkg/sql/parsers/tree and pkg/sql/plan; full tests for both packages; focused new regression tests under -race, 10 runs.

@mergify mergify Bot added the queued label Jul 23, 2026
@mergify

mergify Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-23 16:08 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-23 17:08 UTC · at 7092c52c6dcfef426fad6c33c8427573acb688ac · squash

This pull request spent 1 hour 26 seconds in the queue, including 1 hour 7 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)
  • 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 / 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 Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64

This branch was previously deployed

1 inactive deployment
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 size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants