clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

Intermittent decoding failure for Array(Map(LowCardinality(String), String)) — works on driver 0.6.3, fails on 0.8.6 / 0.9.4

Open Schum-io opened this issue 1 month ago • 4 comments

On ClickHouse client/driver versions 0.8.6 and 0.9.4, reading a column of type:

Array(Map(LowCardinality(String), String))

fails with:

[HY000] Failed to read value for column traits
array element type mismatch

The same query on the same dataset using driver 0.6.3 always works correctly.

The failure is non-deterministic: the query may succeed once and fail on the next attempt without any data changes. This matches real production behavior where this error “happens every other run”.

This issue appears specifically when the column is located inside a Nested structure in real data, but the failure also reproduces with a plain column in a minimal table.

Environment

  • ClickHouse server: 25.10.1.3832 and 25.6.12.10
  • Client/driver:
  • 0.9.4 — fails intermittently
  • 0.8.6 — fails intermittently
  • 0.4.6 — always works (no failures)
  • 0.6.3 — always works (no failures)

Steps to reproduce

CREATE TABLE reproduce_table
(
    StartedDateTime DateTime,
    traits Array(Map(LowCardinality(String), String))
)
ENGINE = MergeTree
ORDER BY StartedDateTime;
INSERT INTO reproduce_table (StartedDateTime, traits) VALUES
(
    '2025-11-11 00:00:01',
    [
        map(),
        map(
            'RandomKey1','Value1',
            'RandomKey2','Value2',
            'RandomKey3','Value3',
            'RandomKey4','Value4',
            'RandomKey5','Value5',
            'RandomKey6','Value6',
            'RandomKey7','Value7',
            'RandomKey8','Value8'
        ),
        map(), map(), map(), map(), map(), map()
    ]
);
SELECT traits
FROM reproduce_table

Expected Behaviour

[{}, {'RandomKey1': 'Value1', 'RandomKey2': 'Value2', 'RandomKey3': 'Value3', 'RandomKey4': 'Value4', 'RandomKey5': 'Value5', 'RandomKey6': 'Value6', 'RandomKey7': 'Value7', 'RandomKey8': 'Value8'}, {}, {}, {}, {}, {}, {}]

Actual behavior

[HY000] Failed to read value for column traits
array element type mismatch

Additional detail: the issue is triggered only when empty maps (map()) are present

While testing, we discovered that the decoding failure appears only if the Array(Map(...)) contains empty maps — i.e. map() with zero key/value pairs.

If all maps inside the array are non-empty, the error does not reproduce, even across multiple blocks and different LowCardinality dictionaries.

Schum-io avatar Nov 13 '25 05:11 Schum-io

fix this one pls 🙏

p0lorad avatar Nov 13 '25 05:11 p0lorad

@Schum-io Thank you for reporting the issue! We will look into it.

Do you have a stacktrace? Do you use JDBC?

Thanks!

chernser avatar Nov 13 '25 21:11 chernser

  • I don’t have a full stacktrace because I’m executing the query via DataGrip,PyCharm (not a custom Java application).

  • Yes — the driver in question is the clickhouse-java JDBC driver version 0.9.4 (also tested 0.8.6)

Schum-io avatar Nov 14 '25 07:11 Schum-io

Thank you, @Schum-io ! We will look into it.

chernser avatar Nov 14 '25 21:11 chernser