Skip to content

[client-v2] Exception when trying to read data from an empty result GenericRecord  #1788

@unlimited-creative14

Description

@unlimited-creative14

Describe your feedback

It should not go inside the for loop because the query return empty dataset. See my example below

Code example

        Client clickhouseV2Client = new Client.Builder()
                .addEndpoint("http://localhost:8123")
                .setDefaultDatabase("default")
                .setUsername("")
                .setPassword("")
                .build();
        CompletableFuture<Records> query = clickhouseV2Client.queryRecords("SELECT 1 LIMIT 0");
        for (GenericRecord record : query.get()) {
            System.out.println("record.c1 = " + record.getInteger(1));
        }

There are stack traces:
java.lang.NullPointerException: Cannot invoke "java.util.Map.get(Object)" because "this.currentRecord" is null
at com.clickhouse.client.api.data_formats.internal.AbstractBinaryFormatReader.readValue(AbstractBinaryFormatReader.java:104) ~[client-v2-0.6.4.jar:client-v2 0.6.4 (revision: fc8d92e)]
at com.clickhouse.client.api.data_formats.internal.AbstractBinaryFormatReader.getString(AbstractBinaryFormatReader.java:169) ~[client-v2-0.6.4.jar:client-v2 0.6.4 (revision: fc8d92e)]
at com.clickhouse.client.api.data_formats.internal.BinaryReaderBackedRecord.getString(BinaryReaderBackedRecord.java:32) ~[client-v2-0.6.4.jar:client-v2 0.6.4 (revision: fc8d92e)]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions