Skip to content

[Gandiva] Add timestamp precision support infrastructure and extractYear POC#128

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

[Gandiva] Add timestamp precision support infrastructure and extractYear POC#128
telemenar wants to merge 10000 commits intodremio:dremiofrom
telemenar:gandiva-timestamp-precision-base

Conversation

@telemenar
Copy link

Summary

This PR adds core infrastructure for supporting all four timestamp precisions (SECOND, MILLISECOND, MICROSECOND, NANOSECOND) in Gandiva, along with a proof-of-concept implementation for extractYear.

Changes

Phase 1: Core Infrastructure

  • Add MICROS_*, NANOS_*, SECS_* constants to time_constants.h
  • Create templated EpochTimePointT<Duration> class for precision-aware time operations
  • Add gdv_timestamp_{sec,ms,us,ns} type aliases in types.h
  • Update FunctionSignature::Hash() to include TimeUnit for temporal types
  • Add timestamp_{sec,ms,us,ns}() helpers and TIMESTAMP_PRECISION_TYPES macro

Phase 2: Proof of Concept - extractYear

  • Implement extractYear_timestamp_{sec,ms,us,ns} functions
  • Register precision-specific extractYear in function registry
  • Add unit tests for EpochTimePointT template
  • Add unit tests for precision-specific extractYear
  • Add FunctionSignature hash tests for timestamp precisions
  • Add integration test for extractYear with all precisions

Motivation

Currently, Gandiva internally operates on milliseconds for most timestamp functions, which can lead to precision loss when working with microsecond or nanosecond timestamps. This PR establishes the foundation for native multi-precision support.

Testing

  • Unit tests for EpochTimePointT template with all precisions
  • Unit tests for extractYear with all precisions
  • FunctionSignature hash tests verifying precision differentiation
  • Integration tests with Gandiva Projector

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.