Octonica / ClickHouseClient

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

use datetime in bulk load under dotnet 6.0 #44

Open UncleJosef opened 2 years ago

UncleJosef commented 2 years ago

When working under dotnet 6.0 with date fields, a timezone error appears. When the same code is running under dotnet 5.0, such an error does not occur.

funcmike commented 2 years ago

I'm using bulk loader under dotnet 6.0 it works ok with DateTime[] startAt = new DateTime [batchSize]; // Clickhouse schema DateTime('UTC')

victor-sushko commented 2 years ago

Versions of ClickHouseClient for .Net 6 and .Net 5 have different approaches for handling time zones. The version for .Net 6 uses new time zone conversion API. The version for .Net 5 relies on TimeZoneConverter.

There may be two possible reasons for a time zone error in the .Net 6 version of ClickHouseClient.

  1. An application is running in the invariant globalization mode. In this case very limited set of time zones is supported by the runtime both on Windows and on Linux.
  2. An application is running on Windows and is not in the invariant globalization mode. In this case there are several time zones which are supported by ClickHouse but are unknown to the runtime.

Here is the query for a list of time zones supported by ClickHouse:

SELECT * FROM system.time_zones

I checked time zones from this list on different version of ClickHouseClient running on Windows.

Here are time zones which are not supported in the ClickHouseClient version for .Net 5 (Windows):

America/Fort_Wayne
Antarctica/Troll
Factory
Pacific/Kanton

And here are time zones which are not supported in the ClickHouseClient version for .Net 6 (Windows):

Antarctica/Troll
Asia/Kashgar
Asia/Urumqi
CET
EET
Factory
MET
Pacific/Kanton
WET