Repository navigation
GH-55860: [C++][FlightRPC][ODBC] Fix TIME to TIMESTAMP conversion ignoring the time unit (cherry-pick to dremio_27.0_26_20) - #178
Merged
xxlaykxx merged 2 commits intoDec 3, 2026
Conversation
…on ignoring the time unit ### Rationale for this change When a TIME column is fetched as a timestamp through the Flight SQL ODBC driver, the converter in `GetConverter` (`odbc_impl/util.cc`) assumes a fixed unit instead of reading it from the array type: * `time64` is always treated as nanoseconds, so `time64[us]` values come back 1000x too small. For example, `12:34:56.123456` is returned as `00:00:45.296123`. * `time32` is always treated as milliseconds, so `time32[s]` values are also wrong. The result is silently wrong data, with no error. Only `time64[ns]` and `time32[ms]` are converted correctly. ### What changes are included in this PR? * The separate TIME32 and TIME64 to TIMESTAMP branches in `GetConverter` are replaced by one helper, `ConvertTimeToTodayTimestamp`, which reads the unit from the array's `TimeType`. * The helper adds today's date in that unit and casts to `timestamp(unit)`, so the result keeps the precision of the input. * Behaviour for `time64[ns]` and `time32[ms]` is unchanged. ### Are these changes tested? Yes. `util_test.cc` now has one conversion test per unit (`time32[s]`, `time32[ms]`, `time64[us]`, `time64[ns]`), replacing the two previous tests that covered only milliseconds and nanoseconds. Each test also checks that the resulting timestamp has the same unit as the input. ### Are there any user-facing changes? Yes. ODBC clients now get correct values for `time64[us]` and `time32[s]` columns. There are no API changes. **This PR contains a "Critical Fix".** Before this change the driver returned incorrect TIME values for `time64[us]` and `time32[s]` columns without reporting an error. * GitHub Issue: apache#55860 (cherry picked from commit b58954c)
…Second helper Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
lriggs
approved these changes
Dec 3, 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.
Cherry-pick of the fix for apache#55860 onto
dremio_27.0_26_20: the original fix (commit b58954c, already ondremio_27.0_23_19via #176) plus the follow-up review change from apache#55864. Both cherry-picks applied cleanly, with no conflicts.Rationale for this change
When a TIME column is fetched as a timestamp through the Flight SQL ODBC driver, the converter in
GetConverter(odbc_impl/util.cc) assumes a fixed unit instead of reading it from the array type:time64is always treated as nanoseconds, sotime64[us]values come back 1000x too small. For example,12:34:56.123456is returned as00:00:45.296123.time32is always treated as milliseconds, sotime32[s]values are also wrong.The result is silently wrong data, with no error. Only
time64[ns]andtime32[ms]are converted correctly.What changes are included in this PR?
GetConverterare replaced by one helper,ConvertTimeToTodayTimestamp, which reads the unit from the array'sTimeType.timestamp(unit), so the result keeps the precision of the input.arrow::util::GetTimestampConversionrather than a local switch (the upstream review follow-up; not in GH-55860: [C++][FlightRPC][ODBC] Fix TIME to TIMESTAMP conversion ignoring the time unit (cherry-pick to dremio_27.0_23_19) #176).time64[ns]andtime32[ms]is unchanged.Are these changes tested?
Yes.
util_test.ccnow has one conversion test per unit (time32[s],time32[ms],time64[us],time64[ns]), replacing the two previous tests that covered only milliseconds and nanoseconds. Each test also checks that the resulting timestamp has the same unit as the input. The tests were not run locally on this branch.Are there any user-facing changes?
Yes. ODBC clients now get correct values for
time64[us]andtime32[s]columns. There are no API changes.🤖 Generated with Claude Code