Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[client-v2] Cannot read values of column type Array(UInt64) #1990

Closed
DKyryk opened this issue Dec 2, 2024 · 1 comment · Fixed by #1995
Closed

[client-v2] Cannot read values of column type Array(UInt64) #1990

DKyryk opened this issue Dec 2, 2024 · 1 comment · Fixed by #1995

Comments

@DKyryk
Copy link

DKyryk commented Dec 2, 2024

Describe the bug

ClickHouseBinaryFormatReader cannot handle values of type Array(UInt64).
Array reader logic creates result array using widerPrimitiveType field of ClickHouseDataType.UInt64 which is long.
At the same time reading a value to set into array uses readBigIntegerLE method which leads to attempt to set BigInteger into long[].

Steps to reproduce

  1. Use click house v2 client and binary reader
  2. Query table with Array(UInt64) column
  3. use reader.next

Expected behaviour

Array(UInt64) column should be correctly read into java list (list of BigInteger I assume but whatever working version)

Code example

try (QueryResponse response = client.query(query, params, new QuerySettings()).get(3, TimeUnit.SECONDS);) {
            ClickHouseBinaryFormatReader reader = client.newBinaryFormatReader(response);
            while (reader.hasNext()) {
                reader.next();
            }
        } catch (Exception e) {
            log.error("Failed to read data", e);
        }

Error log

Caused by: java.lang.IllegalArgumentException: Failed to set value at index: 0 value 2193107007138251553 of class java.math.BigInteger
at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader$ArrayValue.set(BinaryStreamReader.java:585)
at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.readArray(BinaryStreamReader.java:537)
at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.readValue(BinaryStreamReader.java:209)
... 41 common frames omitted
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at java.base/java.lang.reflect.Array.set(Native Method)
at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader$ArrayValue.set(BinaryStreamReader.java:582)
... 43 common frames omitted

Configuration

Environment

  • Client version: 0.7.1-patch1
  • Language version: jvm 21.0.1+12-LTS
@DKyryk DKyryk added the bug label Dec 2, 2024
@chernser
Copy link
Contributor

chernser commented Dec 2, 2024

@DKyryk Thank you for reporting!

@chernser chernser added this to the 0.7.2 milestone Dec 2, 2024
@chernser chernser self-assigned this Dec 3, 2024
@chernser chernser changed the title Client V2 cannot read values of column type Array(UInt64) Client version 0.7.1-patch1 [client-v2] Cannot read values of column type Array(UInt64) Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants