From f1468c3885b62402cc24820f148834589ccf8a78 Mon Sep 17 00:00:00 2001 From: Polyglot AI <293096396+polyglotAI-bot@users.noreply.github.com> Date: Thu, 10 Sep 2026 08:53:36 +0000 Subject: [PATCH] Fix client-v1 DateTime64 test failing on ClickHouse 26.8 testReadWriteSimpleTypes wrote an unquoted number into the DateTime64(3) column. From 26.8 such a number is a Unix timestamp in seconds instead of the raw scaled value (default of input_format_read_datetime_number_as_raw_value moved from 1 to 0), so the row read back was 1970-01-01 00:00:01 instead of 1970-01-01 00:00:00.001. Write a quoted date-time literal for DateTime64, as the test already does for FixedString and UUID, so the value means the same on every server version. Fixes: https://github.com/ClickHouse/clickhouse-java/issues/3114 --- CHANGELOG.md | 8 ++++++++ .../java/com/clickhouse/client/ClientIntegrationTest.java | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b264b9415..9ad5a57f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -153,6 +153,14 @@ ### Bug Fixes +- **[client-v1]** Fixed the `DateTime64` case of `testReadWriteSimpleTypes` failing against ClickHouse 26.8. From 26.8 + an unquoted number written to a `DateTime64` column in the `Values`/`Quoted` and `JSON` paths is a Unix timestamp in + seconds instead of the raw scaled value - the server setting `input_format_read_datetime_number_as_raw_value` + changed its default from `1` to `0` - so the `insert into ... values(1)` of the test stored `1970-01-01 00:00:01` + instead of the expected `1970-01-01 00:00:00.001`. The test now writes a quoted date-time literal for `DateTime64`, + as it already does for `FixedString` and `UUID`, so the written value means the same on every server version and the + sub-second round-trip stays covered. No client code is affected: both clients quote a date-time value in a text + statement or send it in `RowBinary`. (https://github.com/ClickHouse/clickhouse-java/issues/3114) - **[jdbc-v2, client-v2]** Fixes issue with `FORMAT` in query unable to override format set by client when used with ClickHouse 26.8+. Default format is `RowBinaryWithNamesAndTypes` set at client level. For JDBC, recommend using `format=JSONEachRow` to query JSON. Setting `format=` (empty or `null`) omits the format request header so explicit diff --git a/clickhouse-client/src/test/java/com/clickhouse/client/ClientIntegrationTest.java b/clickhouse-client/src/test/java/com/clickhouse/client/ClientIntegrationTest.java index 95b23f887..fda4fb187 100644 --- a/clickhouse-client/src/test/java/com/clickhouse/client/ClientIntegrationTest.java +++ b/clickhouse-client/src/test/java/com/clickhouse/client/ClientIntegrationTest.java @@ -1206,6 +1206,10 @@ public void testReadWriteSimpleTypes(String dataType, String zero, String negati negativeOneValue = ClickHouseUtils.format("'%s'", ClickHouseIntegerValue.of(-1).asUuid()); zeroValue = ClickHouseUtils.format("'%s'", ClickHouseIntegerValue.of(0).asUuid()); positiveOneValue = ClickHouseUtils.format("'%s'", ClickHouseIntegerValue.of(1).asUuid()); + } else if (dataType.startsWith(ClickHouseDataType.DateTime64.name())) { + negativeOneValue = ClickHouseUtils.format("'%s'", negativeOne); + zeroValue = ClickHouseUtils.format("'%s'", zero); + positiveOneValue = ClickHouseUtils.format("'%s'", positiveOne); } try {