DX-105463: [C++][Gandiva] Add TimestampIR for unit-aware timestamp[us/ns] support#131
Open
dmitry-chirkov-dremio wants to merge 4 commits intodremio_27.0_20from
Open
DX-105463: [C++][Gandiva] Add TimestampIR for unit-aware timestamp[us/ns] support#131dmitry-chirkov-dremio wants to merge 4 commits intodremio_27.0_20from
dmitry-chirkov-dremio wants to merge 4 commits intodremio_27.0_20from
Conversation
…/ns] support Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tor, and test files
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.
Summary
Adds
TimestampIR— an LLVM IR builder class modeled afterDecimalIR— that generates unit-aware wrapper functions at module-load time, enabling Gandiva functions registered fortimestamp[ms]to automatically handletimestamp[us]andtimestamp[ns]inputs without explicit per-unit registry entries.What changes are included in this PR?
timestamp_ir.h/cc(new):TimestampIRclass with wrapper patterns: pure IR arithmetic, calendar split/recombine, extract, trunc, diff, cast, and timezone wrappers. IncludesFloorDiv/FloorDivRemhelpers for correct floor-toward-negative-infinity semantics on pre-epoch timestamps.CMakeLists.txt+engine.cc: WireTimestampIR::AddFunctions()at module load alongsideDecimalIR.function_signature.cc:DataTypeEqualsforTIMESTAMPignoresTimeUnit; only timezone is significant for matching. This allows the existingtimestamp[ms]registry entries to match calls withtimestamp[us]/timestamp[ns]parameters.llvm_generator.cc/h:BuildFunctionCallinspects function descriptor for non-ms timestamp params and remaps to_us/_nssuffixed IR functions. PropagatesStatuserrors from the visitor back to the caller (previously silently dropped).precompiled/time.cc: Floor-division fix inDATE_TRUNC_FIXED_UNITfor pre-epoch (negative) timestamps; fix sub-second millis sign incastVARCHAR_timestamp_int64for negative timestamps.tests/date_time_test.cc: End-to-end C++ tests fortimestamp[us]andtimestamp[ns]through extract, trunc, arithmetic, and cast functions.Are these changes tested?
Yes —
tests/date_time_test.cccovers the new unit-aware paths. Also validated end-to-end througharrow-javaProjectorTestand Dremio integration tests (separate PRs).Are there any user-facing changes?
No API changes. Gandiva functions that previously only accepted
timestamp[ms]now transparently accepttimestamp[us]andtimestamp[ns].Safe degradation: If a caller uses an old native lib (pre-TimestampIR),
DataTypeEqualsfalls back to strict matching, function lookup fails at validation time, and the caller gets a clean error rather than silent wrong results.