[client-v2] NativeFormatReader fails for non-null values of Nullable(String)

Open
#3,137 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
databases

Research direction

Start at the NativeFormatReader entry point and reproduce the issue with the provided Nullable(String) queries using client-v2 0.10.0 and ClickHouseFormat.Native. Trace the failing non-null read, then verify that non-null Nullable(String) values are read successfully without EOFException while the NULL query continues to work.

Written by the indexing model from the issue text.

Description

bug

I am using client-v2 0.10.0 with ClickHouseFormat.Native.

Given a table:

CREATE TABLE test_table
(
    id String,
    optionalValue Nullable(String)
)
ENGINE = MergeTree
ORDER BY id;

Working query

This works:

SELECT optionalValue
FROM test_table
WHERE optionalValue IS NULL;

Failing query

This fails:

SELECT optionalValue
FROM test_table
WHERE optionalValue IS NOT NULL;

with:

ClientException: Failed to read block
Caused by: EOFException: End of stream reached before reading all data
    at NativeFormatReader.readBlock(...)

Workaround

Casting the column to String works:

SELECT CAST(optionalValue AS String) AS optionalValue
FROM test_table;

Java code

QuerySettings settings =
        new QuerySettings().setFormat(ClickHouseFormat.Native);

try (QueryResponse response =
             client.query(sqlQuery, settings).get()) {

    NativeFormatReader reader =
            (NativeFormatReader) client.newBinaryFormatReader(response);
}

Environment

  • client-v2: 0.10.0
  • ClickHouse server: 25.9.3.48
  • Java: 21
Dominant language
Java
Stars
1.6k
Forks
637
Avg merge
2d 12h
Merged PRs (30d)
28

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ClickHouse/clickhouse-java

All issues in ClickHouse/clickhouse-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.