Repository navigation
fix: preserve instant in transaction timestamp conversion - #27636
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? |
LeftHandCold
left a comment
There was a problem hiding this comment.
Reviewed exact head c13c617. The direct HLC physical-nanosecond conversion correctly preserves the absolute TIMESTAMP instant for both ts_to_time and CAST, ignores the logical component, closes NULL handling, and validates precision before narrowing. Focused exact-head tests passed; CI executed table_func_metadata_scan.sql with 67/67 assertions, including cross-time-zone epoch invariance. No blocking correctness, compatibility, or regression issue found.
…in#27636) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27637 ## What this PR does / why we need it: A transaction TS physical component is Unix nanoseconds for an absolute HLC instant. The previous `ts_to_time` and `CAST(TS AS TIMESTAMP)` paths formatted that instant as a UTC wall-clock string and reparsed it in the session time zone, shifting the underlying instant by the zone offset and allocating/parsing a string for every row. This PR converts the HLC physical component directly for both public conversion paths, ignores the non-SQL logical component, validates the original int64 precision before narrowing, and closes NULL handling. Existing TS-to-NOW coverage is retained. The metadata_scan BVT adds CAST/function equivalence and epoch invariance across +08:00 and -05:00 without new fixtures, data loads, sleeps, or cluster initialization. ## Validation - owning package full UT: `mo-cgo-test ./pkg/sql/plan/function -count=1 -timeout=20m` — PASS, 12.285s - focused UT after rebase to current main — PASS - `go list`, `go build`, and `go vet` for `./pkg/sql/plan/function` — PASS - real candidate service on `10.222.1.55`: metadata_scan executed the added function, CAST, NULL, and cross-time-zone epoch checks without unexpected errors - benchmark: direct conversion 5.44-5.46 ns/op, 0 B/op, 0 allocs/op; legacy string round trip 181.9-185.9 ns/op, 32 B/op, 1 alloc/op Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…in#27636) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27637 ## What this PR does / why we need it: A transaction TS physical component is Unix nanoseconds for an absolute HLC instant. The previous `ts_to_time` and `CAST(TS AS TIMESTAMP)` paths formatted that instant as a UTC wall-clock string and reparsed it in the session time zone, shifting the underlying instant by the zone offset and allocating/parsing a string for every row. This PR converts the HLC physical component directly for both public conversion paths, ignores the non-SQL logical component, validates the original int64 precision before narrowing, and closes NULL handling. Existing TS-to-NOW coverage is retained. The metadata_scan BVT adds CAST/function equivalence and epoch invariance across +08:00 and -05:00 without new fixtures, data loads, sleeps, or cluster initialization. ## Validation - owning package full UT: `mo-cgo-test ./pkg/sql/plan/function -count=1 -timeout=20m` — PASS, 12.285s - focused UT after rebase to current main — PASS - `go list`, `go build`, and `go vet` for `./pkg/sql/plan/function` — PASS - real candidate service on `10.222.1.55`: metadata_scan executed the added function, CAST, NULL, and cross-time-zone epoch checks without unexpected errors - benchmark: direct conversion 5.44-5.46 ns/op, 0 B/op, 0 allocs/op; legacy string round trip 181.9-185.9 ns/op, 32 B/op, 1 alloc/op Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…in#27636) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27637 ## What this PR does / why we need it: A transaction TS physical component is Unix nanoseconds for an absolute HLC instant. The previous `ts_to_time` and `CAST(TS AS TIMESTAMP)` paths formatted that instant as a UTC wall-clock string and reparsed it in the session time zone, shifting the underlying instant by the zone offset and allocating/parsing a string for every row. This PR converts the HLC physical component directly for both public conversion paths, ignores the non-SQL logical component, validates the original int64 precision before narrowing, and closes NULL handling. Existing TS-to-NOW coverage is retained. The metadata_scan BVT adds CAST/function equivalence and epoch invariance across +08:00 and -05:00 without new fixtures, data loads, sleeps, or cluster initialization. ## Validation - owning package full UT: `mo-cgo-test ./pkg/sql/plan/function -count=1 -timeout=20m` — PASS, 12.285s - focused UT after rebase to current main — PASS - `go list`, `go build`, and `go vet` for `./pkg/sql/plan/function` — PASS - real candidate service on `10.222.1.55`: metadata_scan executed the added function, CAST, NULL, and cross-time-zone epoch checks without unexpected errors - benchmark: direct conversion 5.44-5.46 ns/op, 0 B/op, 0 allocs/op; legacy string round trip 181.9-185.9 ns/op, 32 B/op, 1 alloc/op Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27637
What this PR does / why we need it:
A transaction TS physical component is Unix nanoseconds for an absolute HLC instant. The previous
ts_to_timeandCAST(TS AS TIMESTAMP)paths formatted that instant as a UTC wall-clock string and reparsed it in the session time zone, shifting the underlying instant by the zone offset and allocating/parsing a string for every row.This PR converts the HLC physical component directly for both public conversion paths, ignores the non-SQL logical component, validates the original int64 precision before narrowing, and closes NULL handling. Existing TS-to-NOW coverage is retained. The metadata_scan BVT adds CAST/function equivalence and epoch invariance across +08:00 and -05:00 without new fixtures, data loads, sleeps, or cluster initialization.
Validation
mo-cgo-test ./pkg/sql/plan/function -count=1 -timeout=20m— PASS, 12.285sgo list,go build, andgo vetfor./pkg/sql/plan/function— PASS10.222.1.55: metadata_scan executed the added function, CAST, NULL, and cross-time-zone epoch checks without unexpected errors