Skip to content

fix date_bin overflows subtracting extreme nanosecond timestamp origin#22251

Open
xiedeyantu wants to merge 1 commit into
apache:mainfrom
xiedeyantu:date_bin
Open

fix date_bin overflows subtracting extreme nanosecond timestamp origin#22251
xiedeyantu wants to merge 1 commit into
apache:mainfrom
xiedeyantu:date_bin

Conversation

@xiedeyantu
Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

date_bin could overflow when subtracting extreme nanosecond timestamps, which could trigger a panic. This fix makes that path return an error instead, so the query safely returns NULL rather than crashing.

What changes are included in this PR?

  • In date_bin.rs, the nanosecond path now uses checked_sub instead of direct subtraction, and returns an ArrowError::InvalidArgumentError on overflow.
  • In date_bin_errors.slt, a regression test was added for an extreme nanosecond timestamp case to verify that overflow returns NULL instead of panicking.

Are these changes tested?

  • Yes. The new sqllogictest covers the regression scenario and verifies that extreme nanosecond timestamp input returns NULL.

Are there any user-facing changes?

  • Yes. date_bin is now more robust for extreme nanosecond timestamp inputs and will return NULL instead of panicking.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: date_bin overflows subtracting extreme nanosecond timestamp origin

2 participants