Skip to content

fix: preserve GROUP_CONCAT warning source rows - #28747

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28665-group-concat-warning
Sep 12, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28665-group-concat-warning

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 11, 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:

Closes #28665

What this PR does / why we need it:

GROUP_CONCAT() truncation diagnostics used local aggregate-finalization order as the warning row number. With multiple groups, partial aggregation, or spill/rebuild, that order can differ from input order, so the result can be correct while SHOW WARNINGS reports the wrong source row.

The fix carries source-row metadata across batches, ordered and unordered DISTINCT state, partial merges, and local spill/rebuild. It combines warnings across spill buckets before publication and preserves existing H0/single-group behavior and NULL handling.

Distributed provenance is explicit. Independent remote CN processes mark their row ordinals untrusted instead of exporting local ordinals. The coordinator and legacy readers fall back to a deterministic aggregate ordinal domain for untrusted or marker-free partials, including empty and NULL-only partials. Mixed state is never re-exported with partially trusted row metadata.

Upstream main now contains #28746, which assigns MORPC v65 to ASCII's signed INT result. This PR uses MORPC v66 for the GROUP_CONCAT source-row diagnostics extension and gates the payload and provenance marker on v66. The duplicate ASCII compatibility commit is no longer part of this branch.

Validation

  • Rebased on current upstream main at 0d701bb966f3dbc313d6659baec1c47762d1c186; MORPC v65 remains assigned to ASCII and GROUP_CONCAT metadata requires v66.
  • Before this latest rebase, targeted GROUP_CONCAT and ASCII tests passed in pkg/sql/colexec/aggexec, pkg/sql/colexec/group, pkg/vm/process, pkg/sql/compile, and pkg/sql/plan/function; TestIssue28665WarningRowsFollowInputOrder passed in pkg/tests/issues.
  • At current head 6551997865b616b07fa50eecf53e2c124604b604, GPT-6 medium final review passed and git diff --check passed. CI reruns are in progress; local runtime tests were not rerun after this rebase.
  • Before this rebase, the full UT suites for pkg/sql/colexec/aggexec, pkg/sql/colexec/group, pkg/vm/process, pkg/sql/compile, pkg/sql/plan/function, and pkg/pb/plan passed; the public distributed BVT, focused -race cases, make cgo -j12, and incremental golangci-lint --new-from-rev=origin/main also passed.
  • A previous same-head CI run had one TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges deadline failure; the same test passed on the next run of that exact SHA and in another run. Issue [Bug]: Race UT restore case intermittently hits deadline under CI load #28763 tracks this intermittent restore-test behavior. That later run failed overall in the separate TestBackupProtectionCheckpointProtection case; that checkpoint timeout is not classified as flaky.

Compatibility and performance

The local path adds a small state-level marker at the v66 partial boundary. Trusted local values retain source rows; remote or legacy mixed states use a bounded fallback counter. No new goroutine, RPC wait, or unbounded retention path is introduced.

@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 Sep 11, 2026
@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Sep 11, 2026
@XuPeng-SH
XuPeng-SH force-pushed the codex/issue-28665-group-concat-warning branch from 90d60d9 to 3403168 Compare September 12, 2026 01:44
@matrix-meow matrix-meow added size/XXL Denotes a PR that changes 2000+ lines and removed size/XL Denotes a PR that changes [1000, 1999] lines labels Sep 12, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed head 6551997865b616b07fa50eecf53e2c124604b604 against base 0d701bb966f3dbc313d6659baec1c47762d1c186. No blocking issue found in this review.

I traced input-row allocation through batch offsets, local partial producers, ordered/unordered DISTINCT state, finalization, and spill/rebuild. The source-row metadata stays separate from DISTINCT identity; the logical grouped context survives singleton spill buckets. Warning retention is bounded, counts are accumulated separately, and publication consumes the diagnostics to avoid duplicate reporting during cleanup. Failed finalization clears pending diagnostics.

The v66 gate preserves v65 for ASCII. Remote and marker-free partials downgrade provenance, including empty/NULL-only partials, and mixed state does not re-export partially trusted source rows. This deliberately provides fallback aggregate ordinals for those paths, rather than claiming globally ordered source positions across independent CN streams.

The additional row metadata and bounded warning sorting have a real GROUP_CONCAT memory/CPU cost; this review does not establish a measured performance delta. The new per-process cursor lock is limited to counter lookup/allocation, with no downstream I/O under the lock, and counters are cleared at query reset.

Validation reused: current-head CI run 34690713442, with UT, SCA, shared build, coverage, both active BVT jobs, and CI Required successful. Also inspected the focused regression tests for partial merge, NULL/DISTINCT handling, offsets, spill boundaries, warning retention, and protocol gates. No redundant broad local test run was performed.

Submitting COMMENT because this is a self-authored PR.

@XuPeng-SH
XuPeng-SH merged commit 999e07e into matrixorigin:main Sep 12, 2026
17 of 20 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/issue-28665-group-concat-warning branch September 12, 2026 12:37

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/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: GROUP_CONCAT reports incorrect truncation row diagnostics across multiple groups

2 participants