GH-49454: [C++][Gandiva] Fix castVARCHAR_timestamp for pre-epoch timestamps#49455
Open
dmitry-chirkov-dremio wants to merge 1 commit intoapache:mainfrom
Open
Conversation
f19a7ef to
b4b0c4c
Compare
b4b0c4c to
9e9ce58
Compare
xxlaykxx
approved these changes
Mar 6, 2026
lriggs
approved these changes
Mar 6, 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.
Rationale for this change
GH-49454 castVARCHAR_timestamp_int64 produces negative milliseconds for pre-epoch timestamps
What changes are included in this PR?
Fixed
castVARCHAR_timestamp_int64to correctly handle pre-epoch timestamps (before 1970-01-01). The issue was that usingin % MILLIS_IN_SECon negative timestamps produces negative milliseconds, resulting in output like"0107-10-17 12:20:03.-10".Are these changes tested?
Yes, added 4 new test cases covering pre-epoch timestamps with milliseconds
Are there any user-facing changes?
This PR contains a "Critical Fix".
This fixes a bug that caused incorrect data to be produced when casting pre-epoch timestamps to VARCHAR in Gandiva. Previously, timestamps before 1970-01-01 with non-zero milliseconds would produce invalid output with negative millisecond values (e.g.,
"0107-10-17 12:20:03.-10"instead of"0107-10-17 12:20:03.900").