Skip to content

[Gandiva] Complete timestamp precision support for all datetime functions#129

Draft
telemenar wants to merge 10000 commits intodremio:dremiofrom
telemenar:gandiva-timestamp-precision-details
Draft

[Gandiva] Complete timestamp precision support for all datetime functions#129
telemenar wants to merge 10000 commits intodremio:dremiofrom
telemenar:gandiva-timestamp-precision-details

Conversation

@telemenar
Copy link

Summary

This PR completes the implementation of timestamp precision support for all Gandiva datetime functions, building on the infrastructure established in #128.

Changes

Phase 4: Extract Functions

  • Implement extractMonth, extractDay, extractHour, extractMinute, extractSecond for all precisions
  • Implement extractDoy, extractDow, extractQuarter, extractWeek for all precisions
  • Implement extractEpoch, extractMillennium, extractCentury, extractDecade for all precisions

Phase 5: Date Truncation Functions

  • Implement date_trunc_Second/Minute/Hour/Day/Week/Month/Quarter/Year for all precisions
  • Implement date_trunc_Decade/Century/Millennium for all precisions
  • Add new date_trunc_Millisecond (for us/ns) and date_trunc_Microsecond (for ns)

Phase 6: Timestamp Arithmetic Functions

  • Implement timestampaddSecond/Minute/Hour/Day/Week for all precisions
  • Implement timestampaddMonth/Quarter/Year for all precisions
  • Support both argument orders: (int, timestamp) and (timestamp, int)

Phase 7: Cast and Conversion Functions

  • Implement timestamp-to-timestamp precision casts (all 12 combinations)
  • Implement castDATE for all timestamp precisions
  • Implement castTIME for all timestamp precisions
  • Implement datediff for all timestamp precisions

Phase 8: Remaining Functions

  • Implement months_between for all timestamp precisions
  • Implement last_day for all timestamp precisions

Functions Implemented

Category Functions Precisions
Extract 14 functions sec, ms, us, ns
Truncate 11+ functions sec, ms, us, ns
Arithmetic 8 functions sec, ms, us, ns
Cast castTIMESTAMP, castDATE, castTIME sec, ms, us, ns
Other datediff, months_between, last_day sec, ms, us, ns

Testing

  • Comprehensive unit tests for all functions with all precisions
  • Tests for edge cases (year boundaries, negative timestamps, precision conversion)

Dependencies


Co-authored by Augment Code


Pull Request opened by Augment Code with guidance from the PR author

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.