Skip to content

Cannot invoke "java.util.TimeZone.toZoneId()" because "tz" is null in client-v2 #1780

Closed
@BeenAxis

Description

@BeenAxis

Describe the bug

Exception when you create a table on server with an undefined timeZone parameter, this exception occurs.
I debugged the client code and fixed it myself via git clone. After the fix this works as required.

Steps to reproduce

  1. create table with DateTime64 (without timezone)
  2. insert some test values, i think no matter what values.
  3. use new client-v2 (0.6.4) query or queryAll or queryRecords

Expected behaviour

No exceptions

Code example

client.queryRecords("select * from test_noerror").await().forEach { record: GenericRecord ->
    println("Record No Error: ${record.getLocalDateTime("issue_field")}")
}
client.queryRecords("select * from test_error").await().forEach { record: GenericRecord ->
    println("Record with Error: ${record.getLocalDateTime("issue_field")}")
}

Error log

11:39:32.663 [main] DEBUG c.c.c.http.ClickHouseHttpConnection - url [http://localhost:8123/?compress=1&extremes=0&wait_end_of_query=true]
11:39:32.673 [main] INFO  c.c.c.http.ApacheHttpConnectionImpl - Connection TTL: 0 ms
11:39:32.673 [main] INFO  c.c.c.http.ApacheHttpConnectionImpl - Connection reuse strategy: LIFO
11:39:32.723 [main] DEBUG c.clickhouse.client.AbstractClient - Connection established: com.clickhouse.client.http.ApacheHttpConnectionImpl@63070bab
11:39:32.723 [main] DEBUG c.c.client.http.ClickHouseHttpClient - Query: select * from test_noerror
11:39:32.727 [main] DEBUG c.c.c.http.ApacheHttpConnectionImpl - HTTP request attempt 0
11:39:32.893 [main] INFO  ShowCase - Record No Error: 2024-08-21T11:06:20
11:39:32.893 [main] DEBUG c.c.client.http.ClickHouseHttpClient - Query: select * from test_error
11:39:32.894 [main] DEBUG c.c.c.http.ApacheHttpConnectionImpl - HTTP request attempt 0
Exception in thread "main" com.clickhouse.client.api.ClientException: Failed to read value for column issue_field
	at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.readValueImpl(BinaryStreamReader.java:181)
	at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.readValue(BinaryStreamReader.java:44)
	at com.clickhouse.client.api.data_formats.internal.AbstractBinaryFormatReader.readRecord(AbstractBinaryFormatReader.java:77)
	at com.clickhouse.client.api.data_formats.internal.AbstractBinaryFormatReader.next(AbstractBinaryFormatReader.java:140)
	at com.clickhouse.client.api.query.Records$1.next(Records.java:48)
	at com.clickhouse.client.api.query.Records$1.next(Records.java:38)
	at ShowcaseKt.main(Showcase.kt:228)
	at ShowcaseKt.main(Showcase.kt)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.TimeZone.toZoneId()" because "tz" is null
	at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.readDateTime64(BinaryStreamReader.java:488)
	at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.readValueImpl(BinaryStreamReader.java:133)
	... 7 more

Configuration

Environment

  • Client version: 0.6.4
  • Language version: Kotlin 2.0.0 & JVM 17
  • OS: Arch Linux

ClickHouse server

  • ClickHouse Server version: 24.3.2.23 (official build)
create table test_error (
    any_field String,
    issue_field DateTime64
)
engine = MergeTree
order by any_field
;

create table test_noerror (
    any_field String,
    issue_field DateTime64(3, 'Europe/Moscow')
)
engine = MergeTree
order by any_field
insert into test_error (any_field, issue_field) VALUES ('Test', now());
insert into test_noerror (any_field, issue_field) VALUES ('Test', now());

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions