Octonica / ClickHouseClient

ClickHouse .NET Core driver
Apache License 2.0
138 stars 23 forks source link

`DateTime64` values less than 1970-01-01 cannot be read #62

Closed MaceWindu closed 6 months ago

MaceWindu commented 2 years ago

From error it looks like values read as UInt64 instead of Int64

System.OverflowException
  Message=The value 0xFFCD8C88F2850000 is greater than the maximal value of the type "System.DateTime". It is only possible to read this value as "System.UInt64".
  StackTrace:
   at Octonica.ClickHouseClient.Types.DateTime64TableColumn.GetValue(Int32 index)
   at Octonica.ClickHouseClient.Types.ReinterpretedTableColumn`2.GetValue(Int32 index)
   at Octonica.ClickHouseClient.ClickHouseDataReader.GetFieldValue[T](Int32 ordinal)

Originally posted by @MaceWindu in https://github.com/Octonica/ClickHouseClient/issues/60#issuecomment-1172932038

MrDoe commented 6 months ago

I have the same problem. I think this project isn't maintained anymore. I'll try to fix that in my fork.

Edit: I submitted a pull request for this issue. If you still can use it and can't wait for the pull request to be merged, you can use my fork: https://github.com/MrDoe/ClickHouseClient

victor-sushko commented 6 months ago

I changed ranges of supported values to [1900-01-01 00:00:00, 2299-12-31 23:59:59.99999999] for DateTime64 and to [1900-01-01, 2299-12-31] for Date32. Also, the client doesn't return default(DateTime) for 1970-01-01 anymore.

victor-sushko commented 6 months ago

The bug was fixed in the version 3.1.2.