Strange behavior with dateTime
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #472 by @ansh0014 — closed without merging
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with the DateTime64Example code in the issue and reproduce the inserts with the server in Asia/Tokyo and clients in Europe/Paris and Europe/Moscow. Compare text/TSV inserts with Client.Insert(), then trace their DateTime64 timezone handling. Done means the insertion paths have documented, consistent timezone behavior and the requested client-local option is addressed.
Written by the indexing model from the issue text.
Description
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 │
└────────────────────────────┘
- Dominant language
- C
- Stars
- 388
- Forks
- 220
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 16
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/clickhouse-cpp
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainers usually reply within 1 day
-
bug queries
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
ClickHouse/clickhouse-cpp#644 ·
Maintainers usually reply within 1 day
-
bug data-types native-format
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ClickHouse/clickhouse-cpp#643 ·
Maintainers usually reply within 1 day
-
bug connectivity native-protocol
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-cpp#638 ·
Maintainers usually reply within 1 day
-
Core SQL test harness: ParseSetAssignments does not skip comments inside SETPossibly taken @puretechteam claimed this 12 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ClickHouse/clickhouse-cpp#626 · 1 comment ·
Maintainers usually reply within 1 day
All issues in ClickHouse/clickhouse-cpp
Similar issues
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
389ds/389-ds-base#8251 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100