Repository navigation
use account id - #4
Merged
Merged
Conversation
cpegeric
added a commit
that referenced
this pull request
Jul 6, 2026
Resolve four findings from the WAND retrieval-index self-review: - B1 uuid membership prefilter: docFilterMembership.Contains probed a uuid via encodePk (36-char canonical string), but the membership filter is built from the source uuid's raw 16 bytes (CBloomFilter.addFixedVector) — every candidate was rejected, so a uuid-PK retrieval query with a WHERE prefilter returned zero rows. Probe the raw 16 bytes to match. (Native temporal/decimal PKs were already correct: their encodePk output IS the raw representation the bloom hashes.) - #4 cfg JSON: build the WAND search TVF config with json.Marshal instead of raw fmt.Sprintf, so a schema name containing a quote/backslash no longer produces malformed JSON that the search side's Unmarshal rejects. - #5 retrieval fail-fast: a parser='retrieval' index is maintained only as WAND frames (classic postings go stale), so error instead of silently falling back to fulltext_index_scan when its WAND store/metadata siblings can't be resolved. - #6 CDC-blob bounds check: readLenBytes/readLenString bounds-check the length against remaining bytes + io.ReadFull, so a truncated pk/text errors cleanly rather than silently zero-filling. Regression tests: TestDocFilterMembershipUuid, TestDecodeWandCdcTruncatedPk. Decision-logged (not fixed): B2 (limit/offset, skipped per request); B3 (insert+ delete-same-window phantom — needs reachability confirmation + a coalescing change that provably preserves the working UPSERT ordering); #7/#8 (dead parallel codecs entangled with live helpers — dedicated cleanup); #9 (hot-path micro-opt, low gain). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cpegeric
added a commit
that referenced
this pull request
Jul 16, 2026
…e base Five self-review findings on the CDC/rebuild paths: #1 CDC pk-type panic — the fulltext2 sink binary-encodes the pk (encodePk asserts native Go types), but IndexConsumer.valueRepr only gave *WandSqlWriter ReprNative; *Fulltext2SqlWriter got ReprSQLString, so a datetime/time/timestamp/decimal/uuid pk arrived as its SQL-display string → interface-conversion panic crashed the consumer goroutine → index permanently unmaintained. Fix: add *Fulltext2SqlWriter to the native-repr writers. #3/#4 json CDC produced ZERO tokens (rows silently unsearchable) — build (rowTerms) flattens each json column per-column, binary-aware, then joins; CDC joined the raw columns then flattened the blob once with binary=false, which mis-parsed a T_json column (bytejson.ByteJson) and multi-column json. Fix: flatten per-column on the CDC write side (FlattenJSONColumn, type-dispatched: ByteJson vs text-json) exactly like build, and CdcTokenizer no longer re-flattens. #6 REBUILD over an emptied table served the stale base — the create TVF clears the tag=0 base inside end(), but end() early-returns on zero source rows, so a rebuild of an all-deleted table kept the old base. Fix: clear the base(s) + evict the cache in the REBUILD orchestrator (buildAndRegisterCDC), which has the cfg regardless of row count. #7 stale doc comments (fulltext2_search.go "no VectorIndexCache yet"; search_cache.go "off-heap posting buffers" — now mmap block-postings). BVT: pessimistic_transaction/fulltext2/fulltext2_bugfix (datetime+decimal PK CDC, T_json + multi-column json CDC, REBUILD-empty), validates 100%. Live-verified all four. (#5 multi-segment boolean stats/top-k is the remaining open finding.) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cpegeric
added a commit
that referenced
this pull request
Jul 21, 2026
… of 7) Self-review (fulltext2_only vs cuvs_quantize, OOM focus) surfaced 7 defects; this fixes 6: #1 (BLOCKER, index.go) newBoundedTopK did make([]topKItem,0,k) — a pushed LIMIT (clamped to MaxInt32) sized the phrase top-k to ~50GB and OOM-killed the CN on a tiny table. Now: no pre-alloc (grow lazily to min(k,#matches)) + cap k to globalN in SearchPhrase. Verified: MATCH ... LIMIT 500000000 on a 3-row table returns instantly. #2 (BLOCKER, plugin/plan/tablefunc.go) fulltext2SearchColDefs declared doc_id=T_int64/score=T_float64 but the executor AppendAny/AppendFixed[float32] — a direct FROM fulltext2_search(...) wrote 4-byte floats into an 8-byte score column (garbage ORDER BY) and mistyped non-int pks. Match the executor (T_any / T_float32), same as the MATCH-path ftIndexColdefs. #3 (index.go) ReconstructLiveDocs bucketed the WHOLE live corpus before yielding, so MERGE (guard-exempt) peaked at O(corpus) Go heap — the reclaim op itself OOMs. A live doc's postings are entirely within its own segment, so reconstruct ONE SEGMENT AT A TIME: buckets is now bounded to O(one segment) (≤ capacity), freed before the next. #4 (storage.go) checkTailLoadBudget gated on 1× SUM(LENGTH(data)) but load holds raw chunks + reassembled frames + decoded segments at once; scale the estimate (×3) so the guard fails before the real peak OOMs. #6 (segment.go, termdict.go) loaded-side forEachPosting materialized the whole vocabulary via prefixTerms("") ([]string); stream the FST via a new forEachTerm — no O(vocabulary) spike compounding the MERGE peak. #7 (serialize.go) decodeDocmap stored pk offsets in []int32; a >2GB docmap wrapped the offset negative → pk(ord) panic. Fail fast at decode instead. Deferred/decision-logged: #5 (stream.go:143 no-LIMIT non-disjunctive materializes all matches) is partially mitigated by #1 (phrase pre-alloc now bounded to #matches); the full fix is DAAT streaming for phrase/boolean (A2), bounded by the result set the user asked for. Verified: pkg/fulltext2 tests pass; live MERGE 25/25, fulltext2 37/37, membership 33/33, async 18/18; build/vet/gofmt clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cpegeric
added a commit
that referenced
this pull request
Jul 24, 2026
…, base-load leak, plugin-kind) #1 [P1] CDC last-write-wins (no frame reorder). A repeated upsert of one pk within an open tail segment merged old+new terms under one live doc, and an upsert to empty/NULL text left the old terms searchable. Add Builder.SetDoc(pk, words) which REPLACES a pk's terms (not append) and keeps a live 0-term doc for an empty upsert so it shadows older copies via recency; TailBuilder.AddBatch uses it (empty INSERT skipped, empty UPSERT shadows). Delete-first frame ordering is unchanged — UPDATE relies on it; the residual upsert->delete phantom is masked by the source-table join. Tests: SetDoc replace, upsert->upsert (no merge), nonempty->empty, nonempty->empty same flush, capacity-crossing, upsert->delete (documented), plain delete. #2 [P1] cache coherence — DEFERRED to a follow-up PR (it is an all-index cache-layer change, not fulltext2-specific). Documented as an in-code Decision block on VectorIndexCache.Remove, with a pointer from the fulltext2 CDC consumer. #3 [P1] DDL backup/restore round-trip. SHOW CREATE dropped position_free / max_index_capacity / max_postings_capacity, and checkpoint dump emitted classic FULLTEXT for a fulltext2 index (losing the engine). IndexParamsToStringList now renders position_free; SHOW CREATE fulltext2 emits the full option set; checkpoint renderCreateIndexStatement emits FULLTEXT2. Tests for the renderer + FULLTEXT2 round trip. #4 [P2] partial base-load leak. LoadAllBases returned on a later LoadFromStorage error without freeing the already-mapped segments; now freeSegs(bases) first. Tests: freeSegs releases the mmap; LoadAllBases frees on partial failure. #5 [P2] plugin index-kind contract. IsVectorIndexAlgo special-cased only classic fulltext by name, so a registered fulltext2 reported as a vector index. Add an explicit IsVectorIndex() capability to the catalog Hooks interface (vector plugins true, fulltext-family false); IsVectorIndexAlgo now delegates to it. Capability pinned in the fulltext2 + hnsw runtime tests. Also: fix a space-before-tab whitespace lint in mysql_sql.y's mergeIndexOption block (git diff --check clean; regenerated mysql_sql.go is byte-identical). Perf follow-up (pooled phrase-buffer position retention; no-LIMIT phrase materializing globalN) is tracked separately and not in this change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cpegeric
pushed a commit
that referenced
this pull request
Oct 8, 2026
) Record the remaining embedding implementation sequence after merged Sirius matrixorigin#25 and importer #3/#4. Split native import/type/scalar plumbing from the complete aggregate/key/capability milestone, then retain merged dependencies for MO lowering, full acceptance, cutover and sidecar retirement. Correct the numeric design's stale approval status while preserving the approved semantic revision. Record the owner-selected strict legacy configuration migration and the 1.0 matched Flight+MO gate only on available equivalent coverage. Preserve the historical delivery map and GC protection/reconciliation requirements. Validation: `git diff --check` and the MatrixOne PR guard pass. This is a documentation/delivery-map change; no production behavior or test oracle changes. Approved by: @XuPeng-SH
cpegeric
pushed a commit
that referenced
this pull request
Oct 26, 2026
…xorigin#31000) `quantileExactWeighted` has no entry anywhere in the SQL stack: the parser grammar carries no token or aggregate rule (so `quantileExactWeighted(...) OVER (...)` and `DISTINCT` forms fail to parse), the function registries carry no `quantileexactweighted` key (flat calls return (20105, "not supported: function or operator")), and the exact-percentile executors (median / approx_percentile / percentile_cont / percentile_disc) retain only unweighted value rows. Unweighted `PERCENTILE_CONT` computes a different statistic: on the issue's fixture it interpolates 3 where the weighted lower-CDF threshold selects 2. This PR adds the native exact weighted percentile `quantileExactWeighted(value, weight, level)` computing `min { v present : F(v) >= k }` with `k = ceil(level * W)` in exact big-integer arithmetic: - Grammar: a `QUANTILE_EXACT_WEIGHTED` aggregate rule with `DISTINCT` and window support, the keyword map entry, and `mysql_sql.go` regenerated through the repository's in-tree goyacc make target under its zero-conflict gate; a parser UT covers the plain, DISTINCT, window-partition and window-ROWS-frame forms, and the full parser corpus passes. - Registration/binding: function id 616 in both registries (re-issued from the pre-merge draft 606 when upstream matrixorigin#31017's indicator kernels allocated 605-615; the design's first-unassigned-id rule, recorded in the document's second post-merge annotation); typed weight admission (int widths, BIT, UINT64, FLOAT32/64, DECIMAL64/128) with DECIMAL256 rejected at bind; flat three-argument layout whose level parameter is constant-or-prepared configuration, re-evaluated per EXECUTE through the shared validated percentile codec; sliding time-window contexts rejected like the ordered-set percentiles. - Executor (new `pkg/sql/colexec/aggexec/quantile_exact_weighted.go`): weights validated in their own type before exact uint64 conversion with a total-overflow abort; the paired-NULL rule; `DISTINCT` deduplicates exact (value, weight) typed pairs; typed saved state with interim wire and spill round trips; finalization restores one group's typed value rows once while converting every retained weight exactly once in the same arena scan (per-group temporary footprint is the restored value rows plus the 8-byte-per-row sort selectors and converted uint64 collapse weights — (valueWidth + 16) × N plus the result/bitmap tail — with no second pair-payload copy), sorts through an interruptible in-package heap order whose comparator reproduces SortByVectors' SQL-order relation exactly, checks context at chunk entry, per-row entry, the restore scan, inside the sort at a bounded swap cadence and the cumulative scan at a bounded row cadence, frees partially built results only on the error path, transfers successful output ownership to the caller, and constructs retained-pair errors only inside failing branches so a valid finalization reports no errors. - Window: admitted beside the ordered-set percentiles for full-partition frames (ordered-set fast path) and sliding ROWS frames (generic per-frame path); the window binder carries `DISTINCT` through for this aggregate exactly like the group-aggregate binder records it, while every other DISTINCT window aggregate stays NYI. - Distributed: destination-verified remote dispatch gated on MORPC protocol 131 at encode time (requiredProtocol floor over pipelines containing the aggregate), send time (per-destination stream confirmation) and compile time (AllCNsSupportProtocol fast-fail plus the coordinator self-gate). ### Issue-to-test proof (matrixorigin#29944) - Red/green on the assigned base `e3a6ffe27c`: the identical self-contained BVT file `test/distributed/cases/function/func_aggr_weighted_quantile.test` (76 statements) fails on the clean base - the issue's own probe is rejected 3/3 with (20105, "not supported: function or operator 'quantileexactweighted'") and the compared mo-tester run passes only 47/76 with every quantileExactWeighted statement failing (20105 bind rejections for flat calls, SQL parser errors for window/DISTINCT forms) - and passes 76/76 at a 100% success rate on this branch, where the issue fixture returns 2 beside the 3.0 unweighted control. - Every generated BVT value was hand-verified against exact `k = ceil(level * W)` mathematics before adoption: GROUP BY partitions, full-partition and cumulative-ROWS windows, DISTINCT windows (distinct 2.0 vs plain 6.0 with the dedup row flipping inside both a partition and a bounded frame), ties, zero-weight endpoints (trailing zero weight at level 1, massless leading value at level 0, all-zero group), empty and all-skipped groups returning NULL, typed UINT64 weights above 2^53 accepted exactly (W=18014398509481985, k=9007199254740993 = F(1)), DECIMAL(20,0) and literal weights, prepared levels re-evaluated per EXECUTE (0.25 -> -1, 0.75 -> 4), and the documented rejections (level out of range, fractional and negative weights, DECIMAL(65,0) weight rejected at bind). ### Validation Executed locally on the final tree (macOS/arm64, native cgo artifacts built by `make cgo`), using `.agents/skills/mo-dev/scripts/mo-cgo-test` as the repository CGo wrapper: - `--count=1 -run 'TestQuantile|TestAccounted...AllocationFailure' ./pkg/sql/colexec/aggexec/` -> ok: the executor matrix (issue fixture, endpoints, 128-bit threshold arithmetic, typed-weight witnesses, overflow with allocated-memory accounting, merge equivalence, wire round trips, DISTINCT + spill, dispatch/config guards, the Flush -> executor-free -> repeated-read output-ownership witness), the rewritten large-group cancellation witness with deterministic flip points mid-restore, at sort entry, deep inside the sort's element work, mid cumulative scan and between groups (leak-free on every abort), the sort-interruption unit witnesses (pre-cancelled context stops the sort with zero element moves; mid-work abort after the bounded swap checkpoint), the ordering-parity witness against SortByVectors for every supported value type (NaN/±Inf/−0/+0/extremes/duplicates), the 8192-row peak-scratch witness (measured within (valueWidth + 16) × N and admitted under an enforced-budget account) and the two allocation-failure sweep cases green. - `--count=1 -run 'TestWindowQuantileExactWeighted' ./pkg/sql/colexec/window/` -> ok: full-partition broadcast, retained-partition-result survival after executor destruction across output chunks, and DISTINCT windows over a full partition and a bounded frame, plus the 40000-row large-partition cancellation regression (a context cancelled after Prepare makes vm.Exec return the standard cancellation error before any partition result is broadcast; the finalize's own mid-work abort points are pinned by the executor-level regression). - `--count=1 -run 'TestQuantileExactWeighted|TestPreflightQuantileExactWeighted' ./pkg/sql/compile/` -> ok: prepared-level preflight and reuse, config extraction keeping original argument types, the protocol-131 floor, the 129/130/131 dispatch matrix (including a worker advertising only upstream's temporal 130), the coordinator self-gate and the stream-confirmation seam. - `--count=1 -run 'TestQuantileExactWeightedDistinctWindowBinding|TestBindWindowFuncExprValidationAndHelpers|TestPreparedQuantileExactWeightedParameters' ./pkg/sql/plan/` -> ok. - Full normal-mode owning packages: `./pkg/sql/colexec/aggexec/`, `./pkg/sql/colexec/window/`, `./pkg/sql/compile/`, `./pkg/sql/plan/`, `./pkg/defines/` all ok; the full parser corpus and `./pkg/sql/plan/function/` also pass. - BVT via the shared mo-tester against an isolated local service: genrs regenerated the checkpoint, every value inspected, compared run 76/76 with run exit 0 on this branch and 47/76 with run exit 1 on the clean base build. - `gofmt -l` empty over all changed Go files; `go vet` clean on all owning packages. ### Residual risks / follow-ups - Only `quantileExactWeighted` carries DISTINCT through windows; generalizing DISTINCT windows to other aggregates is out of scope here. - Sliding ROWS frames recompute per frame through the generic aggregate path; the full-partition fast path covers the common case. - The MORPC-131 mixed-version gates are proven at seam/UT level and by single-process SQL; a real multi-CN mixed-version cluster remains CI territory. - The BVT checkpoint embeds current diagnostic wording; unrelated wording drift would need one checkpoint regeneration, as with any BVT result. ### Design gate: recorded approval This feature triggers the mandatory design-first gate (new public SQL API, cross-package aggregate state, mixed-version MORPC dispatch; contract at `.agents/skills/mo-dev/references/feature-design-review.md`). Review order was honored end to end: a versioned design document was written first and reviewed in five design-only rounds while implementation stayed blocked — four REQUEST_CHANGES decisions (revisions 1-4; each returned blocker and its fix is recorded in the document's own revision log: typed weight admission, exact big.Int threshold domain, destination-verified MORPC protocol gating, typed saved-state schema, finalization resource and output ownership) — and then: - **Reviewed design**: [`docs/design/20261023-exact-weighted-percentiles.md`](https://github.com/gouhongshen/matrixone/blob/60d88ff6adb4ae6ea9e1ba0946ee82bc61f26ea7/docs/design/20261023-exact-weighted-percentiles.md), revision 5. The approved revision-5 content is SHA256 `b2705c13ab4d3f9965ab3d83a6f3e4a83d3426e4ffefdcdc8b6713864c69e083`, byte-preserved at commit `60d88ff6adb4ae6ea9e1ba0946ee82bc61f26ea7` (the commit that introduced the document), so the reviewed bytes remain verifiable against that hash. - **Reviewer**: independent design-review session, separate from the implementing author (issue-fix loop review session `01a16996-b2e8-76a1-aa31-f47fd5a0737d`), applying the repository's feature-design-review contract; design-only checkpoint, no repository state modified during the review. - **Decision**: PASS, 2026-10-24 — "Numerical semantics, typed saved state, destination protocol gates and corrected output ownership are coherent with the inspected code. No blocking design findings remain." One non-blocking P3 (exercise executor destruction before retained-result reads); the window UT covers it (flush -> executor teardown -> retained-result reads -> caller release). - **Document/PR reconciliation**: commit `0afd975232` records this decision inside the design document itself — its Status section now states the approval (decision, date, reviewer, reviewed revision and content hash) and the header links this PR, replacing the pre-review "pending" wording. Documentation-only annotation; no reviewed decision, invariant, or validation plan changed. - The separate implementation review reused this recorded design approval, verified the implementation against the design, and returned its own PASS. ### CI follow-up: race-mode UT failure fixed The `UT Test on Ubuntu/x86` job runs the unit tests with `-race`, where `pkg/container/vector`'s race build (`compile_config_race.go` -> `checkType`) enforces generic access typing. `TestQuantileExactWeightedEmptyAndSkippedGroups` appended the untyped literals `0`/`1` through `vector.AppendFixed` into `T_float64` vectors, binding the generic parameter to `int`: under `-race` the weight append panicked with `type mismatch: casting float64 vector to []int` (surfaced by the test's deferred allocation check, 0 expected vs 557056 actual), while a non-race build silently wrote int bit patterns into the float64 weights. The two literals are now the float64 literals `0.0`/`1.0`, so the generic binds to the vector's element type. A sweep of the other generic vector call sites this PR adds found no similar untyped-literal misuse. - Red/green at the pushed head `3fb5563e` with the repository wrapper: `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -run '^TestQuantileExactWeightedEmptyAndSkippedGroups$' ./pkg/sql/colexec/aggexec` failed with the exact CI signature (`checkType` panic reached through `AppendFixed` at `quantile_exact_weighted_test.go:135`), and passes after the change. - Package-level race parity for the failed CI job on the fixed tree: `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 ./pkg/sql/colexec/aggexec` -> ok (31.8s), zero failing tests. - Regression and static checks: focused normal-mode `-run 'TestQuantileExactWeighted'` on the same package passes; `gofmt` and `go vet` on the package are clean. ### Review-fix round: finalization cancellation and memory conformance (D12) The requested-changes review (`mo-bot-local`, commit `0afd975`) returned two P2 findings on finalization — cancellation inside the sort/scan of a large group or window partition, and a temporary footprint beyond the approved resource model — and the delivered code has been conformed to the approved design revision 5 (no design decision changed, so no re-review was required). - **In-sort and in-scan cancellation (was `quantile_exact_weighted.go:371`)**: `SortByVectors` carried no context and the final cumulative scan had no checkpoint, so cancellation waited for the entire sort. Finalization now sorts through an executor-owned interruptible heap order (`quantileSortSelectors`) that checks the context at sort entry and after every 1024 elementary swaps, mirroring pkg/sort's own heapsort shape; the cumulative scan checks the same 1024-row cadence. The comparator reproduces `SortByVectors`' SQL-order relation per value type (integer/BIT width compares, `Float32/64OrderAscCompare`'s deterministic NaN/−0 total order, `Decimal64/128.Lt`), pinned by `TestQuantileSortSelectorsMatchesSortByVectors` over identity selectors for every supported value type including NaN/±Inf payloads, −0.0/+0.0, width extremes and duplicates. - **Single-scan restore (was `:475`)**: the finalize path no longer materializes a typed weight column at all. `restorePairs` walks the retained arena once per group, restoring only the typed value rows (the sort key and `UnionOne` output source — the same in-flight restore `orderedPercentileDiscreteExec` performs) while converting every retained weight exactly once into the converted-weight scratch and accumulating the total W with the overflow abort in the same pass. Per-group temporary footprint is now (valueWidth + 16) × N plus the result/bitmap tail — 24N for INT64/UINT64 (was 32N) and 32N for two DECIMAL128 columns (was 48N) — with no second pair-payload copy. - **Regressions**: `TestQuantileExactWeightedCancellation` was rewritten from three single-pair groups (the reviewer's stale-fixture concern) to a 4096-row group whose deterministic check sequence is learned from a counting-context warmup, pinning flips mid-restore, at the sort's entry, deep inside the sort's element work, mid cumulative scan, and between groups after partial output — each abort surfaces the cause at exactly the first cancelled check and returns the pool to its baseline. `TestQuantileSortSelectorsInterruptsInsideElementWork` proves a pre-cancelled context stops the sort before its first element move and a bounded-checkpoint abort stops mid-work (selectors neither identity nor fully sorted). `TestQuantileExactWeightedFinalizeScratchHonorsDesignBudget` arms an allocation-account controller over a real 8192-row group for INT64/UINT64, INT64-with-DECIMAL128-weight and DECIMAL128/DECIMAL128: the measured peak temporary capacity stays within — and above — the (valueWidth + 16) × N budget (the lower bound proves the restore, selectors and converted weights are genuinely simultaneous), and an admission run that denies any byte beyond the budget still finalizes the group correctly. `TestWindowQuantileExactWeightedLargePartitionHonorsCancellation` drives a 40000-row full-partition window with a context cancelled after Prepare and gets the standard cancellation error back through `vm.Exec` before any partition result is broadcast; the finalize's own mid-work abort points are pinned deterministically by the executor-level witnesses, and window partitions reuse the same `FlushWithContext` finalize and therefore the same cadence and budget. - Overflow semantics are unchanged: the uint64 wrap is detected during the restore scan instead of after the sort (any accumulation order detects the same wrap), with the same invalid-input abort and error-only result cleanup. DISTINCT/merge/wire/spill state is untouched. Local evidence (`mo-cgo-test`): the focused aggexec executor suite plus both allocation-failure sweeps, the `TestQuantileSortSelectors*` interruption and ordering-parity witnesses, and the window quantile suite including the large-partition cancellation all exit 0; `gofmt` is clean and `go vet` and `golangci-lint --new-from-rev` report zero findings on the changed packages. ### Update: semantic merge of `main` — MORPC capability slot re-minted 130 -> 131 Upstream `main` merged matrixorigin#30311 (`5a813a324d`, incomplete temporal string overloads), which independently minted `MORPCVersion130` and moved the `MORPCLatestVersion` sentinel to 130 — the same slot this branch had drafted for `quantileExactWeighted`'s remote-dispatch gate, leaving the PR DIRTY. Merge commit `2eecad8753` resolves it semantically; per the approved design's D10, no design decision changed, so no design re-review is required. - `pkg/defines/const.go`: upstream's temporal `MORPCVersion130` is kept, and this aggregate's capability version is re-minted at the next free slot — `MORPCVersion131 int64 = 131 // exact weighted percentile aggregate remote dispatch` — with `MORPCLatestVersion` moved to 131. All `MORPCLatestVersion` consumers use the symbol, so they follow the bump unchanged. - The aggregate's three verified gate layers (the `encodeRemoteScopeWithProtocol` `requiredProtocol` floor, the `AllCNsSupportProtocol` compile-time fast-fail, the coordinator self-gate message) and the protocol UT now reference `MORPCVersion131`; every upstream temporal gate keeps 130. The self-gate message now reads `quantileExactWeighted remote execution requires MORPC protocol version 131`. - The protocol UT gains the mixed-version counterexample the collision creates: a worker advertising only the temporal `MORPCVersion130` is below the aggregate's gate and fails closed both at the inventory fast-fail (coordinator at 131, worker at 130 — `supportsQuantileExactWeightedDispatch` false, shuffle-group compilation refused, remote group wire unsupported) and at the pre-dispatch stream confirmation (confirming 131 against a 130 worker errors before any pipeline payload). - The approved design document records this in its revision log as a post-merge annotation: D10's reviewed contract is that dispatch is gated by the capability version minted for THIS aggregate at whichever slot is free when it merges — only the concrete slot number moved (130 drafted pre-collision, 131 delivered), with the approved revision-5 bytes still byte-preserved at introducing commit `60d88ff6ad`. No decision, invariant, layering or validation plan changed. Validation of the merged tree (the tree that became `2eecad8753`, local macOS/arm64, `mo-cgo-test` wrapper): - `mo-cgo-test --count=1 -run 'TestQuantileExactWeighted|TestPreflightQuantileExactWeighted' ./pkg/sql/compile/` -> exit 0: the re-minted gate floor (`requiredProtocol` = 131 when an encoded pipeline carries the aggregate), the coordinator self-gate message at version 131, the compile-time inventory fast-fail across 129/130/131 — including the new counterexample: coordinator at 131 with a worker advertising only the temporal 130 fails closed (`supportsQuantileExactWeightedDispatch` false, shuffle-group compilation refused, remote group wire unsupported) — and the pre-dispatch stream confirmation (131 accepted; the temporal-130 worker, 129 and unknown capability rejected before any payload). A `-list` enumeration confirms all three expected test names matched, and a `-v` rerun on the same tree records every PASS line, including the `worker_at_temporal_gate,_below_aggregate_gate` subtest. - `mo-cgo-test --count=1 -run 'TestQuantile|TestAccounted' ./pkg/sql/colexec/aggexec/` -> exit 0: the full quantile executor matrix (issue fixture, endpoints, exact threshold arithmetic, typed weights, overflow, merge, wire, DISTINCT + spill, interruptible finalize) plus every allocation accounted/sweep case on the merged tree — upstream's Decimal128 short-coefficient rework (`0abc1d317a`) is inside this package's dependency closure. - `mo-cgo-test --count=1 -run 'TestWindowQuantileExactWeighted' ./pkg/sql/colexec/window/` -> exit 0: full-partition broadcast, retained-result survival after executor destruction, DISTINCT windows and the 40000-row large-partition cancellation witness on the merged tree (all four expected test names enumerated via `-list`). - `mo-cgo-test --count=1 -run 'TestQuantileExactWeightedDistinctWindowBinding|TestBindWindowFuncExprValidationAndHelpers|TestPreparedQuantileExactWeightedParameters' ./pkg/sql/plan/` -> exit 0: binder/prepared-parameter behavior on the merged tree (upstream's base_binder/query_builder/utils changes auto-merged here; all three test names enumerated). - `mo-cgo-test --count=1 -run 'TestAggregateExecutorIDs|TestQuantileExactWeightedRegistration|TestQuantileExactWeightedCheckFnVerifiesTypedAdmission' ./pkg/sql/plan/function/` -> exit 0: the executor/function-id registry test (function id equality across both registries; 606 at that time, 616 after the second merge renumber) and typed-admission/registration checks on the merged tree. - `mo-cgo-test --count=1 ./pkg/sql/parsers/...` -> exit 0: the full parser corpus (`pkg/sql/parsers`, `dialect/mysql`, `dialect/postgresql`, `tree` all `ok`; `pkg/sql/parsers/util` changed upstream) — includes this PR's quantile grammar parser test. - Compile/link closure of the merged tree before the focused runs: defines, aggexec, compile and parsers packages all built and linked; static checks on the cons closure: `gofmt -l` clean over every changed file and `go test -vet=all` (full vet) exit 0 on `pkg/defines` and `pkg/sql/compile`. Local logs are preserved under `issue-29944/merge-conflict-resolution/` in the loop's state artifacts directory. ### Update: semantic merge of `main` (second) — ID-space collision 606 -> 616 and window-binder coexistence Upstream `main` advanced past the first merge's base (`ac13078b98`) with matrixorigin#31017 (`6fb6531432`, technical-indicator window kernels, whose registry allocated SQL function ids 605-615 beside `MO_VIEW`'s internal 603/604 helpers), matrixorigin#31021 (`a1888d62f8`) and matrixorigin#31035 (`f4343be0ae`), leaving the PR DIRTY (content conflicts in `pkg/sql/plan/function/function_id.go`, `function_id_test.go`, `pkg/sql/plan/window_binder.go` and the generated parser). The resolution keeps every upstream change and re-issues this aggregate's colliding bits: - `QUANTILE_EXACT_WEIGHTED = 616`, the sentinel `FUNCTION_END_NUMBER = 617`: upstream's indicator registry owns 605-615, so this aggregate takes the first unassigned catalog id past the current sentinel — the approved design's own allocation rule, with only the concrete number moved (606 drafted, 616 delivered; recorded in the design document's second post-merge annotation, a documentation change, not a design revision). `AggIdOfQuantileExactWeighted` tracks it as `616 << 32`; `Test_funids`'s predefined-Funids mapping, the composite-id assertion and the stale "cluster protocol 130" comment on the constant (now 131) follow. - `window_binder.go` keeps both independent hooks: this feature's DISTINCT window-aggregate recording and upstream's indicator-window `validateIndicatorWindowSpec` gate — disjoint paths, both exercised by their respective suites on the merged tree. `mysql_sql.go` is regenerated through the repository's in-tree goyacc make target under its zero-shift/reduce-conflict gate from the cleanly merged grammar (both this feature's `QUANTILE_EXACT_WEIGHTED` rules and upstream's grammar changes retained). - The dispatch gate stays on `MORPCVersion131`; `pkg/defines/const.go` auto-merged cleanly. Validation of the merged tree (local macOS/arm64, `mo-cgo-test` wrapper, ladder v3): - `mo-cgo-test --count=1 -run '^$' ./pkg/defines/ ./pkg/sql/colexec/aggexec/ ./pkg/sql/colexec/window/ ./pkg/sql/compile/ ./pkg/sql/plan/ ./pkg/sql/parsers/...` -> exit 0: compile/link of the whole owning closure on the merged tree (the working tree that became the merge commit). - `mo-cgo-test --count=1 -run 'TestQuantile|TestAccounted' ./pkg/sql/colexec/aggexec/` -> exit 0: the full quantile executor matrix — 67 matched tests (`-list`), including the 8192-row peak-scratch budget, cancellation/witness and `SortByVectors`-parity suites — green with `AggIdOfQuantileExactWeighted = 616 << 32`. - `mo-cgo-test --count=1 -run 'Test_funids' ./pkg/sql/plan/function/` and `-run 'TestAggregateExecutorIDs'` -> exit 0 both: the predefined-Funids consistency audit (616/617 entries, upstream's 605-615 kept) and the cross-registry id-equality circuit. - `mo-cgo-test --count=1 -run 'Quantile|FunctionID|Funids' ./pkg/sql/plan/function/` -> exit 0: registration and typed-admission checks on the merged registry (`TestQuantileExactWeightedRegistration`, `TestQuantileExactWeightedCheckFnVerifiesTypedAdmission` enumerated via `-list`). - `mo-cgo-test --count=1 -run 'TestQuantileExactWeightedDistinctWindowBinding|TestBindWindowFuncExprValidationAndHelpers|TestPreparedQuantileExactWeightedParameters|TestIndicatorBinderSurface|TestIndicatorRegistryBits|TestIndicatorDeduceNotNullablePins' ./pkg/sql/plan/` -> exit 0: the manually resolved window-binder seam holds both sides — this feature's DISTINCT binding and upstream's indicator binder surface (all six names enumerated via `-list`). - `mo-cgo-test --count=1 -run 'TestWindowQuantileExactWeighted|TestIndicatorOperator|TestIndicatorChunkedEmit|TestIndicatorScanCancellationLatency' ./pkg/sql/colexec/window/` -> exit 0: this feature's four window-quantile witnesses and upstream's indicator operator emit/reset/cancel/lifecycle seams coexist on the auto-merged `window.go` (eleven names enumerated via `-list`). - `mo-cgo-test --count=1 -run 'TestQuantileExactWeighted|TestPreflightQuantileExactWeighted' ./pkg/sql/compile/` -> exit 0: the 129/130/131 dispatch matrix (including the temporal-130-only counterexample) and prepared-level preflight re-proven on the merged tree. - `mo-cgo-test --count=1 ./pkg/sql/parsers/...` -> exit 0: full parser corpus (`pkg/sql/parsers`, `dialect/mysql`, `dialect/postgresql`, `tree`) against the regenerated `mysql_sql.go`, which is goyacc-verified (zero shift/reduce conflicts) to carry both this feature's `QUANTILE_EXACT_WEIGHTED` grammar and upstream's changes. - `gofmt -l` clean over every changed file; `git diff --check` clean. Ladder v3 preserved per-step exit-status files: every step 0. Local logs are preserved under `issue-29944/merge2-conflict-resolution/` in the loop's state artifacts directory. ### Update: third merge of `main` — tracked CI blocker matrixorigin#31044 resolved (closed NOT_PLANNED); fresh-head re-evaluation With the second merge's head `f79bbb0dbe` terminally red only on the coverage lanes that tracked issue matrixorigin#31044 (run [40105576983](https://github.com/matrixorigin/matrixone/actions/runs/40105576983) attempt 4: `UT Coverage` producer flake with `Coverage`/`CI Required` as its projections) and that run's failed-jobs rerun budget consumed (attempts 3–4 were re-queued externally), the open→closed transition of matrixorigin#31044 was verified and the resolved-blocker contract was followed: current `main` was incorporated so the required checks get a fresh evaluation on a new head, and the stale run is not rerun. - **Verified blocker resolution**: matrixorigin#31044 was closed at 2026-10-24T21:37:23Z as NOT_PLANNED by XuPeng-SH — the closing review of the complete retained coverage artifact confirmed the complete `CHECK` namespace and all four cross-target recovery scenarios pass on current main `dae02bbaaa` (linux/amd64 race + matrixone_test, package 120.959s, manual-ready 16.71s), explicitly reviewed this PR's attempt-4 reproduction record, and re-classified it as package-budget boundary behavior rather than a recovery defect. No `pkg/embed` change was merged upstream (the six upstream commits touch no path under `pkg/embed`), so current main is the upstream state under which the blocker was declared resolved. - **Base update**: merge of `main` `dae02bbaaa` (upstream matrixorigin#31040 derived-group-by pruning, matrixorigin#31048 composite secondary-index filters, matrixorigin#30886 logservice mutation budgets, matrixorigin#30925 FK `ON DELETE/UPDATE SET NULL` guard, matrixorigin#31001 partition Top-1, matrixorigin#31041 `COM_QUIT` connection close) into `f79bbb0dbe` → `bbd761648c`. A clean auto-merge with zero content conflicts (`git merge-tree --write-tree` dry run: none): the only shared file `pkg/sql/plan/query_builder.go` merged at disjoint hunks (this feature's `NameQuantileExactWeighted` constant vs upstream's `createQuery`/`bindSelect` aggregate-consumer regions). `QUANTILE_EXACT_WEIGHTED` keeps catalog id 616 and `FUNCTION_END_NUMBER` 617 (upstream allocated no SQL function ids), the D10 wire gate `MORPCVersion131` is untouched, and the goyacc-verified generated parser stands byte-unchanged (no upstream grammar change); the upstream range contains no `.github` content. No reviewed design decision changed, so no design re-review was required. The update is a merge, not a rebase: every cited evidence hash stays reachable from the new head (the approved revision-5 bytes byte-preserved at `60d88ff6adb`, the remediation commits `0afd975232`/`5b60194404db`, prior merge `f79bbb0dbe`, and the recorded run identities). Validation of the merged tree (local macOS/arm64, `mo-cgo-test` wrapper, ladder v4 — the second merge's proven ladder set, plus the upstream test families that landed in packages this feature owns or at its binding seam: `sum_local_table_test.go` in aggexec and `derived_group_by_test.go`'s aggregate-consumer pruning tests in plan): - `mo-cgo-test --count=1 -run '^$' ./pkg/defines/ ./pkg/frontend/ ./pkg/logservice/ ./pkg/util/executor/ ./pkg/sql/colexec/aggexec/ ./pkg/sql/colexec/window/ ./pkg/sql/colexec/partition/ ./pkg/sql/compile/ ./pkg/sql/plan/ ./pkg/sql/plan/function/ ./pkg/sql/parsers/...` -> exit 0: compile/link proof of the whole owning closure extended with the upstream-touched runtime packages (`frontend`, `logservice`, `util/executor`, `colexec/partition`) — every test binary builds against the merged tree. - `mo-cgo-test --count=1 -run 'TestQuantile|TestAccounted|TestSumFullLocalTable' ./pkg/sql/colexec/aggexec/` -> exit 0 (`ok ... 4.391s`): 67 matched tests via `-list` (45 `TestQuantile*` + 20 `TestAccounted*` + upstream's 2 new `TestSumFullLocalTable*`) — the full quantile executor matrix including the 8192-row peak-scratch budget, cancellation/witness and `SortByVectors`-parity suites green with `AggIdOfQuantileExactWeighted = 616 << 32`, plus upstream's grouped-SUM local-table regressions coexisting in the same package. - `mo-cgo-test --count=1 -run 'Quantile|FunctionID|Funids' ./pkg/sql/plan/function/` -> exit 0 (`ok ... 2.015s`): registration, typed-admission and Funids registry-consistency checks (616/617 kept; upstream's 605-615 intact). - `mo-cgo-test --count=1 -run 'TestQuantileExactWeightedDistinctWindowBinding|TestBindWindowFuncExprValidationAndHelpers|TestPreparedQuantileExactWeightedParameters|TestIndicatorBinderSurface|TestIndicatorRegistryBits|TestIndicatorDeduceNotNullablePins|TestPruneDerivedGroupBy|TestBuildPlanPrunesDerivedGroupKeys' ./pkg/sql/plan/` -> exit 0 (`ok ... 2.533s`): 10 matched tests via `-list` — this feature's DISTINCT window binding, helper-validation and prepared-parameter cases, upstream's indicator binder surface, and upstream's new derived-group-by pruning tests at the aggregate-consumer seam, all exercising the merged `query_builder.go`. - `mo-cgo-test --count=1 -run 'TestWindowQuantileExactWeighted|TestIndicatorOperator|TestIndicatorChunkedEmit|TestIndicatorScanCancellationLatency' ./pkg/sql/colexec/window/` -> exit 0 (`ok ... 2.674s`): 11 matched tests via `-list` — the window-quantile witnesses (including the 40000-row full-partition cancellation) and upstream's indicator operator emit/reset/lifecycle seams. - `mo-cgo-test --count=1 -run 'TestQuantileExactWeighted|TestPreflightQuantileExactWeighted' ./pkg/sql/compile/` -> exit 0 (`ok ... 4.440s`): the 129/130/131 dispatch matrix (including the temporal-130-only counterexample) and prepared-level preflight re-proven on the merged tree. - `mo-cgo-test --count=1 ./pkg/sql/parsers/...` -> exit 0: full parser corpus — `pkg/sql/parsers`, `dialect/mysql`, `dialect/postgresql` and `tree` all `ok` against the byte-unchanged goyacc-verified `mysql_sql.go`. - Static: `gofmt -l` over the feature-owned files and the auto-merged `query_builder.go` -> clean; `git diff --check` -> clean; `git status --porcelain` -> empty. Every step wrote an individual exit-status file; the ladder's overall status is 0. Local logs and per-step exit-status files are preserved under `issue-29944/merge3-conflict-resolution/` in the loop's state artifacts directory. ### Update: fourth merge of `main` — function-id re-issue 616 -> 619 (matrixorigin#31020 claimed the catalog tail) GitHub reported this PR DIRTY/CONFLICTING against head `bbd761648c` because upstream `main` advanced to `ac4ec31587` (matrixorigin#31020, local sliding-window ranks `mrank`/`cumrank`/`tmrank` — a feature that itself had been renumbered around matrixorigin#31017's 605-615 indicator block when it merged, and allocated SQL function ids `MRANK = 616`, `CUMRANK = 617`, `TMRANK = 618` with `FUNCTION_END_NUMBER = 619`). That is exactly the tail this aggregate occupied after its own second merge (`QUANTILE_EXACT_WEIGHTED = 616`, sentinel 617), so three content conflicts followed: `pkg/sql/plan/function/function_id.go`, `function_id_test.go`, and the generated parser `pkg/sql/parsers/dialect/mysql/mysql_sql.go`; the grammar (`mysql_sql.y`), keywords, window operator and window-binder seams auto-merged with disjoint paths. The upstream range contains no `.github` content. The resolution applies the approved design's recorded first-unassigned-id allocation rule unchanged — the same rule as the second merge, applied to new inputs; no design decision, invariant, admission set or validation plan changed, and the D10 wire gate `MORPCVersion131` is untouched: - Upstream's `MRANK = 616`, `CUMRANK = 617`, `TMRANK = 618` are kept; `QUANTILE_EXACT_WEIGHTED` is re-issued to the first unassigned catalog id `619`, with `FUNCTION_END_NUMBER = 620` (one past the highest allocated id). Every reference to this aggregate's id is by name, so renumbering is safe. - `AggIdOfQuantileExactWeighted` tracks the catalog id as `619 << 32` (in `pkg/sql/colexec/aggexec/function_id.go`); the executor-id tracking assertion in `pkg/sql/plan/function/quantile_exact_weighted_test.go` and the `Test_funids` predefined-pin map follow (the merged map pins MRANK 616, CUMRANK 617, TMRANK 618, QUANTILE_EXACT_WEIGHTED 619, FUNCTION_END_NUMBER 620). - The generated parser was regenerated through the repository's in-tree goyacc make target under its zero shift/reduce-conflict gate (0 conflicts, exit 0) from the cleanly merged grammar, which carries both this feature's `QUANTILE_EXACT_WEIGHTED` productions and upstream's `MRANK`/`CUMRANK`/`TMRANK` grammar (confirmed in the merged `mysql_sql.y` and `keywords.go`: `"quantileexactweighted"` beside `"mrank"`/`"cumrank"`/`"tmrank"`). - The auto-merged seams keep both sides' coexisting paths: upstream's rank-width binder/operator additions beside this aggregate's DISTINCT window hook, percentile-config normalization and executor wiring (`base_binder.go`, `window_binder.go`, `pkg/sql/colexec/window/window.go`). - `docs/design/20261023-exact-weighted-percentiles.md` records the re-issue as its third post-merge annotation — documentation change only, not a design revision; the approved revision-5 bytes remain byte-preserved at introducing commit `60d88ff6adb`. Merge (not rebase), preserving every cited evidence hash — revision-5 design bytes at `60d88ff6adb`, remediation commits `0afd975232`/`5b60194404db`, prior merges `2eecad8753`/`f79bbb0dbe`/`bbd761648c`, and the recorded workflow-run identities. Validation of the merged tree (local macOS/arm64, `mo-cgo-test` wrapper, ladder v5, `ddc46c416b`; every step exit 0, per-step status files preserved under `issue-29944/merge4-conflict-resolution/` in the loop's state artifacts): - `mo-cgo-test --count=1 -run '^$' ./pkg/defines/ ./pkg/frontend/ ./pkg/logservice/ ./pkg/util/executor/ ./pkg/sql/colexec/aggexec/ ./pkg/sql/colexec/window/ ./pkg/sql/colexec/partition/ ./pkg/sql/compile/ ./pkg/sql/plan/ ./pkg/sql/plan/function/ ./pkg/sql/parsers/...` -> exit 0: compile/link of the owning closure on the merged tree (including upstream-touched window/plan/parser/special-types files and upstream's `bindFuncExprImplByPlanExpr` signature change, whose merged call sites all use the new signature). - `mo-cgo-test --count=1 -run 'TestQuantile|TestAccounted|TestSumFullLocalTable' ./pkg/sql/colexec/aggexec/` -> exit 0 (`ok 1.999s`): the full quantile executor matrix — the same 67-test set as ladder v4 (the merge's only aggexec delta vs `bbd761648c` is the tracking constant `619 << 32`) — green. - `mo-cgo-test --count=1 -run 'Quantile|FunctionID|Funids' ./pkg/sql/plan/function/` -> exit 0 (`ok 1.522s`): `Test_funids` with the merged pin map and `TestAggregateExecutorIDs` cross-registry equality (catalog 619 == `619 << 32` executor id), registration and typed-admission checks. - `mo-cgo-test --count=1 -run '...8-name set...|TestLocalRank' ./pkg/sql/plan/` (full pattern: `TestQuantileExactWeightedDistinctWindowBinding|TestBindWindowFuncExprValidationAndHelpers|TestPreparedQuantileExactWeightedParameters|TestIndicatorBinderSurface|TestIndicatorRegistryBits|TestIndicatorDeduceNotNullablePins|TestPruneDerivedGroupBy|TestBuildPlanPrunesDerivedGroupKeys|TestLocalRank`) -> exit 0 (`ok 2.098s`): 22 matched tests (`-list`) — this feature's binder/prepared-parameter/indicator surfaces beside upstream's 12 `TestLocalRank` binder and prepared-width families on the auto-merged `window_binder.go`/`base_binder.go`. - `mo-cgo-test --count=1 -run 'TestWindowQuantileExactWeighted|TestIndicatorOperator|TestIndicatorChunkedEmit|TestIndicatorScanCancellationLatency|TestLocalRank' ./pkg/sql/colexec/window/` -> exit 0 (`ok 12.374s`): 37 matched tests (`-list`) — the 4 window-quantile witnesses (including large-partition cancellation and executor-destruction retention) and upstream's 7 indicator seams and 26 `TestLocalRank` operator suites on the auto-merged `window.go`/`interval.go`/`local_rank.go`. - `mo-cgo-test --count=1 -run 'TestQuantileExactWeighted|TestPreflightQuantileExactWeighted' ./pkg/sql/compile/` -> exit 0 (`ok 1.690s`): the 129/130/131 dispatch matrix and prepared-level preflight re-proven on the merged tree. - `mo-cgo-test --count=1 ./pkg/sql/parsers/...` -> exit 0: full parser corpus (`pkg/sql/parsers`, `dialect/mysql` incl. upstream's `window_local_rank_parser_test.go` and this feature's `mysql_sql_test.go`, `dialect/postgresql`, `tree`) against the regenerated goyacc-verified parser. - Static: `gofmt -l` over the resolved and feature-owned files -> clean; `git diff --check` and `git diff --cached --check` -> clean. ### Update: review remediation — equal-key sort-work cancellation cadence (P2 · `quantile_exact_weighted.go:584`) The `mo-bot-local` review of head `ddc46c416b` requested changes for one P2: the interruptible heap sort charged its cancellation-checkpoint counter on sift-down element swaps only, and not even root-extraction swaps received a charge. With an equal-valued group every sift-down returns at the comparison without a swap, so the counter never advanced again: cancelling immediately after the sort's entry check let the whole sort run to completion (the review's 65,536-equal-values probe recorded `checks=1`, `selector_moves=65536`, `err=nil`), with the cancelled cause surfacing only at the later cumulative-scan checkpoints — a departure from approved D12's "bounded per-row cadence inside each group's finalization". Fix (commit `a4a7ef92bd`, `pkg/sql/colexec/aggexec/quantile_exact_weighted.go`): the checkpoint cadence now charges every elementary heap step — each sift-down iteration, including the comparing iterations that return without swapping, plus each root-extraction swap (the review's requested "count comparisons or iterations, including no-swap work"). `context.Cause` is re-checked at the sort's entry (unchanged) and after every `quantileSortCheckSteps = 1024` charged steps, before the next element move, so the work between checks stays bounded for every value distribution. The comparator, heap shape and selection order are untouched (the `SortByVectors` parity suite re-proves it); no design decision, invariant, admission set or validation plan changed, and DISTINCT/merge/wire/spill state is untouched. Regressions added per the finding (all in `quantile_exact_weighted_test.go`): - `TestQuantileSortSelectorsInterruptsEqualValuedWork` — the sort-level probe over 65,536 identical values: the counting warmup gates on real in-sort checkpoints; flipping at the first in-sort checkpoint surfaces the cancelled cause with zero element moves; a learned mid-extraction flip aborts with selectors neither identity nor the completed permutation. - `TestQuantileExactWeightedEqualValuedCancellation` — the executor-level regression ("cancel the finalization of a large equal-valued aggregate or window partition"; window partitions finalize through the same `FlushWithContext` path): a 4096-row equal-valued group's finalization cancelled at the sort's first in-work checkpoint and deep inside its element work surfaces the cause at exactly the first flipped check, frees every scratch and partial result, and a fresh executor over the same group still finalizes the correct value. - `TestQuantileSortSelectorsInterruptsInsideElementWork` retuned to the iteration-charged cadence (its old `n=2` flip pinned "after exactly 1024 swaps", which under descending input now fires during the no-swap heap build): the flip point is learned from a counting warmup, deep inside the extraction phase, keeping the same three assertions; it is an invariance witness on both cadences, green before and after this change. Validation of the remediation (local macOS/arm64, `mo-cgo-test` wrapper; per-step logs and exit-status files preserved under `issue-29944/review-equal-key-cancellation/logs/` in the loop state artifacts): - Pre-fix failure of the same new tests, implementation hunk stashed (`base-prefixed-code-fails.log`, exit 1): the sort-level equal-key warmup records exactly 1 checkpoint over 65,536 equal values and the executor-level equal-key group learns 11 total checks — zero in-sort checkpoints — both the review probe's signature. - Post-fix new regressions plus retuned descending witness exit 0 (`postfix-new-regressions-pass.log`, `ok 2.367s`). - Full aggexec matrix `TestQuantile|TestAccounted|TestSumFullLocalTable` exit 0 (`aggexec-full-quantile-matrix.log`, `ok 4.847s`; 69 matched tests via `-list`: 22 `TestQuantile*` + 45 `TestAccounted*` + 2 `TestSumFullLocalTable*` — the ladder-v5 67-test set plus the two new regressions), including the descending large-group cancellation matrix, the `SortByVectors` ordering-parity suite, the 8192-row peak-scratch budget admission and the allocation-failure sweeps. - `TestWindowQuantileExactWeighted` exit 0 (`window-quantile-witnesses.log`, `ok 1.419s`), including the 40000-row full-partition window cancellation through the shared finalization route. - Static: `gofmt -l` clean; `go vet` and `golangci-lint --new-from-rev ac4ec31` report zero findings on the changed closure under the repository CGo native environment; `git diff --check` clean. The fresh MatrixOne ALL CI run on the new head `a4a7ef92bd` re-evaluates every lane; the previous head `ddc46c416b` holds the recorded green verdicts (shared build, Ubuntu/x86 UT, arm64 SCA, UT Coverage, Coverage, `CI Required`, both multi-CN BVT compose legs, preflight, Iceberg Connector E2E). ### Update: fifth merge of `main` — conflict resolved against matrixorigin#30973's widened RANGE frame bounds GitHub reported this PR DIRTY/CONFLICTING against head `a4a7ef92bd` because upstream `main` advanced to `80ea60aaeb`, three commits past the merge-#4 base `ac4ec31587`: fix(window) matrixorigin#30973 (widen narrow integer RANGE frame bounds), fix(plan) matrixorigin#31015 (overlapping ON DELETE CASCADE/SET NULL order-independence) and fix(frontend) matrixorigin#31052 (preserve microseconds in session timestamp overrides). `merge-tree` pinned exactly **one** content conflict: `pkg/sql/plan/window_binder_test.go`, where matrixorigin#30973 appends `TestRangeFrameBoundTypeWidening` (plus its `T_int32`→`T_int64` prepared-marker assertion updates) at the same file tail this feature's `TestQuantileExactWeightedDistinctWindowBinding` occupies. Resolution (semantic union; no design change): the conflicted test file now carries **both** appended functions with upstream's widened marker assertions. `pkg/sql/plan/window_binder.go` and `pkg/sql/colexec/window/window.go` auto-merged because the seams are disjoint — this feature's DISTINCT window hook lives in `bindWindowFuncExpr` while matrixorigin#30973's `rangeFrameBoundType` call site lives in `bindWindowSpec`, and this feature's `orderedSetWindowAggregate` entry is a different function from matrixorigin#30973's `signedNarrowRangeBound`/`signedRangeOffsetValue` additions. This feature's tests use only ROWS frames, so the bound-widening change cannot alter any of this PR's expected outputs. Upstream allocated no SQL function IDs in this range: `QUANTILE_EXACT_WEIGHTED = 619`, `FUNCTION_END_NUMBER = 620` and every recorded id evidence stand, so no design-document annotation is required (no design decision, invariant, admission set or validation plan changed). The upstream range touches no `.github` and no mo-tester content. Merge (not rebase), preserving every cited evidence hash — revision-5 design bytes at `60d88ff6adb`, remediation commits `0afd975232`/`5b60194404db`/`a4a7ef92bd`, prior merges `2eecad8753`/`f79bbb0dbe`/`bbd761648c`/`ddc46c416b` — plus the recorded workflow-run identities. Validation of the merged tree (local macOS/arm64, `mo-cgo-test` wrapper, ladder v6, `a56f0b0313910268d8500260ec5572dfad514df7`; every step exit 0; console log, per-step status files and `-list` proofs preserved under `issue-29944/merge5-conflict-resolution/logs/` in the loop's state artifacts): - `mo-cgo-test --count=1 -run '^$' ./pkg/defines/ ./pkg/frontend/ ./pkg/logservice/ ./pkg/tests/issues/ ./pkg/util/executor/ ./pkg/sql/colexec/aggexec/ ./pkg/sql/colexec/window/ ./pkg/sql/compile/ ./pkg/sql/plan/ ./pkg/sql/plan/function/ ./pkg/sql/parsers/...` -> exit 0: compile/link of the owning closure on the merged tree (upstream's frontend, window, plan-DML and tests-issues files beside this feature's packages). - `mo-cgo-test --count=1 -run 'TestQuantile|TestAccounted|TestSumFullLocalTable' ./pkg/sql/colexec/aggexec/` -> exit 0 (`ok 1.512s`): the full quantile executor matrix — including the equal-key cancellation regressions, SortByVectors parity and budget/sweep witnesses — unchanged and green through the merge. - `mo-cgo-test --count=1 -run 'Quantile|FunctionID|Funids' ./pkg/sql/plan/function/` -> exit 0 (`ok 1.074s`): `Test_funids` with the unchanged pin map (MRANK 616, CUMRANK 617, TMRANK 618, QUANTILE_EXACT_WEIGHTED 619, FUNCTION_END_NUMBER 620) and `TestAggregateExecutorIDs` cross-registry equality (catalog 619 == `619 << 32`). - `mo-cgo-test --count=1 -run 'TestQuantileExactWeightedDistinctWindowBinding|TestBindWindowFuncExprValidationAndHelpers|TestPreparedQuantileExactWeightedParameters|TestIndicatorBinderSurface|TestIndicatorRegistryBits|TestIndicatorDeduceNotNullablePins|TestPruneDerivedGroupBy|TestBuildPlanPrunesDerivedGroupKeys|TestLocalRank|TestRangeFrameBoundTypeWidening|TestPreparedWindowRangeFrameMarkers' ./pkg/sql/plan/` -> exit 0 (`ok 1.623s`): 25 matched tests (`-list`) — this feature's binder/prepared-parameter surfaces and upstream's 12 `TestLocalRank` binder families (the merge-#4 set) beside the three new matrixorigin#30973 binder regressions (`TestRangeFrameBoundTypeWidening`, `TestPreparedWindowRangeFrameMarkers`, `TestPreparedWindowRangeFrameMarkersInBothBounds`), all on the auto-merged `window_binder.go`. - `mo-cgo-test --count=1 -run 'TestWindowQuantileExactWeighted|TestIndicatorOperator|TestIndicatorChunkedEmit|TestIndicatorScanCancellationLatency|TestLocalRank|TestBuildRangeIntervalWideSignedBounds' ./pkg/sql/colexec/window/` -> exit 0 (`ok 3.888s`): 38 matched tests (`-list`) — the four window-quantile witnesses, upstream's 7 indicator seams and 26 `TestLocalRank` operator suites (the merge-#4 37-test set) beside `TestBuildRangeIntervalWideSignedBounds`, on the auto-merged `window.go`. - `mo-cgo-test --count=1 -run 'TestQuantileExactWeighted|TestPreflightQuantileExactWeighted' ./pkg/sql/compile/` -> exit 0 (`ok 1.405s`): the compile dispatch and preflight sets re-proven on the merged tree. - `mo-cgo-test --count=1 ./pkg/sql/parsers/...` -> exit 0 (`pkg/sql/parsers`, `dialect/mysql`, `dialect/postgresql`, `tree` all `ok`): full parser corpus against the byte-unchanged goyacc-verified parser (this upstream range made no parser change; no regeneration was needed). - Static: `gofmt -l` over the resolved and auto-merged files -> clean; `git diff --check` and `git diff --cached --check` -> clean. The fresh MatrixOne ALL CI run on the new head re-evaluates every lane; the previous head `a4a7ef92bd` holds the fully green exact-head CI record (shared build, Ubuntu/x86 UT, arm64 SCA, UT Coverage, Coverage, `CI Required`, both multi-CN BVT compose legs, preflight, pr-size-label, coverage eligibility, Iceberg Connector E2E), and the standing review state — CHANGES_REQUESTED from the mo-bot review of the superseded `ddc46c416b`, with the equal-key remediation answered on `a4a7ef92bd` and every affected thread resolved — carries to the new head as CI and review proceed. Approved by: @XuPeng-SH, @iamlinjunhong
cpegeric
pushed a commit
that referenced
this pull request
Oct 30, 2026
…matrixorigin#31739) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#30940 ## What this PR does / why we need it: ### Problem `DECIMAL` column declarations silently dropped the parsed `UNSIGNED` and `ZEROFILL` attributes: - `DECIMAL(10,2) UNSIGNED` accepted and stored negative values under every `sql_mode`, where MySQL rejects them with `ERROR 1264 (22003) Out of range value`. - `DECIMAL(10,2) ZEROFILL` produced no zero-padded output, and `SHOW CREATE TABLE` / `information_schema.columns.COLUMN_TYPE` lost both modifiers. - `CAST(x AS DECIMAL(p,s) UNSIGNED|ZEROFILL)` was accepted, which MySQL rejects outright with `ERROR 1064`. ### Root cause Three coupled defects: 1. The plan-layer DECIMAL conversion (`getTypeFromAstWithoutCharset`) selected decimal64/128/256 by precision and scale only, discarding the parsed attributes, so the attribute never reached the persisted type, assignment admission, or any presentation surface. 2. With no attribute on the type domain, every assignment path (INSERT/UPDATE/LOAD/REPLACE/VALUES) had no unsigned rule to enforce, SHOW CREATE / information_schema / result metadata had nothing to render, and the CAST target grammar accepted spellings MySQL forbids. 3. The bootstrap upgrade framework had no versioned entry able to reconcile persisted `information_schema.COLUMNS` view text on existing clusters, and no admission gate for legacy CDC tasks during that crossing. ### Changes - **Attribute carrier**: `plan.Type.numeric_attributes` (proto field 14) carries UNSIGNED/ZEROFILL from DDL through persistence, catalog cache, table functions, arrowbridge/external readers, checkpoint tooling and sysview. - **Unsigned enforcement**: every assignment admission path enforces the unsigned domain — strict mode rejects negatives with `ERROR 1264 (22003)` atomically (no partial writes), non-strict saturates to the lower bound with a 1264 warning, `IGNORE` accepts; `ZEROFILL` implies `UNSIGNED`. Executor cast saturates to the unsigned domain with scale widening before negation. - **Presentation**: SHOW CREATE and COLUMN_TYPE render the modifiers (`decimal(10,2)`, `decimal(10,2) unsigned`, `decimal(10,2) unsigned zerofill`); zero-padding is applied on all six decimal serialization/export sites (text rows ×2, binary rows ×2 including prepared, CSV and JSONLINE export) plus result-column display metadata. - **CAST grammar**: `CAST(... AS DECIMAL(p,s) UNSIGNED|ZEROFILL)` is rejected with `ERROR 1064 (42000)`, matching MySQL. - **Upgrade crossing**: new version 4.0.18 (offset 1) one-shot `information_schema.COLUMNS` reconciliation entry with legacy-CDC admission gating, retained-target recheck, frozen-offset preservation (`MinUpgradeVersion 4.0.7`, `RequiredProtocolVersion 126`), so upgraded clusters decorate their persisted view text exactly once. ### Validation - Primary regression, assigned base vs fixed: identical 8-section SQL script plus server-side-prepared binary-row probe run against isolated services built from (a) the unaltered base `3cf38889bc` (every defect reproduced: negatives stored, modifiers dropped, no padding, CAST accepted) and (b) this change (strict `ERROR 1264 (22003)` with zero rows stored, non-strict clip to `0.00` + Warning 1264, modifiers retained in SHOW CREATE/COLUMN_TYPE for masks 0/1/3, zero-padded text and binary wire, both CAST spellings `ERROR 1064`, signed/NULL controls unchanged). - Focused BVT `test/distributed/cases/dtype/decimal_unsigned_zerofill.test` (144 statements: strict/non-strict/IGNORE, modifier masks, wide widths, defaults, UPDATE, NULL, CAST rejection, persistence, snapshot compatibility): `TOTAL 144 SUCCESS 144 SUCCESS RATE 100%`; `mo-tester` result regeneration byte-identical. - Upgrade legs: `go test ./pkg/embed/ -run 'TestColumnsUpgrade'` — 7/7 PASS, including an ablation leg proving the 4.0.18 entry is solely responsible for decoration (background COLUMNS maintenance suppressed, undecorated predecessor verified) and a post-replacement-crash leg proving view-content and tenant-progress roll back together with idempotent restart replay; plus `go test ./pkg/bootstrap/...`, `go test ./pkg/hakeeper/`, and the v4_0_18 commit-fence unit subcase, all green. ### Residual risks - The background `information_schema.COLUMNS/TABLES` maintenance walker (kept enabled in production) also converges view text over time; the upgrade entry owns the deterministic crossing and the ablation leg proves its sole responsibility, but real-cluster non-upgrade convergence remains upstream-owned behavior. - Evidence scope: focused BVT and affected-package suites are green; the full distributed dtype suite is left to CI. Signed-DECIMAL controls in the focused file and sweeps show no behavior change for unmodified columns. ### CI fix update (2026-10-29, commit 74a4105) CI run 40845538549 at the previous head failed Matrixone UT Coverage (4 tests) and multi-CN e2e BVT (3 rows); all were caused by this PR and are fixed in `74a4105d94`: - **Bootstrap upgrade chaining** (`pkg/bootstrap/service_upgrade_tenant.go`, `pkg/bootstrap/custom_upgrade.go`): `MaybeUpgradeTenant`/`UpgradeOneTenant` planning stopped at the frozen consolidated v4.0.7 terminal entry, so tenants on older versions never received the forward v4.0.18 upgrade and tenants already at 4.0.7 skipped it. Both paths now re-plan and run the v4.0.7 crossing on demand until no pending v4.0.7 upgrade remains, and the frozen terminal entry is skipped so the forward version still executes. Fixes `TestCollationsMetadataUpgrade`, `TestV407LoginRepairsTenantCreatedAfterUpgradeSnapshot`, `TestCallerOwnedTenantUpgradeRollsBackAndRetries`, `TestCatalogVersionOrderingUsesSemanticVersionAndOffset`. - **Stale test expectations** (`pkg/embed/catalog_view_identity_test.go`, `pkg/embed/catalog_upgrade_paging_test.go`): assert the semantic final version instead of hardcoded `4.0.7`; injected version samples retargeted to 4.1.9/4.1.10/4.1.11 to preserve the semantic-vs-lexicographic ordering check. - **BVT expected results** (`test/distributed/cases/dml/show/show.test`, `zz_accesscontrol/account_restricted.sql`): spliced the unsigned-decimal-decorated `information_schema.COLUMNS` SHOW CREATE DDL (Create View descriptor 18848 chars, +209) into the three expectations; fixes show.test row 295 and account_restricted.sql rows 55/113. Local verification: pkg/bootstrap package suite green; both embed tests pass with `-v`; focused `decimal_unsigned_zerofill` BVT 144/144 pass via mo-tester against a locally built instance; the three spliced SHOW CREATE rows are byte-exact (18848 chars) against the live upgraded instance. ### CI fix update #2 (2026-10-29, commit 0a05d68) CI run 40862553192 at head 74a4105 failed `SCA Test on Linux/arm64` (job 123409348216): `make static-check-selected` reported 9 static-analysis findings, all in files owned by this PR. Fixed in `0a05d68642`: - `pkg/container/arrowbridge/staging_text_test.go`: gofmt(simplify) — collapse `decimal128.Num{}` to `{}` in the composite literal. - `pkg/sql/plan/function/func_cast_unsigned_decimal.go`: ineffassign — drop the dead `outcome` initializer (both classifier branches always assign). - `pkg/sql/plan/function/func_cast_unsigned_decimal_test.go`: two ineffassign findings — discard results reassigned before use, rescope the second JSON admission result. - `pkg/vm/engine/disttae/cache/catalog_column_update_numeric_attributes_test.go`: prealloc — build the 5-column fixture slice in a single literal with full capacity. - `pkg/bootstrap/service_upgrade_crossing_test.go`: unused `inTxn` field and `executionLog` accessor removed. - `pkg/embed/upgrade_columns_4_0_18_test.go`: unused `readColumnsRoute` / `waitColumnsVersionReady` helpers and the orphaned `testify/assert` import removed. No behavior change. Local verification: `golangci-lint run -c .golangci.yml` on the five affected packages reports 0 issues (the exact CI gate); the targeted suites all pass — arrowbridge staging-text suite, `pkg/sql/plan/function` TestUnsignedDecimalAdmission* + TestCastDecimalExtremeExponentRendering, `disttae/cache` TestColumnOnlyUpdateNeverDropsNumericAttributes, and `pkg/bootstrap` TestCrossing*. The same run's `UT Coverage on Ubuntu/x86` failure (job 123409393777) and its downstream `Coverage` merge block are the known `TestCrossTargetUpgradeRecovery` embedded-cluster admission flake tracked in matrixorigin#31044 (comment below); the PR code does not execute in that fixture-acquire failure. ### Base update (2026-10-29, merge commit 983cad4) Main advanced with matrixorigin#31662 (`641c34d259`), which removed the periodic `information_schema.COLUMNS/TABLES` repair walker and made the versioned 4.0.7 entry plus `CREATE ACCOUNT` initialization own convergence. That removal conflicted with this PR's walker-ablation additions (which only existed so upgrade scenario tests could attribute decoration to the v4.0.18 entry). Merge `983cad4dc3` resolves it: the disable option, gate, and struct field are dropped together with the ablation argument at all 13 cluster-wiring call sites; with the walker gone, the scenario tests' attribution premise holds unconditionally. This PR's v4.0.18 one-shot COLUMNS reconciliation entry is unchanged and is exactly the supported convergence path on the new main. Verification on the merged tree: `go vet` green on `pkg/bootstrap/...`, `pkg/embed`, `pkg/frontend`; `golangci-lint` (repo config) reports 0 issues on `./pkg/bootstrap/...` and `./pkg/embed`; `pkg/bootstrap` TestCrossing* and TestV407* pass; `TestColumnsUpgradeAutomaticScenarioCompletion` passes as the merged-premise end-to-end smoke. The residual-risks note above mentioning the background walker "also converges view text over time" is superseded: on current main the walker no longer exists and the versioned entries own convergence. ### CI fix update #3 (2026-10-29, commit a15f2bf) CI run 40880503711 at head 983cad4 (after the matrixorigin#31662 merge) failed `UT Coverage on Ubuntu/x86` (job 123471690727): `TestCreateAccountCatalogInitialization` in `pkg/tests/sqlintegration` failed in 3.35s. That test was introduced by matrixorigin#31662 with a hard-coded `create_version` expectation of `4.0.7`; this PR registers the v4_0_18 upgrade handle, so on the PR head `GetFinalVersion()` is `4.0.18` and `CREATE ACCOUNT` stamps `mo_account.create_version = '4.0.18'` (bound to `baseService.GetFinalVersion()` in `authenticate.go`). The stale literal is updated to `4.0.18` in `a15f2bff2b`; the sibling scenario in `collations_metadata_test.go` already compares against the dynamic `upgrader.GetFinalVersion()` and passed in the same job. No production-code change. ### CI fix update #4 (2026-10-30, commit 66bae00) CI run 40902981503 at head a15f2bf failed `Matrixone Coverage execution / Coverage` (job 123577267924): this PR's own diff coverage measured 536/717 = 74.76%, below the 75% PR-coverage gate. The failure is PR-caused (the gate only counts blocks this PR adds or modifies), so the root cause is fixed with genuine test additions rather than any gate change; nothing outside test files is touched: - `pkg/sql/plan/function/func_cast_unsigned_decimal_test.go`: admission-matrix coverage for the uncovered blocks in `func_cast_unsigned_decimal.go` — signed fixed-width sources rejecting negative rows (1264/22003) and pass-through for non-negative float/int/uint/bool/bit rows; date/datetime/timestamp/enum decodes; select-list row skipping across fixed, JSON, binary and varlena inputs; binary decimal128/256 payload decoding and empty-payload errors; the MySQL-prefix charset fast path; string outcome branches (pass through, clip-to-zero with WARN_DATA_TRUNCATED + 1264 warnings under ignore policy, and the fit-abstain path); varlena NULL rows; and the nil-process out-of-range warning fallback. - `pkg/container/arrowbridge/staging_text_test.go`: staged-text rendering for the remaining Arrow scalar kinds (int8/16/32, uint8/16/32/64, float16/32, decimal256), the rendered upper-bound table for int/float/bool kinds plus its unsupported-source rejection, context cancellation observed in both the whole-batch conversion and the per-column staged loop, and row-budget rejection for unsupported staged sources. - `pkg/common/moerr/error_out_of_range_column_test.go` (new): `NewOutOfRangeValueForColumnNoCtx` keeps the 1264/22003 wire contract naming the column and 1-based row. - `pkg/container/types/attributed_decimal_oid_test.go` (new): `T.IsAttributedDecimalOid` accepts exactly the decimal family. Local verification, reproducing the CI gate exactly: artifact profiles from the failed run (UT + BVT pessimistic + BVT compose) merged by block key with the profiles of these tests (same Go 1.27.1 toolchain), then the CI `parse_coverage.py` rerun over this PR's diff: total 717 modified blocks, covered 602, PR coverage 83.96% → pass (margin +9 points over the gate). All named suites pass locally (arrowbridge staging-text file, `pkg/sql/plan/function` TestUnsignedDecimalAdmission* + TestAppendUnsignedDecimalOutOfRangeWarning*, moerr, types). No production-code change; no CI/workflow change. ### Base update (2026-10-30, merge commit 8cc3ce9) GitHub reported the PR CONFLICTING after main advanced with matrixorigin#31628 (FK rebind to surviving keys, `969998e697`), matrixorigin#31738, matrixorigin#31746, matrixorigin#31766, matrixorigin#31767, matrixorigin#31768, matrixorigin#31777. The only content conflict was `pkg/sql/plan/build_ddl_test.go`: both sides appended independent test functions after `TestSessionDatabaseNullability`. The resolution keeps both — this PR's `TestBuildCTASUnsignedDecimal{Attribute,SetOperation}Provenance` and main's FK-rebind tests — with no changes to either test body. All other shared files auto-merged on disjoint hunks, verified by comparing both sides' diff regions against the merge base `641c34d259`: `pkg/common/moerr/error{,_no_ctx}.go` (this PR's `ErrOutOfRangeValueForColumn` 20211 vs main's `ErrDataBranchConflict` 22501, different code groups), `pkg/sql/plan/build_ddl.go` (this PR's CTAS default/attribute region vs main's FK-rebind region), plus `base_binder.go`, `build_alter_table.go`, `query_builder.go`, and `pkg/vm/engine/disttae/txn_table.go`. Local verification on the merged tree (Go toolchain, repo Makefile CGO flags): - `go build ./pkg/common/moerr/... ./pkg/sql/plan/... ./pkg/vm/engine/disttae/...` — green. - `go test ./pkg/common/moerr/` — pass (covers both error-catalog sides). - `go test ./pkg/vm/engine/disttae/cache/ -run TestColumnOnlyUpdateNeverDropsNumericAttributes` — pass (4 subtests). - `go test ./pkg/sql/plan/ -run '<19-test seam regex>'` — all 19 top-level tests pass: this PR's 9 unsigned-decimal suites, main's 8 FK-rebind suites, `TestSessionDatabaseNullability`, `TestBuildCTASPreservesMySQLSpecialColumnTypes`. No production-code change in the resolution beyond the merge itself; no CI/workflow change. Fresh CI on the new head was not awaited. ### CI fix update #5 (2026-10-30, commit 9d109f5) CI run 40929677611 (attempt 1) at head 8cc3ce9 failed `Matrixone CI execution / UT Test on Ubuntu/x86` (job 123645508612): package `pkg/sql/plan/function` failed with `--- FAIL: TestUnsignedDecimalAdmissionTemporalEnumAndUnsupportedSources` — `panic: type mismatch: casting ENUM vector to []uint16` — and `CI Required` failed as a consequence. The failure is PR-caused: the enum decode case added in update #4 built its ENUM input vector through `testutil.NewVector`, whose `T_enum` branch appends plain `uint16`; `vector.AppendFixed[uint16]` trips the race-build `checkTypeIfRaceDetectorEnabled` in `pkg/container/vector` (an enum-typed vector is not type-compatible with `[]uint16`). UT runs with `-race`, so the panic only fires there; local non-race runs passed, which is how it escaped update #4. Production code is unaffected: the admission path already reads enum vectors through `unsignedDecimalAdmissionFixed[types.Enum]`. Fix, test-only and one spot: - `pkg/sql/plan/function/func_cast_unsigned_decimal_test.go`: construct the enum source with `vector.NewVec(types.T_enum.ToType())` + `vector.AppendFixed(types.Enum(7))`, the enum vector construction already used elsewhere in the tree (e.g. `pkg/sql/compile/fuzzyCheck_test.go`). Local verification with the race detector (Go 1.27.1, repo Makefile CGO flags): - Before the fix: `go test -race -run '^TestUnsignedDecimalAdmissionTemporalEnumAndUnsupportedSources$' ./pkg/sql/plan/function/ -count=1 -v` panics with the identical `type mismatch: casting ENUM vector to []uint16` seen in the CI log. - After the fix: the same command passes, and the full `go test -race ./pkg/sql/plan/function/ -count=1` — the package CI aborted early at the panic — passes end to end. No production-code change; no CI/workflow change. Fresh CI on the new head was not awaited. ### Review fix update #1 (2026-10-30, commit 1a96756) The local review at `9d109f531e` (CHANGES_REQUESTED) reproduced one P2 defect in `pkg/container/arrowbridge/staging_text.go`: `renderedStageTextBound` estimated a staged Arrow decimal row as `precision + 3` bytes, which only covers the fixed-point render form. A declared scale outside the fixed-point domain renders the bounded scientific form (`<coeff>e<-sf>`), whose exponent bytes the estimate omitted, and a forged record can carry more coefficient digits than the declared precision. `MaxOutputRows` then admitted a window of individually valid rows whose rendered staging payload exceeded the configured byte budget — the probe admitted two 10^37 rows at scale 1e9 under a 130-byte budget but materialized 148 bytes (146 at scale -1e9) — leaving the reader's wire-size safeguard to split, copy, and discard the excess rows. Fix, scoped to the shared bound helper: - `pkg/container/arrowbridge/staging_text.go`: `renderedStageTextBound` now charges decimals the larger of the two reachable render forms over the physical coefficient span — Decimal128 at most 39 digits (|2^127|), Decimal256 at most 77 (|2^255|), signed two's-complement storage — independent of the declared precision. Fixed-point needs a sign, the digit run zero-padded to the gate-capped scale (<= 76), and the point; scientific needs a sign, the digits, and `e` plus the at-most-11-character negated int32-scale text. The resulting conservative row bounds are 79 bytes (Decimal128) and 90 bytes (Decimal256). Regression coverage (`pkg/container/arrowbridge/staging_text_test.go`): - `TestMaxOutputRowsAccountsScientificStagedText` (new, replicates the review probe): plain and dictionary-encoded `DECIMAL128(38, +/-1e9)` rows of coefficient 10^37 under a 130-byte budget admit exactly one row, and the converted staging window materializes within the budget; a two-row budget admits both with the encoding-independent 148/146-byte footprints below the estimate. - `TestRenderedStageDecimalBoundCoversWorstRenders` (new): the worst renders the gate can physically emit reach the bound exactly (Decimal256 scientific at scale `math.MaxInt32` = 90 bytes; the shared renderer's fixed-point ceiling = 79 bytes), and a forged 39-digit Decimal128 coefficient stays inside the bound. - `TestRenderedStageTextBoundKinds`: pins the 79/90 decimal bounds, including extreme declared scales; `TestMaxOutputRowsAccountsRenderedStagedText` row arithmetic updated to the new bound. Local verification (Go 1.27.1, repo Makefile CGO flags): the new regression tests fail on the pre-fix bound with the review's exact symptom (budget admits 2 rows, expected 1; `arrow-staging-probe.log` equivalent), and the full `go test ./pkg/container/arrowbridge/ -count=1` passes after the fix. `go test ./pkg/sql/colexec/external/ -count=1` passes except the pre-existing environmental `TestExternalArrowLoadFromLocalMinIOAndRejectsObjectChange`, whose local shared MinIO refuses writes because the host Data volume is at 100% capacity ("minimum free drive threshold"). Production-code change is confined to the row-size estimate rule; no CI/workflow change. Fresh CI on the new head was not awaited. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #
What this PR does / why we need it: