fix: handle out of range errors in DATE_BIN instead of panicking#20221
Open
mishop-15 wants to merge 3 commits intoapache:mainfrom
Open
fix: handle out of range errors in DATE_BIN instead of panicking#20221mishop-15 wants to merge 3 commits intoapache:mainfrom
mishop-15 wants to merge 3 commits intoapache:mainfrom
Conversation
neilconway
reviewed
Feb 8, 2026
Contributor
neilconway
left a comment
There was a problem hiding this comment.
Thanks for looking at this! Can we add some test cases?
Contributor
Author
Added test cases for both out-of-range scenarios in the latest commit. |
neilconway
approved these changes
Feb 8, 2026
| stride: i64, | ||
| stride_fn: fn(i64, i64, i64) -> i64, | ||
| ) -> impl Fn(i64) -> i64 { | ||
| stride_fn: fn(i64, i64, i64) -> Result<i64>, |
Contributor
There was a problem hiding this comment.
nit: Use BinFunction here?
Contributor
Author
There was a problem hiding this comment.
Updated to use BinFunction alias. Thanks for the review.
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 #20219
Rationale for this change
The DATE_BIN function was panicking when datetime operations went out of range instead of returning proper errors. The two specific cases were:
DateTime - Monthspanictimestamp_nanos_opt()returning None and then unwrappingWhat changes are included in this PR?
date_bin_months_intervalandto_utc_date_timeto returnResultinstead of panickingorigin_date - Monthsandorigin_date + Monthswithchecked_sub_monthsandchecked_add_months.unwrap()calls with propermatchstatements and error handlingResulttypesAre these changes tested?
Tested manually with the exact queries from the issue that were panicking:
Both queries now return NULL instead of panicking. All existing unit tests pass.
Are there any user-facing changes?
Yes - queries with DATE_BIN that would previously panic now return NULL when datetime operations go out of range.