Repository navigation
fix: correct ROUND/TRUNCATE extreme-digits overflow and make VARIANCE raise out-of-range (#31154, #31355) - #31434
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
95f9ca8 to
e36b8ac
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: e36b8acb7c9d644157a74040f1288d8eea3a5faf
Assessment: request_changes
Reviewed all seven changed files, linked issues and complete discussion. The reported extreme-scale and VARIANCE overflow fixes work, but the new fallback introduces a TRUNCATE result regression and substantial avoidable allocation/CPU costs.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
-
P2
pkg/sql/plan/function/func_binary.go:794: Execute SELECT TRUNCATE(1e24,-24), TRUNCATE(-1e24,-24), or TRUNCATE(TRUNCATE(1.1e24,-24),-24). Column inputs with dynamic precision behave identically.
Impact: These expressions now return zero instead of preserving the decimal multiple. SetFloat64 exposes the binary representation just below exact 10^24, and integer quotient truncation discards the entire value. Correct the boundary treatment while retaining the extreme-scale fixes, and add positive/negative, vector and repeated-truncation regressions.
Evidence: sql-contracts.log reproduces all affected SQL paths. The exact frozen baseline passes the same seven boundary/control scenarios in base-sql-control.log. Candidate receipt 1793110746984830150-5 exits 1; baseline receipt 1793110969190480800-4 exits 0. The new tests' exact-binary interpretation does not establish compatibility with the existing DOUBLE behavior. -
P2
pkg/sql/plan/function/func_binary.go:726: TRUNCATE processes large finite DOUBLE values with ordinary negative precision, such as values around 1e20 with digits=-1.
Impact: The magnitude guard sends every row through allocating big.Rat arithmetic even when the precision cannot change the represented result. A 1,024-row vector takes 385–438 microseconds and about 636 KB/19,456 allocations, versus 5.0–5.3 microseconds and zero allocations in the baseline callback path. Preserve a justified cheap identity path and reserve exact arithmetic for boundaries that require it.
Evidence: vector-cost.log contains three samples per case through production vector wrappers, with candidate/base result equality checked before timing. The median slowdown is approximately 83x; ordinary-negative and large-positive controls remain close. Receipt 1793111017361800885-3 exits 0. This adjacent magnitude range is absent from the PR's normal-scale benchmarks.
Validation:
-
Artifacts are retained under /home/xupeng/.local/state/mo-bot/jobs/84aa7293bd128a95057f22a6/attempt-1; evidence-audit.json binds commands, source identities, receipts and log hashes.
-
Isolation preflight and repository-owned candidate/base native builds passed. Forty-two selected existing/new unit tests passed; the additional reviewer boundary probe failed as expected.
-
Public SQL validation confirmed the reported extreme-scale fixes, recoverable error 1690 for ROUND/VARIANCE/JSON overflow, and finite STDDEV. Four regression subtests failed; all seven corresponding baseline controls passed.
-
Final audit receipt 1793111204712815438-5 passed: source unchanged, native provenance verified, and both discussion entries accounted for in discussion-assessment.json.
Limitations:
-
Frozen CI reports successful build, unit, static-analysis and multi-CN BVT checks; detailed CI logs were not supplied.
-
Performance measurements cover function-entry execution using verbatim baseline callbacks, not whole-query throughput. No full package or race suite was newly executed.
e36b8ac to
5ececb4
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 3e4a56c9099129fd64ae60acdc7bedbba51509c9
Assessment: request_changes
Reviewed the complete seven-file delta and discussion. The earlier specific grid, MaxFloat and allocation examples are fixed, but repeated TRUNCATE still changes already-truncated values at other decimal scales.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
- P2
pkg/sql/plan/function/func_binary.go:836: Execute SELECT TRUNCATE(1.5e26,-25), TRUNCATE(TRUNCATE(1.5e26,-25),-25). Results are 1.4e26 and 1.3e26. Negative inputs and dynamic precision columns reproduce the same loss.
Impact: A second truncation at unchanged precision discards another full 1e25. The snap guard recognizes nfl(10^k), but the exact fallback can emit a different float representation of that decimal multiple. Make grid recognition consistent with the fallback's output and add nested scalar/vector regressions.
Evidence: Production SQL confirms the failure; the exact base math implementation preserves repeated results. For the intermediate 1.4e26, 14fl(1e25) is 1.4000000000000002e26, so the equality guard misses it and exact truncation selects 13. See sql-candidate.log with checks/1793129113053675321-3.json and sql-base-control.log with checks/1793129179563777364-3.json. The author's 1.5e24/-23 examples pass, but do not close this broader idempotence contract.
Validation:
-
Forty maintained numeric test roots passed, including allocation, MaxFloat, variance, NULL/mask and error-path coverage.
-
Current SQL probe: 22 regression/control subtests passed and three idempotence subtests failed. All six selected baseline SQL controls passed.
-
Isolation preflight passed; verified 200 native/module inputs and 46 retained build outputs against repository-owner evidence.
-
Saved discussion-assessment.json covering all six discussion keys and validation-audit.json correlating commands, source fingerprints, exits and logs. Final audit receipt 1793129294704991165-3 passed; source remains unchanged.
Limitations:
-
SQL validation used one CN; baseline controls replaced only func_binary.go with the exact merge-base version.
-
No independent MySQL, full-package/race or multi-CN run was repeated. Current author benchmark and CI raw logs were unavailable.
3e4a56c to
a030185
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: a030185116dffd5d00c749f8bfed4a0be64c4ad5
Assessment: approve
Reviewed the complete seven-file delta, linked issues and discussion. Current source and fresh execution resolve the prior grid-loss, repeated-truncation, false-overflow and allocation findings. Numeric error propagation and cleanup are sound; no actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Isolation preflight passed; verified 200 native inputs and 46 retained build outputs against repository build evidence.
-
44 focused test roots and both full owning packages passed: 2,946 test roots, with eight unrelated ONNX skips.
-
25 production SQL integration cases passed, covering scalar/vector regressions, overflow errors, finite STDDEV and same-connection recovery.
-
A 41,392-case sweep per function found no newly introduced idempotence drift on baseline-stable cases.
-
Three-sample vector comparisons confirmed zero allocations. The affected 1,024-row path measured 7.29 µs versus 4.78 µs baseline; the approximately 2.45 ns/row overhead is accepted.
-
Saved discussion-assessment.json and validation-audit.json under /home/xupeng/.local/state/mo-bot/jobs/a0511f9479f873cd82e0d555/attempt-1. Final audit receipt checks/1793141317316345679-4.json passed: source unchanged, all eight discussion keys reconciled, and commands/source/exits matched retained logs.
Limitations:
-
Local SQL execution used one CN; no independent MySQL, full distributed BVT or race run was repeated. Frozen CI reports successful relevant gates, without detailed case logs.
-
The scale sweep is sampled; 14 TRUNCATE cases drift in both baseline and candidate. Benchmarks measure vector execution, not whole-query throughput.
-
Eight unrelated ONNX tests skipped because their runtime was unavailable.
✅ Merged into
|
| Condition | Required by | |
|---|---|---|
| ✅ | #review-threads-unresolved = 0 |
GitHub branch protection |
| ✅ | github-review-approved |
GitHub branch protection |
The batch, tested in place
| Condition | Required by | |
|---|---|---|
| ✅ | any of: check-success = CI Required, check-neutral = CI Required, check-skipped = CI Required |
GitHub branch protection |
Times in UTC · dashboard · how the merge queue works
…s and JSON conditions (#31492) ## 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 #30931 Related to #30930 Related to #30932 ## What this PR does / why we need it: Consolidated group #30931: ENUM/SET truthiness, BIT value literals, JSON IF/CASE conditions. Each defect traces to a surface consuming display text or a strict cast where the stored payload was required. Root causes - **#30931 (master)** ENUM/SET column references bind as display calls; boolean contexts string-parsed labels: `IF(e,1,0)`/`IF(s,1,0)` returned 0 for every nonzero ordinal/bitmap, `WHERE e`/`s` and `e AND 1` failed with 'a' is not a valid bool expression', grouped/DISTINCT boundaries lost storage identity, and numeric SET IN/NOT IN comparisons re-parsed labels after a review-round condition narrowing. On the persisted path the binder binds raw storage (uint64/T_enum), which base already evaluates correctly - so the r8 round also removed an over-broad feature classification that refused native sessions access to SET generated expressions base serves. - **#30930 (included)** BIT value literals `b'1'`/`b'0'` reached the raw-byte text truth paths instead of their numeric payload in logical operators, NOT/XOR, IF/CASE and prepared execution. BIT columns stay with #30922 by acceptance checklist. - **#30932 (included)** `iffCheck`/`caseCheck` excluded T_json conditions and the table-path CASE evaluator assumed a BOOL condition vector (panic on a JSON vector); the strict `jsonScalarToBool` cast path was also applied inside IF/CASE. Fix (approved design revision 9, committed at docs/design/20261027-implicit-boolean-semantics-enum-set-bit-json.md, content hash dd7f1b0a57e9e4e486ca21e039f3d19fc850c6b78d171b57c286ba38a80984d5) - Stored-payload truth for ENUM ordinals/SET bitmasks across IF, CASE WHEN, predicates and logical operators, via identity-based recovery (direct storage, hidden grouped slot, reversible-label decode) that fails closed with a typed error for ambiguous declarations; every boundary keeps exact grouped identity (D6/D10) and explicit CAST ... AS BOOL consumes storage on every grouping/DISTINCT/derived boundary. - One mode gate (D11): MySQL-mode statements evaluate the corrected contracts; MATRIXONE_NATIVE statements keep byte-identical base behavior on every boolean surface, incl. DML assignment casts and the native joins of logservice/persisted write paths. - BIT value literals use the numeric payload in MySQL-mode boolean contexts; DML assignments keep base's raw-payload rejection in native mode. - JSON scalar conditions evaluate in-domain with MySQL conditional numeric coercion; JSON null selects ELSE and stays distinct from SQL NULL; strict JSON->BOOL cast is preserved outside IF/CASE; prepared/binary execution is covered, and the persisted T_json generated-column round-trip carries the same-version cross-mode consumption gate (tjx): MySQL-mode sessions serve it, native-mode sessions keep base's typed refusal. - Remote/persisted compatibility (design revision 9): under the repository's shutdown-only upgrade contract every in-cluster peer runs the same binary, so the corrected contracts ship with NO per-feature protocol version, no `MORPCLatestVersion` bump and no version gate; the provisional MORPCVersion135 fence and its remote/persisted gate wiring from design revisions 2-8 are removed. The shared `JSONBooleanConditionContracts` walk has exactly one consumer, the same-version cross-mode consumption gate for persisted T_json conditions and ENUM storage-truth expressions (`RequireMySQLConditionalBooleanConsumption`); SET storage conditions are exempt (revision 8 / review finding F8, retained) because their numeric executors are unchanged - native sessions keep base access to SET persisted/generated expressions across authoring, SELECT, INSERT and UPDATE, and no base-supported catalog definition is native-inaccessible. Issue -> test proof (all commands run in the isolated validation environment of the agent run; receipts preserved in the run logs) - **#30931**: `test/distributed/cases/dtype/issue_30931_enum_set_bool_truthiness.test` and `issue_30931_consolidated_boolean_semantics.test` (230 statements incl. the five-row truth table `IF/S+0` values, `WHERE e` -> 1,2,4,5 and `WHERE s` -> 1,2,5, logical operators, CAST zones, grouping/DISTINCT boundaries, tiered zone cells, the native/MySQL DML pairs, the SET numeric-IN restores and the 29-statement SET persisted section). Two-binary receipts: fixed binary 259/259 across the two cases (consolidated 230/230 + enum_set 29/29, zero corruption hits); pristine base binary 153/259 with exactly the pre-fix contract-cell failures and every r8 SET persisted statement green (base-compatible parity). Focused UT: `go test ./pkg/sql/plan -run 'TestIfConditionBindsEnumSetStorage|TestWherePredicateCastsEnumSetStorage|TestLogicalOperatorsAndCaseCastEnumSetStorage|TestNumericSetInListRecoversStorageAcrossBoundaries|TestExplicitBoolCastBindsGroupedStorage|TestCrossBlockExplicitBoolCastFailsClosed|TestBooleanConditionContractDetectionOnBoundExpressions|TestSetStorageConditionsExemptFromBooleanContracts|TestCrossModeConsumptionGateRequiresMySQLMode'` - red on the pre-fix tree, green after (native-mode and zone controls included). - **#30930**: BIT-literal cells inside the consolidated case - `b'1' AND 1`, `b'0' AND 1`, `NOT b'1'`, XOR, `CASE WHEN b'1'`, ordinary and server-prepared execution, and native-mode DML assignment rejections with alive checks - green on the fixed binary and red on base in the same two-binary cycles; Connector/J battery 25/25 PASS lines incl. prepared reexecute/rebind and connection-usability-after-error. - **#30932**: seven-row JSON IF/CASE reference vectors (0,1,1,0,1,0,0 with JSON null distinct from SQL NULL), prepared JSON cells and the `tjx` persisted generated-column round-trip (catalog authoring, INSERT/UPDATE recompute, SELECT reread, native typed refusals with alive checks and no rows written, MySQL retry committing) - green on the fixed binary, red on base in the same cycles. Test commands (validation ladder actually executed) - `go test ./pkg/sql/plan` full package (ok; repeated each revision round), `make build` green each round. - mo-tester pair on the two frozen cases: `bash run.sh -p test/distributed/cases/dtype -m run -t 1 -r 100 -i issue_30931_consolidated_boolean_semantics,issue_30931_enum_set_bool_truthiness` against the fixed binary and against the pristine base binary (same lock files, second frozen result) - fixed 259/259, base 153/259 with every new r8 statement green, failure population identical to the previous round (sorted diff empty). - Connector/J server-prepared battery incl. `enumset_where_e` as ServerPreparedStatement, rebinds, `json_conditions`, `connection_usable_after_error`, `source_rows_unchanged`: 25/25 PASS. - Final self-check pre-commit: gofmt + `go vet` + `golangci-lint --new-from-rev` over all changed packages (this run). Residual risks - Zone-3 fail-closure is deliberate: ambiguous empty-label/duplicate-label declarations reject cross-block boolean/CAST recovery with a typed error instead of guessing (MySQL keeps separate groups; the loud error is the safe choice). - Native mode is intentionally the pre-change surface: it keeps base's text-truth quirks (including the historical BIT-payload byte in the native DML error) so upgrades stay byte-compatible; the corrected semantics are the MySQL-mode default. - Rollout follows the repository's shutdown-only upgrade contract (design revision 9): releases restart every in-cluster peer onto the same binary, so the corrected contracts carry no per-feature protocol version and raise no HAKeeper floor; mixed-version execution inside one cluster is an unsupported deployment mode, not a condition this PR fences. The one retained hazards surface is same-version cross-mode: native-mode sessions refuse persisted ENUM/JSON contract definitions through the consumption gate. - BIT columns remain out of scope (tracked by #30922), and JSON conditional semantics outside IF/CASE keep the strict pre-change cast. Broader CI suites (full distributed BVT, frontend/disttae) remain for CI; the focused batteries and the two frozen cases carry the reproduction-and-repair proof. Rebase receipt (2026-10-28, conflict resolution) - main advanced to f847803 and minted MORPCVersion132-134 in the same const-block tail this PR claims 135 in, so Mergify's auto-update failed to merge and the PR went CONFLICTING. Resolution: rebased onto f847803; pkg/defines/const.go keeps main's ladder verbatim (132 decimal float rounding, 133 typed JSON MIN/MAX, 134 ordered ODKU baseline) and applies only this PR's semantic delta: MORPCVersion135 + MORPCLatestVersion = MORPCVersion135 (net +2/-1 vs main) - historical: superseded by design revision 9 below, which removed the mint so pkg/defines/const.go is byte-equal to main again. The provisional whole-block realignment (and its anticipation comment) was dropped so the file carries no formatting churn; every protocol gate and constant is byte-equal to the reviewed design. All other overlapping files (plan/colexec/compile/pb-plan protocol surfaces) auto-merged and both sides' feature floors (132/133/134 from main + 135 from this PR) coexist and compose. - Post-rebase validation on the merged tree: full-package UT green for pkg/sql/plan (ok 48.089s), pkg/sql/plan/function (ok 15.672s), pkg/pb/plan + pkg/defines, plus targeted green for the PR batteries in pkg/sql/colexec/colexec group, pkg/sql/compile (PR boolean-condition contracts + main's Float/JSONMinMax/ODKU/LASTInsertID protocol neighbors incl. TestProtocol132FloatComposesWithJSON133AndODKU134), pkg/cnservice and pkg/hakeeper view-metadata/floor tests; `make build` green (binary stamped 67d17dd). BVT pair re-run on the rebased binary: genRS regeneration of the consolidated case is byte-identical to the committed frozen .result (SHA256 7280b83da7c7f8f76c5a06336bb8c7bbcbd0990b10a5c221291a3a4f3ef8df65), both frozen cases 259/259 at 100% (230/230 + 29/29, zero corruption hits), and main's merged behavior introduces no drift in any of the 230 expectation cells. Connector/J server-prepared battery: 25/25 PASS incl. rebinds, json conditions, connection_usable_after_error, source_rows_unchanged. Owned validation services for both runs shut down cleanly with all 27xxx listeners released. - The pristine-base red pairing (153/259 with the pre-fix failure population) remains valid from the pre-rebase round: the frozen cases, expected results, and the defect's pre-fix refusal receipts are unchanged by the rebase, and the rebased fixed binary reproduces the identical green population, so the red/green discrimination is carried by the same paired evidence. SCA receipt (2026-10-28, CI run 40629398512 attempt 1, job "Matrixone CI execution / SCA Test on Linux/arm64") - The SCA job failed at the license-header gate before any analyzer ran: license-eye v0.4.0's full check (full mode forced by an infra-side config-pin mismatch; scope-only effect) reported exactly one invalid file in CI's 73758-file tree - `pkg/sql/colexec/evaluate_case_json_bool_test.go`, added by this PR without the Apache-2.0 Matrix Origin header. The other 33 PR-changed .go files were valid, so the gate failure is fully attributable to that file. - Fix (follow-up commit on this branch): prepend the canonical 14-line header, byte-identical to this PR's other new files. Comment-only diff, zero behavior change: gofmt-clean, and the two focused UTs in the file re-run green on the fixed tree. - Exact-mode local replay of the stages that attempt never reached: license-eye header check on the fixed tree now reports 0 invalid files (dep check clean too), and `make static-check-selected` over every PR-owned package reproduces CI's passing SCA baseline: the pinned molint recipe prints the identical pre-existing finding set seen in the green run of merged PR #31434 (run 40610550148) with zero new diagnostics from this PR, and golangci-lint v2.14.0 (the pinned recipe version) reports 0 issues. Rebase receipt 2 (2026-10-28, conflict resolution onto e9dc8c4) - main advanced again (df8bfd6 -> e9dc8c4): #31088 integer add/mul widening, #31476 MATCH-as-condition row flag, #31506 python-sdk validation artifacts removal, and #30316 MySQL approximate-numeric text notation (FLOAT/DOUBLE scalar and JSON number printing, historical catalog DOUBLE->string width-32 repair). GitHub reported this PR CONFLICTING at head c209aee (mergeStateStatus DIRTY). - Resolution: rebased both commits onto e9dc8c4 (new head adc62e8; force-with-lease push, remote prerequisite exactly c209aee). The single textual conflict was pkg/sql/plan/function/function.go, where #30316 added `check = legacyFloatStringCheck(ctx, check, args)` immediately before `switch check.status` - the same spot this PR added the two D11 gates (native-mode IFF/CASE legacy condition admission, ENUM->BOOL cast-pair gate). Semantic resolution keeps both, in main's order: the D11 gates first, then main's legacyFloatStringCheck as the final pre-switch override. In MySQL-contract mode the gates are inert and binding is byte-identical to main; in native mode the gates restore pre-contract admission first and the catalog-repair float-width narrowing (LegacyFloatStringBounds; it only adjusts float64->varchar(34) cast widths under succeedWithCast) then applies exactly as on main. range-diff confirms the replay is otherwise hunk-identical and the PR diff/file set is unchanged versus the previous head. - All other overlapping files (base_binder.go, bind_context.go, func_cast.go, query_builder.go, types.go, utils.go - touched upstream by #30316/#31088) auto-merged; the merged hunks (IFNULL common-value contract refactor, legacy float-string bound propagation in ddlExpressionContext, integer-precision metadata) were audited and have no interaction with the boolean-contract surfaces. pkg/pb/plan/string_literal_form.go is hand-maintained support code (the plan_string_literal_form postprocess only patches plan.pb.go/api.pb.go), so the regenerated pkg/pb/plan/plan.pb.go upstream carries no regeneration drift for this PR. BVT expectation sensitivity: the two frozen issue-30931 cases touch no FLOAT/DOUBLE/DECIMAL surface and their JSON cells print only strings and integers ("0.5", "1e2", {"x": 1}, [1, 2], true, null), so #30316's numeric-notation change cannot shift any of the 230+29 expectation cells; the 259/259 fixed-binary receipts from the merged-tree round remain the contract evidence and CI re-runs the full BVT pair. - Post-rebase validation on the rebased tree (all commands with the repository CGO environment; logs preserved under the loop artifacts for issue-30931/rebase2-evidence/): `make build` green (exit=0, mo-service binary stamped CommitID adc62e8); `go test ./pkg/sql/plan/function` ok 84.022s (full package - upstream's func_cast_test.go plus this PR's func_cast_enum_bool_test/operatorSet_test additions); `go test ./pkg/sql/plan` ok 375.972s (full package - this PR's boolean-contract batteries plus main's float_string_*/integer_precision/numeric_context suites, all green on the merged semantics); targeted batteries green: pkg/sql/colexec TestEvalCaseJsonCondition* ok 3.894s, pkg/sql/colexec/group TestGroupJointGroupingFlagsPreserveStorageTruthOnActiveArms ok 2.204s, pkg/sql/compile TestBooleanConditionContract* ok 3.969s, pkg/cnservice TestCNViewMetadataSameGenerationFutureFloorPoisonsWithoutRevocation ok 2.850s, pkg/hakeeper TestPersistedFloorExpiryReleasesWithoutShutdownEvidence ok 1.325s, and pkg/defines + pkg/pb/plan ok (0.856s/2.592s, run right after the rebase with the equivalent plain environment). All three issue proofs (ENUM/SET IF/WHERE/logic recovery, BIT-literal payloads, JSON IF/CASE in-domain evaluation) are exercised inside those packages on the new base; every step exit=0. CI-alignment receipt (2026-10-29, compose-pessimistic BVT failure in run 40665475705, job 122744108573) - The multi-CN e2e BVT job ran all 662 assigned scripts and failed only dtype/set.sql rows 51/60/69: the three `group by ... count(*)` queries over the `SET('', 'a')` and `SET('z', '', 'a')` fixtures carried pre-contract expectations that merged the zero bitmap with the empty-label member into one display group. Under this PR's D1 composite (display, storage) group key those rows are separate groups that both display `''` exactly like MySQL (recorded MySQL 8.3.0 reference; the analogous fixture documents MySQL duplicate-key 1062 in mysql_compat_enum_set_numeric.result), so the buried rows were stale relative to the reviewed contract. - Fix: commit 0d022fc "test(dtype): align set.sql grouped empty-label SET expectations with D1 contract" - the three grouped count rows in test/distributed/cases/dtype/set.result (merged ('',2) group becomes two ('',1) groups; group output stays the display label) and a rewritten stale comment in test/distributed/cases/dtype/set.sql (GROUP BY keys the stored bitmap; DISTINCT keeps one row per display label; grouped ORDER BY sorts by the canonical bitmap of the surviving display). - Verified locally on the head binary (BuildTime 1793166448, CommitID adc62e8) with CI-identical mo-tester flags (run.sh -n -g -o, dtype case root): pre-change red set.sql 84/87 failing exactly rows 51/60/69 with the same data diff CI reported; post-change green 314/314 statements 100% (set.sql 87/87, issue_28687 17/17, issue_30538 74/74, issue_30931_enum_set_bool_truthiness 29/29, mysql_compat_enum_set_numeric 107/107); wider neighbor battery 934/934 at 100% (binary_string_function_semantics 157, enum_1 88, enum_index_update 107, issue_30931_consolidated_boolean_semantics 230, mysql_compat_type_conversion 25 plus the repeated four enum_set files). Red/green detail and command/status receipts: /private/tmp/issue-30931-run/tests/ci-set-red-run2.log, ci-set-green-run.log, ci-set-final-cycle.log (mo-tester exit 0, SUCCESS RATE 100%). - Note on one nuance: for `GROUP BY x ORDER BY x` over an empty-label declaration the corrected rows cluster the equal-display groups together (the #29177 canonical-display order key is intentionally preserved) rather than interleaving members by raw storage value as MySQL would; the grouped truth contract itself is unaffected and the same-block/oracle batteries pin it. CI re-runs the full BVT population on the new head. - Delivery: pushed to the PR head branch as plain fast-forward adc62e8 -> 0d022fc (this PR is cross-repository with its head branch in the gouhongshen/matrixone fork; an initial push aimed at upstream origin was refused by the repository-wide "not-create-branch" ruleset 19657232, which restricts branch creation there for non-maintainers). Fresh CI ran to completion on the new head (MatrixOne ALL CI run 40799186983, completed 2026-10-29T02:38:13Z, conclusion: success): 13 successful, 16 skipped, 0 failing, 0 pending - green across UT on Ubuntu/x86, UT Coverage, SCA on Linux/arm64, multi-CN e2e BVT (compose pessimistic and proxy modes) and the required `CI Required` gate, confirming the set.sql alignment on the CI population. Design revision 9 receipt (2026-10-30, review-driven fence removal) - The 2026-10-30 mo-bot review (CHANGES_REQUESTED at 0d022fc) found one P2 design-policy blocker: the per-feature MORPCVersion135 mint plus remote and persisted expression version gates conflicts with the repository's shutdown-only upgrade contract (.agents/skills/mo-dev/references/upgrade-compatibility.md:13-40 - peers inside one cluster always run the same binary; do not mint per-feature versions, bump MORPCLatestVersion for a feature, gate on capability checks, or extend existing gates for new features); the review explicitly supported the SET expectation corrections. The finding was verified anchor by anchor and answered at #31492 (comment). - The design was revised BEFORE implementation per feature-design-review.md and independently PASSed with zero findings: revision 9, committed at docs/design/20261027-implicit-boolean-semantics-enum-set-bit-json.md, content hash dd7f1b0a57e9e4e486ca21e039f3d19fc850c6b78d171b57c286ba38a80984d5 - section 7 rewritten to the same-binary remote/persisted contract, section 8 rejects the fence alternative, section 9 removes the fence batteries, and acceptance criterion (7) pins "no version minted, MORPCVersion134 stays MORPCLatestVersion". - Repair commit a811f13 "fix(plan): remove the per-feature MORPC gate for implicit boolean contracts" implements deviation items 6-9: MORPCVersion135 unminted and MORPCLatestVersion = MORPCVersion134 restored (pkg/defines/const.go is byte-equal to main again); the four gate wires removed - the remoterun encode floor raise + below-135 delivery refusal, the remoteExpressionProtocolVersion requirement, the remote-destination version tuple, and the persisted feature->version table row (the parameterized helper is inlined back into RequiredPersistedExpressionProtocolVersion); the walk-side comments reworded to the mode-gate purpose. Every pre-existing gate row for features 104-134 stays untouched, and the share-walk flag JSONBooleanConditionContracts keeps exactly one consumer: the same-version cross-mode consumption gate RequireMySQLConditionalBooleanConsumption with the F8 SET exemption. - Fence-only tests deleted: pkg/sql/compile/boolean_condition_contracts_protocol_test.go (TestBooleanConditionContractPlacementEncodeAndRefusal, TestBooleanConditionContractStreamConfirmationCoversGateVersion, TestBooleanConditionContractPersistedGatesOnBoundExpressions and the compile-side version-floor detection test), pkg/hakeeper/view_metadata_boolean_contracts_test.go (TestPersistedFloorExpiryReleasesWithoutShutdownEvidence) and pkg/cnservice/view_metadata_boolean_contracts_test.go (TestCNViewMetadataSameGenerationFutureFloorPoisonsWithoutRevocation) in full, plus TestRequiredPersistedBooleanConditionContractsFloor, TestPersistedBooleanContractsPassThroughReaderLackingDetector and TestPersistedBooleanContractsGateSimulations in persisted_ip_boolean_contracts_test.go and TestGeneratedColumnAssignmentCastRaisesPersistedFloor in boolean_contracts_cross_mode_test.go. Retained green: TestSetStorageConditionsExemptFromBooleanContracts verbatim, the native-mode/cross-mode/semantic batteries, and the new plan-side TestBooleanConditionContractDetectionOnBoundExpressions pinning the feature walk over real bound ENUM/JSON expressions with RequiredPersistedExpressionProtocolVersion = 0 and numeric negative controls - the executable record that the feature adds no row to the durable feature->version table. - Post-repair focused validation (repository CGo environment; logs preserved in the run artifacts for issue-30931): changed-closure go build green; go vet over pkg/defines, pkg/pb/plan, pkg/hakeeper, pkg/cnservice, pkg/sql/plan and pkg/sql/compile exit 0 (the hakeeper/cnservice test sets still compile after the fence-file deletions); gofmt clean over all changed files; the 22-test plan retention battery green (22 PASS / 0 FAIL: detection + SET exemption + cross-mode consumption gate + native-mode parity + the ENUM/SET/BIT semantic batteries); go test -run Persist ./pkg/sql/plan/ green (86 PASS / 0 FAIL); full pkg/pb/plan package ok; pkg/sql/compile TestViewMetadataSender*|TestJSONStringConsumer* ok - main's pre-existing protocol gates for other features compose unchanged. - Semantics unchanged: the repair deletes gating only, so every recorded expected value of all three members keeps standing and the paired two-binary BVT receipts (fixed 259/259 vs pristine base 153/259 on the two frozen issue_30931 dtype cases) remain valid; CI re-runs the full population at the new head a811f13. --------- Co-authored-by: gouhongshen <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #31154
issue #31355
What this PR does / why we need it:
#31154 — ROUND/TRUNCATE on finite DOUBLE at extreme decimal digits. For negative digits beyond the integer fast path (k ≤ 15), the previous implementation produced wrong magnitudes or instability. This PR implements three-lane semantics:
big.Ratpath, so genuine rounding boundaries keep exact semantics.isExactDecimalGridFloat): values that are already exact decimal-grid points at scale k (including outputs of the exact path, e.g. the float64 nearest1.5e26) are returned bitwise-identically. The design intent here is idempotence by construction: an already-on-grid value takes an identity lane, sof(f(x,k),k) = f(x,k)holds wherever the computed result is on-grid. This property is verified over the tested scope — digits scales −25/−23/−1, both signs, adjacent lattice representatives (1.4e26/1.5e26/1.5e24/1e20@−1), nested application, constants and dynamic-precision columns (fixes the review-5673058412 witnessTRUNCATE(1.5e26,-25)drifting to 1.4e26/1.3e26). This is sampled coverage of that scope, not an exhaustive proof over all (x, k).finishFloat64NegativeDecimalVerified:ROUND/TRUNCATE(MaxFloat,-200)stays finite, while truly unrepresentable results (e.g.ROUND(1.7e308,-308)) raiseER_DATA_OUT_OF_RANGE(1690). Ordinary lane remains zero-allocation.#31355 — VARIANCE family overflow semantics. When the aggregate result overflows to a nonfinite value (unscaled path: +Inf; legacy scaled path: Inf−Inf = NaN on finite same-sign large input),
VAR_POP/VAR_SAMP/VARIANCEnow raiseER_DATA_OUT_OF_RANGE(1690) instead of returning +Inf/NaN downstream (which also breaks JSON consumers, e.g.JSON_OBJECTcannot serialize +Infinity). FiniteSTDDEVcapability is preserved; NULL/singleton groups are unaffected.Evidence
-count=1): 12 deterministic tests — 9 inpkg/sql/plan/function(extreme-scale idempotence ±signs, scale ratios, overflow boundary/1690, vector + dynamic digits, wrapper error-channel reuse, masked/null row skipping) and 3 inpkg/sql/colexec/aggexec(variance out-of-range finalize, group error isolation, legacy Inf−Inf NaN).go vetandmolintscoped to the changed packages; molint reports 2checkunsafefindings (byte_like_wildcard_search.go:17,func_cast_integer_assignment.go:21) that are pre-existing — present verbatim at the merge-base parent and untouched by this patch.test/distributed/cases/function/func_issue31154_31355.test/.result— 38/38 statements pass, including the review-5673058412 lattice-idempotence rows.8e4015e0b88ec3078e2b49befaf6c0ae91430e3f, a Mergify-authored merge of upstream/mainb888c218fb3a4f094bb8417288a45c47402e5635into this branch (parents:a030185116dffd5d00c749f8bfed4a0be64c4ad5andb888c218fb3a4f094bb8417288a45c47402e5635); it carries no code change beyond that main merge. All test, BVT, SQL and benchmark evidence in this body pertains to the feature code of this PR; the actual source/binary identity of each run varies and is stated below — the named tests and static checks ran on thea030185116dffd5d00c749f8bfed4a0be64c4ad5source tree, the BVT run (driver r74) used a binary rebuilt ata030185116, and the isolated SQL runs (driver r67) used a binary built ate4bf900fa2, between which anda030185116only the two BVT data files differ (zero Go-source delta). The feature commit's parent is1fd12d526e64a63f867d4eb6a54e7ed6c437113c, which was upstream/main at delivery time 2026-10-27 and has since advanced. No tests, BVT or benchmarks have been run against the merge commit8e4015e0, and no binary was built at it — the numbers above describe the feature code only, not the merge commit.git format-patchof the feature commit as delivered: sha2569b264f5ad0b2d2561211aa7f145b049eceed6854c31c7ad8a360f5199c0e05b3. Binary identity of the runtime evidence stated exactly: the isolated SQL runs (driver r67) on thee4bf900fa2binary are semantically valid for the feature source but do not carry exact-head binary identity; the BVT runs (driver r74) used the binary rebuilt ata030185116(sha2564f9c2c6b5ec9892607eabff9c6b9a11e5a9c0143eb2df22607b6fd780ab1548e), which carries exact-feature-commit identity.Limitations
checkunsafefindings are pre-existing and left for a separate cleanup.