Repository navigation
fix: bin date_bin month strides outside chrono's range - #26153
Open
ThilakShekharShriyan wants to merge 1 commit into
Open
ThilakShekharShriyan wants to merge 1 commit into
ThilakShekharShriyan wants to merge 1 commit into
Conversation
Month strides went through DateTime<Utc>, so a timestamp past chrono's range returned NULL even when the month start still fit the output type.
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.
Which issue does this PR close?
Closes #25855.
Rationale for this change
date_binwith a month stride returnedNULLfor timestamps that sit outsideDateTime<Utc>, even when the month start still fits in the output type. Second, millisecond, and microsecond timestamps can be wider than chrono's range. A month bin should beNULLonly when that bin itself does not fit.What changes are included in this PR?
The narrow month path is unchanged and still uses chrono for timestamps that fit in
i64nanoseconds.The wide path, used when the nanosecond conversion overflows, now bins on the civil calendar with the same day-count conversion
date_truncalready uses. It keeps the existing stride rule, including negative strides, and clamps a missing day to the end of the month the waychecked_add_monthsdoes. When the candidate is after the source, it steps back one stride from the origin rather than from the already-clamped date.A result that does not fit the output unit is still
NULL. That coversTimestamp(Second)::MINand a nanosecond source with a stride too large fori64nanoseconds.What is the testing strategy for this PR?
date_bin_errors.sltcovers the issue:10_000_000_000_000seconds bins to month start9999998294400, and the negative input bins to-10000001059200.-4306016287785600000) and used to beNULLonly because chrono overflowed. The nanosecond form of that stride still expectsNULL.Are there any user-facing changes?
Yes. Month-stride
date_binnow returns the month start for timestamps outside chrono's range when that instant fits the output type. Values that already fit ini64nanoseconds are unchanged. No public API change.Made with Cursor