Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 21, 2025

Date32, Datetime64, Timestamp64, and Interval64 types use 4/8-byte integers to represent values outside DateTime/TimeSpan ranges. Previously, attempting to read or write such values would throw "Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks" exceptions.

Changes

YdbDataReader

  • GetInt32() now returns raw values for Date32 (signed days from Unix epoch)
  • GetInt64() now returns raw values for Datetime64 (signed seconds), Timestamp64 (signed microseconds), and Interval64 (signed microseconds)

YdbPrimitiveTypeInfo

  • Date32 parameters accept int values directly
  • Datetime64, Timestamp64, Interval64 parameters accept long values directly

Usage

// Read dates outside DateTime range (e.g., year 1696)
int rawDays = reader.GetInt32(ordinal);  // Date32
long rawSeconds = reader.GetInt64(ordinal);  // Datetime64
long rawMicroseconds = reader.GetInt64(ordinal);  // Timestamp64/Interval64

// Write raw values as parameters
new YdbParameter("@Date32", YdbDbType.Date32, -100000)
new YdbParameter("@Datetime64", YdbDbType.Datetime64, -10000000000L)

DateTime/TimeSpan conversion still works for values within their supported ranges.

Original prompt

This section details on the original issue you should resolve

<issue_title>feature: Allow work with Date32, Datetime64, Timespan64 and Interval64 raw values</issue_title>
<issue_description># Feature Request

Date32, Datetime64 and Timespan64 types represented by 4/8 byte unix timestamp with range outside of DateTime supported range and currently it is not possible to read such values and write cannot be done using parameters.
Same for Interval64 - it uses 8 byte value representing number of microseconds

Describe Preferred Solution

It would be nice to:

  • be able to read raw data from data reader using GetInt32 (for Date32) and GetInt64 methods to allow full type range read
  • allow parameter to accept int/long values for corresponding types

Describe Alternatives

Introduce custom types, but it doesn't make much sense as proper implementation is not trivial, e.g. see how NodaTime decided to ditch big ranges in v 2: https://nodatime.org/2.0.x/userguide/range

</issue_description>

Comments on the Issue (you are @copilot in this section)

@KirillKurdyukov ``` Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. (Parameter 'ticks') ``` @KirillKurdyukov [min / max bounds on server YDB](https://github.com/ydb-platform/ydb/blob/799414a6ba1f52b7a012ddaf326d8733352cece2/ydb/library/yql/public/udf/udf_data_type.h#L160)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Nov 21, 2025
Copilot AI and others added 3 commits November 21, 2025 10:03
…al64 types

Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
… range types

Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for Date32, Datetime64, Timespan64, and Interval64 types Add raw integer value support for extended-range date/time types Nov 21, 2025
Copilot AI requested a review from asmyasnikov November 21, 2025 10:16
@KirillKurdyukov KirillKurdyukov marked this pull request as ready for review November 23, 2025 20:26
@KirillKurdyukov KirillKurdyukov requested review from KirillKurdyukov and removed request for asmyasnikov November 23, 2025 20:26
@KirillKurdyukov KirillKurdyukov merged commit 3e8244f into main Nov 23, 2025
21 of 25 checks passed
@KirillKurdyukov KirillKurdyukov deleted the copilot/add-date32-datetime64-support branch November 23, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Allow work with Date32, Datetime64, Timespan64 and Interval64 raw values

3 participants