Repository navigation
fix: render Timestamp and TimestampTz up to 9999-12-31 23:59:59.999999 - #107
Merged
Merged
Conversation
The Display impls clamped values to 9999-12-30T22:00:00Z, the upper bound of jiff::Timestamp, so later timestamps were printed as that instant. Build a jiff::civil::DateTime from the epoch micros (plus the offset for TimestampTz) instead; it covers the full year range. Values outside years -9999..=9999 saturate as before, so formatting still never panics. Refs databendlabs/databend#21070
Contributor
Author
|
cc @b41sh I think jiff is enough, no need to replace chrono. |
Contributor
Author
|
will fix in #108 |
b41sh
approved these changes
Nov 12, 2026
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.
Fixes the text rendering part of databendlabs/databend#21070.
Problem
DisplayforTimestampandTimestampTzclamps the value to9999-12-30T22:00:00Zbefore formatting, because that is the upper bound ofjiff::Timestamp(it must stay valid in every offset). Databend's TIMESTAMP range ends at9999-12-31 23:59:59.999999, so every later value inside a VARIANT is printed as9999-12-30 22:00:00.000000. This affects query results,v::STRING, and NDJSON/CSV unloads, and a reload stores the changed value.Changes
TimestampTz) to ajiff::civil::DateTime, which covers years -9999 to 9999, and format that.TimestampTzsets the offset on aBrokenDownTimeso%zstill works.i64::MAXmicros, or a local time past year 9999) saturate toDateTime::MIN/DateTime::MAX, so formatting never panics, as before.Tests
test_to_string:9999-12-31 23:59:59,.999999,9999-12-30 22:00:01,0001-01-01,-1micros,i64::MAX/i64::MIN, andTimestampTzwith+0000,+0800,-0800and local-time overflow.main(9999-12-30 22:00:00.000000) and pass with this change.cargo test,cargo clippy --all-targets -- -D warningsandcargo fmt --checkpass.652b12b49cagainst this branch and ran the reproduction from #21070 in a UTC session. Query results (HTTP and MySQL handlers),v::STRING, and NDJSON and CSV round trips now keep9999-12-31 23:59:59. A Databend regression test with these cases fails 9 of 33 records on the current nightly and passes with this branch.TimestampTzinside a VARIANT now renders the same local time asto_string(ts::TIMESTAMP_TZ)in Asia/Shanghai and America/Los_Angeles sessions.Not addressed here:
Timestamptext has no offset and Databend parses it back in the session time zone, so a text round trip in a non-UTC session shifts the value by the offset (and can now hit the range limit at the max end in negative offsets). That behavior is independent of this change and will be tracked separately in Databend.AI assistance
Prepared with an AI coding assistant. @TCeason has read the full diff and is responsible for answering review questions.