Skip to content

fix: support extended types in group_concat - #27620

Merged
XuPeng-SH merged 12 commits into
matrixorigin:mainfrom
Lundomn:fix/issue-27589
Aug 27, 2026
Merged

XuPeng-SH merged 12 commits into
matrixorigin:mainfrom
Lundomn:fix/issue-27589

Conversation

@Lundomn

@Lundomn Lundomn commented Aug 26, 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:

close #27589

What this PR does / why we need it:

GROUP_CONCAT accepts DECIMAL256, YEAR, UUID, GEOMETRY, and GEOMETRY32 inputs, but its payload writer did not serialize these types. Queries using them therefore failed during aggregation.

This change:

  • validates and serializes DECIMAL256, YEAR, and UUID fixed-width payloads;
  • preserves GEOMETRY and GEOMETRY32 WKB bytes with the existing payload-length validation;
  • adds unit coverage for values, NULLs, malformed fixed-width payloads, and oversized geometry payloads;
  • adds BVT coverage for all five affected types.

Local verification:

  • go test ./pkg/sql/colexec/aggexec -count=1
  • go test -race ./pkg/sql/colexec/aggexec -count=1
  • go vet ./pkg/sql/colexec/aggexec
  • go vet ./...
  • affected package coverage: 78.8%
  • function_group_concat BVT: 183/183 passed
  • make config
  • make err-check

The full repository test run was also attempted. Its remaining failures (service configuration nil dereferences, unavailable local Grafana, and missing macOS libusearch_c.dylib runtime lookup) were reproduced unchanged on a clean origin/main worktree.

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

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

Blocking: pkg/sql/colexec/aggexec/agg_payload.go:211-215 now writes GEOMETRY/GEOMETRY32 as arbitrary raw WKB bytes, but GroupConcatReturnType at pkg/sql/colexec/aggexec/concat2.go:152-160 still returns TEXT/UTF8 unless an argument is BINARY/VARBINARY/BLOB. Consequently binaryResult is false and the truncation path at concat2.go:1658-1665 treats WKB as UTF-8.

A concrete counterexample is GROUP_CONCAT over WKB POINT(1 2) with group_concat_max_len=20: the 21-byte WKB begins 01 01 00 00 00 00 00 00 00 00 00 f0 3f .... The aggregate should preserve the first 20 binary bytes, but the current code returns only the first 11 bytes because it backtracks over the invalid UTF-8 byte f0; the result is also advertised to MySQL clients as TEXT rather than binary. This corrupts/truncates one of the newly supported types.

Please either make GEOMETRY/GEOMETRY32 force a BLOB/binary GROUP_CONCAT result (including mixed arguments), or serialize them to a textual representation consistently, and add coverage for result metadata plus a group_concat_max_len boundary through the aggregate execution path.

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

Blocking correctness issue in the newly supported GEOMETRY/GEOMETRY32 path: writeGroupConcatData appends raw WKB, but GroupConcatReturnType neither returns BLOB for geometry nor propagates its binary charset (MergeStringCharset ignores geometry). Every truncation path then decides binary/text from retType.Oid == T_blob and treats WKB as UTF-8.

I reproduced this through the aggregate executor on this exact head. WKB POINT(1 2) is 21 bytes; with group_concat_max_len=20, the expected binary prefix is 20 bytes, but the result is only 11 bytes because truncation backs up past byte 0xf0 until the buffer happens to be valid UTF-8. The result type also carries CharsetUTF8, so clients receive incorrect text metadata for opaque bytes. Mixed geometry/text arguments have the same contract problem.

Please make GEOMETRY and GEOMETRY32 force a binary GROUP_CONCAT result (and make the truncation decision follow the binary contract), or serialize them as text consistently. Add executor-level coverage for result OID/charset and a max-length cut inside WKB, including a mixed-argument case. The new Decimal256/Year/UUID serialization and malformed fixed-payload checks passed focused tests; no material performance regression was found there.

@Lundomn
Lundomn requested review from aptend and aunjgr August 27, 2026 05:54

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

Deep re-reviewed the complete diff and all prior reviews/threads at exact head 8e74e4f, with the incremental changes since my previous reviewed head 0a8f3b5 checked separately.

The prior blockers are closed: GEOMETRY/GEOMETRY32 now force an opaque binary result; every resident, ordered, spill, and accounted finalizer truncates according to the result charset; and valid WKB above 64 KiB bypasses the legacy unit limit while the final scratch remains bounded by group_concat_max_len. The new fail-closed type admission matches the serializer contract, with untyped NULL still handled by the existing T_any-to-TEXT cast.

Validated with diff check, full aggexec package tests, vet, build, the full race suite, and repeated focused race coverage for large geometry, Geometry32, mixed binary/text, allocation-account, and spill paths.

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

Approved exact head .\n\nThe previous >64 KiB GEOMETRY rejection is closed by routing GEOMETRY/GEOMETRY32 through the binary result writer rather than the uint16-limited unit validator. The added 65,545-byte coverage exercises both geometry types across ordered, spill, and accounted finalizers. The legacy finalizer's scratch growth is now bounded by , binary truncation follows charset semantics, and the supported-type check is fail-closed. I found no remaining correctness or lifecycle blocker.

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

Approved exact head 8e74e4ff2d9f22f5985b74168deaac8c2d0da78c.

The previous >64 KiB GEOMETRY rejection is closed by routing GEOMETRY/GEOMETRY32 through the binary result writer rather than the uint16-limited unit validator. The added 65,545-byte coverage exercises both geometry types across ordered, spill, and accounted finalizers. The legacy finalizer's scratch growth is now bounded by group_concat_max_len, binary truncation follows charset semantics, and the supported-type check is fail-closed. I found no remaining correctness or lifecycle blocker.

@mergify mergify Bot added the queued label Aug 27, 2026
@mergify

mergify Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-27 08:38 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-27 08:57 UTC · at 10e4e6f72fefa6b3265632dfe23257f5e68e1e2e

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

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #27620 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.

Failing checks:

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.

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
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]: GROUP_CONCAT fails for DECIMAL256, YEAR, UUID, GEOMETRY and GEOMETRY32

5 participants