Strange behavior with dateTime
まだ誰も着手していません。
評価
調査の方向性
Issue の DateTime64Example コードから始め、Asia/Tokyo のサーバーと Europe/Paris および Europe/Moscow のクライアントで inserts を再現します。text/TSV inserts と Client.Insert() を比較し、その後、それらの DateTime64 のタイムゾーン処理を追跡します。挿入経路のタイムゾーン動作が文書化され一貫しており、要求されたクライアントローカルオプションに対応できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I modified example
inline void DateTime64Example(Client& client) {
Block b;
/// Create a table.
client.Execute("CREATE TABLE IF NOT EXISTS test_datetime64 (dt64 DateTime64(6) primary key)");
std::cerr << std::endl;
{
Query query("insert into test_datetime64 values('2024-10-10 11:00:00')");
client.Execute(query);
}
{
Query query("insert into test_datetime64 FORMAT TSV \n2024-10-10 11:01:00");
client.Execute(query);
}
auto d = std::make_shared<ColumnDateTime64>(6);
std::time_t tt = std::time(nullptr);
std::cerr << "inserted local time: " << std::asctime(std::localtime(&tt));
std::cerr << "inserted utc: " << std::asctime(std::gmtime(&tt));
d->Append(tt * (int64_t)1000000 + 123456);
b.AppendColumn("dt64", d);
client.Insert("test_datetime64", b);
client.Select("SELECT dt64 FROM test_datetime64 format tsv", [](const Block& block)
{
for (size_t c = 0; c < block.GetRowCount(); ++c) {
auto col = block[0]->As<ColumnDateTime64>();
uint64_t t = col->As<ColumnDateTime64>()->At(c);
std::time_t ct = t / 1000000;
uint64_t us = t % 1000000;
std::cerr << "selected local time: " << std::asctime(std::localtime(&ct));
std::cerr << "selected utc time: " << std::asctime(std::gmtime(&ct));
std::cerr << "us: " << us << std::endl;
}
}
);
/// Delete table.
// client.Execute("DROP TEMPORARY TABLE test_datetime64");
}
The server was run with time zone Asia/Tokyo.
The test program I run twice in two different time zones Europe/Paris Europe/Moscow and has the results of insert:
selected local time: Thu Oct 10 05:00:00 2024
selected utc time: Thu Oct 10 02:00:00 2024
us: 0
selected local time: Thu Oct 10 05:00:00 2024
selected utc time: Thu Oct 10 02:00:00 2024
us: 0
selected local time: Thu Oct 10 05:01:00 2024
selected utc time: Thu Oct 10 02:01:00 2024
us: 0
selected local time: Thu Oct 10 05:01:00 2024
selected utc time: Thu Oct 10 02:01:00 2024
us: 0
selected local time: Thu Oct 10 11:32:57 2024
selected utc time: Thu Oct 10 08:32:57 2024
us: 123456
selected local time: Thu Oct 10 11:33:09 2024
selected utc time: Thu Oct 10 08:33:09 2024
us: 123456
I see that text query (value or TSV format) inserted data in server time zone.
Data that inserted via Client.Insert() has utc time zone. Time zone of text insert and time zone of binary insert is different!
I need unification of time working.
Also will be very good if I can insert data in client local time zone. I did not found way to insert time in client time zone in text formats.
There is output of the client:
SELECT *
FROM test_datetime64
Query id: 560fd02a-cb6c-4303-8947-2c9727cd1793
┌───────────────────────dt64─┐
- │ 2024-10-10 17:33:09.123456 │
└────────────────────────────┘
┌───────────────────────dt64─┐ - │ 2024-10-10 11:00:00.000000 │
- │ 2024-10-10 11:00:00.000000 │
- │ 2024-10-10 11:01:00.000000 │
- │ 2024-10-10 11:01:00.000000 │
- │ 2024-10-10 17:32:57.123456 │
└────────────────────────────┘
- 主要言語
- C
- スター
- 382
- フォーク
- 208
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 14
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ClickHouse/clickhouse-cpp のほかの issue
-
enhancement pg_clickhouse
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
ClickHouse/clickhouse-cpp#478 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 62/100
ClickHouse/clickhouse-cpp#565 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
ClickHouse/clickhouse-cpp#560 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
ClickHouse/clickhouse-cpp#556 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
ClickHouse/clickhouse-cpp#549 ·
ClickHouse/clickhouse-cpp の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
libsdl-org/SDL#16372 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
corazawaf/coraza-nginx#140 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BasedHardware/omi#15662 · コメント 1 件 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
jamesstringer90/appsandbox#160 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100