ClickHouse / clickhouse-java

ClickHouse Java Clients & JDBC Driver
https://clickhouse.com
Apache License 2.0
1.45k stars 535 forks source link

[client-v2] failing when serializing nested nullable columns. #1858

Closed javiercj93 closed 3 weeks ago

javiercj93 commented 1 month ago

Describe the bug

Create the following table

Steps to reproduce

  1. Create a table with a nested column which has a nullable field.

    CREATE TABLE test.visits
    (
    CounterID UInt32,
    StartDate Date,
    Sign Int8,
    IsNew UInt8,
    VisitID UInt64,
    UserID UInt64,
    Goals Nested
    (
        ID UInt32,
        Serial UInt32,
        EventTime DateTime,
        Price Nullable(Int32),
        OrderID String,
        CurrencyID UInt32
    )
    ) ENGINE = CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign)
  2. Insert a visit with goals Price containing a null value:

Expected behaviour

Since it is possible to create such nullable fields, the client should be able to handle them and serialize them successfully.

Error log

Caused by: java.lang.IllegalArgumentException: Cannot convert null to Integer
        at com.clickhouse.client.api.internal.SerializerUtils.convertToInteger(SerializerUtils.java:225)

Environment

ClickHouse server

I have created this PR which fixes the issue (apparently)

chernser commented 1 month ago

@javiercj93 Thank you for reporting! We will review the PR.