Skip to content

fix(vector): preserve constant selection grouping metadata - #30119

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
Ariznawlll:codex/join-unique-constant-grouping
Oct 15, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
Ariznawlll:codex/join-unique-constant-grouping

Conversation

@Ariznawlll

@Ariznawlll Ariznawlll commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG

Which issue(s) this PR fixes

Fixes #30118.

What this PR does / why we need it:

Further exploration found that the original unique INNER JOIN grouping defect comes from constant-vector selection copies, not just JOIN projection. unionT and unionBatch preserve all-row uniform grouping but drop partial logical-row grouping. This also affects Batch.Clone and LoopJoin's bulk build projection.

Fix the underlying vector copies: map partial grouping bits through the selection/offset/flags while keeping uniform grouping's range fast path. Remove the temporary unique-projection scalar helper and the now-unnecessary membership scalar guard; retain bulk JOIN projection.

Add Go UT for vector copies, Batch.Clone, LoopJoin scalar/range/actual operator resume, and unique HashJoin. No BVT or golden changes.

Original validation (before the 2026-10-14 base sync)

  • Frozen official main: 35c8dd5854750ef96f52f9dd298a70acd031d5e4, macOS arm64.
  • Before fix, with official main's vector/batch/loopjoin code: 18 vector-copy combinations fail their grouping assertions 3/3; 22 controls pass 3/3. Both Batch.Clone variants and both LoopJoin bulk/operator variants reproduce 3/3; scalar LoopJoin control passes 3/3. Original unique INNER JOIN also reproduced 3/3.
  • Matrix covers fixed/string/NULL constants, uniform rollup, flat controls, repeated/out-of-order selections, offsets, sparse/dense/empty flags, preflighted publication, preserved prefixes, excluded out-of-range grouping bits, exact values/NULLs, and resource cleanup.
  • Focused vector, batch, LoopJoin and HashJoin tests pass -race -count=10 after the root fix.
  • Containing vector, batch, LoopJoin, HashJoin and Product suites pass 3 rounds locally.
  • make err-check and git diff --check pass.
  • Full local license header check: 6240 files checked, 0 invalid headers (includes uncommitted exploration files, which are not part of this PR).

This proves an internal vector metadata defect. No public SQL wrong-result, persistence or multi-CN reproduction is claimed.

2026-10-14 follow-up

Merged official main 2ce4e58af6f03b943ee288ffad81012766cf830a. Main already contains the JSON EXPLAIN compilation repair and updated logservice port fixtures; this PR no longer waits for #30106 to supply an EXPLAIN repair. The diff against main remains the six vector/batch/JOIN implementation and regression-test files.

Validation of merge commit 6c7efa7ee7 on macOS arm64, using the repository's native-artifact provenance guard and mo-cgo-test wrapper:

  • Focused grouping tests in vector, batch, HashJoin and LoopJoin: passed.
  • Full normal-mode suites for those four packages: passed.
  • git diff --check: passed.

The earlier race/repetition evidence above describes the original implementation validation, not a new race run after this merge. No BVT, external test environment, or manual CI workflow was started in this follow-up. The PR remains draft; remote checks must validate the new head.

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

Reviewed exact head 40a84030bcbac7573090e7cfd00fbf96e57472f2 against merge-base 2ce4e58af6f03b943ee288ffad81012766cf830a. No blocking issue found. Read all six changed files, issue #30118, PR discussion and review/thread history (no prior substantive reviews or threads). This is a narrowly scoped metadata-copy correctness fix; no separate design-approval gate is needed.

The root correction in pkg/container/vector/vector.go preserves grouping per logical source row for constant Union/UnionInt32 selections and UnionBatch offset/flags selections. Constant payload does not imply uniform grouping. Checked repeated/out-of-order selections, preserved destination prefixes, exclusion of out-of-range source bits, NULL/value independence and the retained uniform-grouping range path. Traced preflight bitmap admission and preflighted publication, Batch.Clone, LoopJoin bulk/resumed projection, unique INNER HashJoin and SEMI/ANTI membership projection after removal of the scalar guard. No new ownership, wait, wire-format or schema contract is introduced; existing bitmap admission and cleanup owners remain in place.

Independent exact-head validation in an isolated worktree, using a fresh top-level make -j4 cgo build and the provenance-checked mo-cgo-test wrapper with CGO enabled:

  • Full normal suites: vector 0.659s, batch 0.032s, HashJoin 4.435s, LoopJoin 0.118s, Product 0.046s; all PASS.
  • Focused original grouping/clone/unique-join/membership/operator-resume tests plus my boundary probe, -race -count=10: vector 1.817s, batch 1.056s, HashJoin 9.859s, LoopJoin 1.157s; all PASS.
  • Independent 24-case scalar-UnionOne oracle covers fixed/string/NULL/rollup constants, 193 logical rows, grouping around 63/64 and 127/128, 61-row prefixes, repeated nonmonotonic selection, offsets, sparse/empty flags, two append rounds and preflighted publication. Verifies exact grouping cardinality, values/NULLs, unchanged source and zero retained MPool/allocation-account metadata after cleanup. Probe SHA-256 d97bb466d0f0f8f182c53f6595b5dc09ae5b70faea75fcd91154b9f6264146a4; temporary probe removed.
  • Formatting and git diff --check pass. Exact-head CI run 38696798163 is successful; downloaded its UT log for corroboration.

These checks establish internal vector metadata and actual operator behavior; I am not claiming a newly reproduced public-SQL wrong result, persisted-data issue, performance benchmark or local multi-CN execution. Rechecked open/non-draft state and the exact head immediately before submission.

@XuPeng-SH

XuPeng-SH commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 40a84030bcbac7573090e7cfd00fbf96e57472f2

Review completed. Read the assessment.

@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: 40a84030bcbac7573090e7cfd00fbf96e57472f2

Assessment: approve

Reviewed all six changed files and affected callers. The fix correctly preserves logical-row grouping in shared vector copies and removes the obsolete HashJoin fallback. Ownership, cleanup, compatibility and ordinary fast paths remain intact. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • Exact-head normal suites passed for vector, batch, HashJoin, LoopJoin and Product: 1,151 named PASS results, zero failures or skips.

  • Confirmed execution of new grouping regressions, existing SEMI/ANTI membership cases and allocation-failure controls.

  • Verified source identity, formatting, native-build inputs, command/exit receipts and retained logs. Evidence: /home/xupeng/.local/state/mo-bot/jobs/ce63883e2e012a0bc71df3a6/attempt-1/validation-summary.json; detailed assessment: review-report.md.

  • Supplied exact-head CI reports successful UT, SCA, coverage and BVT checks.

Limitations:

  • External raw test logs and the linked issue body were not supplied; reported external validation is distinguished from independently executed checks.

  • No local race rerun, public-SQL reproduction or performance benchmark was performed. Additional partial-grouping work is bounded by selected rows.

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

mergify Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-15 09:56 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-15 12:36 UTC · at 70a352322057f6846ade9a9c7320f181083bf306

This pull request spent 2 hours 40 minutes 39 seconds in the queue, with no time running CI.

Reason

Pull request #30119 has been merged manually at bac18ed

Hint

You were too fast!

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

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — 70a35232 Deployed Oct 15, 2026 by XuPeng-SH
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.

[Bug]: constant-vector selection copies drop logical-row grouping metadata

4 participants