diff --git a/client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java b/client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java index cebd72bb3..c031f4b69 100644 --- a/client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java +++ b/client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java @@ -99,6 +99,10 @@ protected AbstractBinaryFormatReader(InputStream inputStream, QuerySettings quer * @throws IOException */ public boolean readToPOJO(Map deserializers, Object obj ) throws IOException { + if (columns == null || columns.length == 0) { + return false; + } + boolean firstColumn = true; for (ClickHouseColumn column : columns) { @@ -135,6 +139,10 @@ public boolean readToPOJO(Map deserializers, Object obj ) th * @throws IOException */ public boolean readRecord(Map record) throws IOException { + if (columns == null || columns.length == 0) { + return false; + } + boolean firstColumn = true; for (ClickHouseColumn column : columns) { try { @@ -157,6 +165,10 @@ public boolean readRecord(Map record) throws IOException { } protected boolean readRecord(Object[] record) throws IOException { + if (columns == null || columns.length == 0) { + return false; + } + boolean firstColumn = true; for (int i = 0; i < columns.length; i++) { try { diff --git a/client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java b/client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java index bc11e5015..1f18ff66b 100644 --- a/client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java +++ b/client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java @@ -344,6 +344,14 @@ public void testQueryAllTableNames() { Assert.assertTrue(tableNames.containsAll(expectedTableNames)); } + @Test(groups = {"integration"}) + public void testQueryAllInsertSelect() { + client.queryAll("CREATE TABLE IF NOT EXISTS nums (number Int16) ENGINE = MergeTree() ORDER BY number;"); + String sql = "INSERT INTO nums SELECT * FROM system.numbers LIMIT 100"; + List records = client.queryAll(sql); + Assert.assertTrue(records.isEmpty()); + } + @Test(groups = {"integration"}) public void testQueryJSONEachRow() throws ExecutionException, InterruptedException { Map datasetRecord = prepareSimpleDataSet();