Skip to content

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

Closed
telemenar wants to merge 1 commit intodremio:dremio_27.0_20from
telemenar:gandiva-timestamp-precision-base
Closed

[Gandiva] Add timestamp precision support infrastructure and extractYear POC#128
telemenar wants to merge 1 commit intodremio:dremio_27.0_20from
telemenar:gandiva-timestamp-precision-base

Conversation

@telemenar
Copy link
Copy Markdown

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

…ractYear POC

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
@telemenar telemenar force-pushed the gandiva-timestamp-precision-base branch from 855a4be to 15d9013 Compare April 13, 2026 21:44
@telemenar telemenar changed the base branch from master to dremio_27.0_20 April 13, 2026 21:44
@telemenar telemenar closed this Apr 16, 2026
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.

1 participant