Skip to content

fix(sql): preserve filtered UNION ALL right branch columns - #30015

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
Ariznawlll:codex/fix-union-all-column-remap-30007
Oct 13, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
Ariznawlll:codex/fix-union-all-column-remap-30007

Conversation

@Ariznawlll

@Ariznawlll Ariznawlll commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Fixes #30007, #30010, and #30016.

  • Preserve the correct positional right-branch column through filtered UNION ALL pruning. This prevents wrong numeric/aggregate results, invalid string vectors, and incorrect persisted values.
  • Return row-encoding errors to the statement handler without sending an ERR packet in the row writer. The handler now sends one terminal error response, so a failed statement cannot leave an extra packet for the next command.

Regression coverage

  • Planner tests cover aggregate, projection, selective filter, string, and NULL values.
  • New SQL regression covers filtered string UNION ALL, direct query, SQL PREPARE reuse, and subsequent statements on the same connection.
  • New frontend unit test deliberately triggers a row-encoding error in both text-query and binary-prepared paths and asserts exactly one terminal ERR packet.
  • go test ./pkg/sql/plan -count=1: passed before this frontend-only follow-up.
  • go test ./pkg/frontend -count=1: passed after this follow-up. Focused frontend tests passed 3/3.
  • The new SQL regression passed 3/3 against a local build with the planner fix. JDBC Connector/J server-prepared execution and same-connection reuse passed 3/3.

The broader legacy union suite had pre-existing golden mismatches in union.sql; the new regression file passed independently. GitHub CI is still running.

@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 →

@XuPeng-SH

XuPeng-SH commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: b073c152a40744230cd673bfc6c969e8388417fb

Assessment: approve

Reviewed the complete six-file delta and affected callers. Positional column preservation remains within the existing planner owner, and row-encoding failures now leave terminal error delivery to the statement handler. No actionable correctness, design, lifecycle or performance defect remains.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

Validation:

  • Verified frozen HEAD, merge-base, patch correspondence and clean source. Diff whitespace and Go formatting checks passed.

  • Traced set-operation construction, filter pushdown, projection pruning and transparent-node remapping, including selective columns, NULLs, aggregates and sorting boundaries.

  • Traced encoding failures through statement handling and ERR delivery; confirmed Conn.Write discards incomplete buffered rows.

  • Reviewed planner regressions, text/binary encoding-error tests and SQL prepared-statement reuse cases.

  • Reused successful current-head build, Ubuntu unit tests, arm64 static analysis, coverage, proxy and multi-CN BVT, and Connector/J pool-reset CI. Frozen comments contain no substantive unresolved concern.

Limitations:

  • No local native or SQL tests were rerun; validation reused frozen CI and supporting author reports.

  • Linked issue bodies and raw author test logs were unavailable; behavioral contracts were assessed from the supplied PR description.

  • The encoder test simulates terminal response delivery; the production statement-handler path was checked by code tracing. Author-reported legacy UNION golden mismatches were not independently reproduced.

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

mo-bot review · mo-bot-local · review

Commit: b073c152a40744230cd673bfc6c969e8388417fb

Assessment: approve

Reviewed the complete six-file delta and affected callers. Positional column preservation remains within the existing planner owner, and row-encoding failures now leave terminal error delivery to the statement handler. No actionable correctness, design, lifecycle or performance defect remains.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

Validation:

  • Verified frozen HEAD, merge-base, patch correspondence and clean source. Diff whitespace and Go formatting checks passed.

  • Traced set-operation construction, filter pushdown, projection pruning and transparent-node remapping, including selective columns, NULLs, aggregates and sorting boundaries.

  • Traced encoding failures through statement handling and ERR delivery; confirmed Conn.Write discards incomplete buffered rows.

  • Reviewed planner regressions, text/binary encoding-error tests and SQL prepared-statement reuse cases.

  • Reused successful current-head build, Ubuntu unit tests, arm64 static analysis, coverage, proxy and multi-CN BVT, and Connector/J pool-reset CI. Frozen comments contain no substantive unresolved concern.

Limitations:

  • No local native or SQL tests were rerun; validation reused frozen CI and supporting author reports.

  • Linked issue bodies and raw author test logs were unavailable; behavioral contracts were assessed from the supplied PR description.

  • The encoder test simulates terminal response delivery; the production statement-handler path was checked by code tracing. Author-reported legacy UNION golden mismatches were not independently reproduced.

@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added the queued label Oct 13, 2026
@mergify

mergify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-13 02:43 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-13 02:54 UTC · at 6321810b12b1beb11cb0829126ebdc3394c21e7c

This pull request spent 10 minutes 49 seconds in the queue, with no time running CI.

Reason

Pull request #30015 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch had an error being deployed

1 failed deployment
ci — 6321810b Deployed Oct 13, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

3 participants