Repository navigation
Optimize packed DATETIME to Decimal128 conversion - #29581
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? |
There was a problem hiding this comment.
Post-main-merge revalidation: current head a962563b5560e0557454f001034db14b37791989 is a pure merge of reviewed commit 50dd48af... with main 6249e488b51f9b6887e8db95ce9bfc92b4eb49e9. Its PR delta is still exactly the same 16 implementation lines and 101 test/benchmark lines. The cast implementation, differential tests and Decimal128/type arithmetic are unchanged by the merge; the incoming main temporal refactor does not replace this conversion owner. Independently verified native input/build provenance and reran the packed differential/rounding tests plus temporal numeric type/NULL boundary tests locally on a962563: PASS. Also reran the packed-value, TIMESTAMP session-timezone and time-numeric arithmetic regressions: PASS. Approval remains valid for this delta. New-head CI run 37107834123 was still running when inspected; the successful CI cited below belongs to the pre-merge head and is not relabeled as new-head CI evidence. No waiting for the new CI is implied.
Deep review of 50dd48a against fcd9686. Decision: APPROVE; no verified blocking finding. No subagents were used.
Design and ownership: this is a bounded equivalence optimization at the existing packed-temporal conversion owner. The 16 production lines reuse Decimal128 arithmetic and Scale rather than adding a second rounding policy, cache or executor. The old parser remains the exact-error fallback. Decimal64 is correctly left unchanged because its intermediate 18-digit rounding is observably different.
Adversarial analysis: checked ZeroDatetime and epoch, fractional half boundaries and calendar-digit carry, precision limits, scale above fractional precision, unsupported internal inputs and overflow. For admitted nonnegative inputs the packed coefficient has at most 21 digits, so Mul128/Add64 cannot overflow; Scale and the strict precision bound match ParseDecimal128. TIMESTAMP session-timezone conversion, NULL/vector append ownership and selection remain in their existing callers. No persistence, data-format, tenant, synchronization or lifecycle contract changes.
Tests and cost: the 31,570 deterministic parser comparisons cover width/scale/value interactions; literal expected-value controls independently pin rounding and the unchanged Decimal64 counterpart. The added benchmark compares the actual helper with the original format/parser path. Implementation +16, tests/benchmark +101, documents +0; the increment buys a concrete hot-path reduction without a framework. Reported 4.50–8.45x helper gains and zero successful-path allocations are not a whole-query speedup claim; full BigData A/B remains unmeasured.
Evidence reused: exact-head CI run 37102603201 is successful (head SHA verified), including native build, UT/race stage, SCA and both multi-CN BVT modes. Downloaded UT checkpoints confirm the resource-heavy race stage terminated with status 0; exact-head coverage also executes the new success/fallback branches. Existing temporal SQL BVT execution is verified in the job report. The attempted local focused run was stopped by the wrapper's native-provenance guard before compilation because the primary checkout has different native inputs; it is not counted as a pass. Author's current-head differential, timezone/NULL and isolated real-SQL evidence is consistent with the traced contract.
Historical comments: no actionable review thread exists; the sole bot comment is an account/subscription notice.
Merge Queue Status
This pull request spent 1 hour 8 minutes 17 seconds in the queue, with no time running CI. ReasonThe pull request #29581 has been manually updated Waiting for any of
All conditions
Requeued — the merge queue status continues in this comment ↓. |
|
CI failure root cause and minimal correction:
Validation: reproduced the undefined symbol before the patch; the prepared authorization allow/revoke/regrant tests, complete frontend package, complete function package, and temporal conversion tests pass after it. The original DATETIME optimization and its parser-equivalence tests are unchanged. While validating, the same one-line fix was independently pushed as The full repository |
Merge Queue Status
This pull request spent 10 minutes 7 seconds in the queue, with no time running CI. ReasonPull request #29581 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29580.
What this PR does / why we need it:
Replace the successful DATETIME/TIMESTAMP-to-DECIMAL128 per-row format-and-parse conversion with exact arithmetic. The existing session time-zone conversion remains unchanged. This is a 16-line production change; no planner, storage format, cache, background task, or shared state changes.
Root cause and semantic boundaries
The reported BigData profile spends most CPU in
packedDatetimeDecimal128: it formatsYYYYMMDDHHMMSS.ffffffand parses the resulting string for every row. The packed coefficient fits Decimal128, so we can construct it exactly and use the existingScalerounding implementation.Overflow and unsupported internal width/scale/value inputs fall back to the original parser, preserving its exact error. Decimal64 is deliberately not changed: its existing 18-significant-digit parse followed by scale conversion can round twice. Replacing that path would change results.
Validation
Based on main
fcd9686e0de5c71b6cd2913f922ad54e7df0a324.pkg/sql/plan/function: pass (15.475s).go vetand incremental golangci-lint: pass.mo-service: pass.Same-mode microbenchmark medians from 3 runs:
Successful conversion allocations decrease from 40 B / 3 allocations to 0 B / 0 allocations. These are helper benchmarks, not a claim that the full 1B-row BigData query improves by the same factor. No full BigData rerun has been performed.
Risk review
The old parser is the differential oracle and remains the fallback; no changes to Decimal64, SQL coercion rules, TIMESTAMP time-zone conversion, NULL handling, or error ownership. This bounded internal equivalence optimization does not introduce concurrency/lifecycle ownership changes.