[client-v2] getStringArray() throws "Not an array of strings" on a non-empty Array(Nullable(String))
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 77/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- java
- Bereich
- backend-api-design
Rechercherichtung
Start with MapBackedRecord.getStringArray(), AbstractBinaryFormatReader.getStringArray(), and BinaryStreamReader.readArrayToArrayValue() to trace how declared element types and array component types are handled. Extend DataTypeTests as suggested, covering queryAll() and reader paths with binary string support on and off. Done means nullable string arrays return String[] with null elements while non-string arrays still throw.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
getStringArray() fails on a non-empty Array(Nullable(String)) column with ClientException: Not an array of strings. An empty array of the same column returns String[0]. Thus the same call on the same column works on some rows and fails on other rows.
The failure depends on the column type, not on the data: ['x', 'y'] (no NULL values) fails too. It occurs on all read paths: queryAll() (MapBackedRecord), newBinaryFormatReader() (AbstractBinaryFormatReader), and queryRecords(); name and index overloads; binary_string_support on and off. getObjectArray() and getList() return the correct values for all rows.
This is a regression in 0.11.2 for the default configuration. 0.11.1 returned String[] (with binary_string_support=false):
| Column type, value | 0.9.9 | 0.11.1 | 0.11.2 and main |
|---|---|---|---|
Array(Nullable(String)), ['x', NULL, 'z'] |
exception | [x, null, z] |
exception |
Array(Nullable(String)), ['x', 'y'] |
exception | [x, y] |
exception |
Array(Nullable(String)), [NULL] |
exception | [null] |
exception |
Array(Nullable(String)), [] |
[] |
[] |
[] |
Array(Nullable(FixedString(3))), ['abc', NULL] |
exception | [abc, null] |
exception |
Array(LowCardinality(Nullable(String))), ['l1', NULL] |
exception | [l1, null] |
exception |
Array(Nullable(Enum8('a' = 1, 'b' = 2))), ['a', NULL, 'b'] |
exception | NullPointerException |
exception |
Array(String), Array(LowCardinality(String)), Array(Enum8(...)) |
OK | OK | OK |
"exception" = ClientException: Not an array of strings.
Steps to reproduce
- Run the code example below against any server.
- The first
getStringArray()call (empty array) returns[]. - The second call (non-empty array, same type) throws.
Error Log or Exception StackTrace
empty: []
Exception in thread "main" com.clickhouse.client.api.ClientException: Not an array of strings
at com.clickhouse.client.api.data_formats.internal.MapBackedRecord.getStringArray(MapBackedRecord.java:336)
at Min.main(Min.java:12)
Expected Behaviour
getStringArray() returns a String[] for a 1D array with string elements, with null for NULL elements, as 0.11.1 did. String[] can hold null, so a nullable element type does not prevent the conversion. The javadoc of ClickHouseFormatReader.getStringArray(int) says "Cannot be used for none string element types", and Nullable(String) is a string element type. The server returns these values for the test table:
$ curl ... --data-binary "SELECT toTypeName(ns), ns, ns_nonull, ns_allnull, nfs, lcns, nen, ns_empty FROM strarr FORMAT JSONCompactEachRow"
["Array(Nullable(String))", ["x",null,"z"], ["x","y"], [null], ["abc",null], ["l1",null], ["a",null,"b"], []]
Code Example
try (Client client = new Client.Builder().addEndpoint("http://localhost:8123")
.setUsername("default").setPassword("").build()) {
GenericRecord r = client.queryAll(
"SELECT CAST([] AS Array(Nullable(String))) AS empty, CAST(['a', 'b'] AS Array(Nullable(String))) AS arr").get(0);
System.out.println("empty: " + Arrays.toString(r.getStringArray("empty"))); // []
System.out.println("arr: " + Arrays.toString(r.getStringArray("arr"))); // throws
}
Root cause
BinaryStreamReader.readArrayToArrayValue()makesnew ArrayValue(Object.class, len)for a nullable element column (BinaryStreamReader.java:800-808). This is intentional since #3343 (history/latest/2846.md: "A non-emptyArray(Nullable(T))read from the binary format isObject[]again").- An empty array takes its component type from
getPrimitiveClass(), which isString(BinaryStreamReader.java:784-786). getStringArray()accepts only the component typesString,StringValueandEnumValue, and throws forObject(MapBackedRecord.java:319-339, AbstractBinaryFormatReader.java:888-908).
A review comment on #3343 found this (comment), and the reply was "this is the issue. Will fix". The fix is not on main.
The fix is in the two getStringArray() accessors; BinaryStreamReader keeps Object[].
Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Configuration
Client Configuration
new Client.Builder().addEndpoint("http://localhost:8123").setUsername("default").setPassword("")
// same result with .binaryStringSupport(true)
Environment
- Cloud
- Client version:
mainat 75063012b (0.12.0-rc1-SNAPSHOT), 0.11.2; compared with 0.11.1 and 0.9.9 from Maven Central - Language version: OpenJDK 17.0.21
- OS: Linux (Docker)
ClickHouse Server
- ClickHouse Server version: 26.10.4.207
- ClickHouse Server non-default settings, if any: none
CREATE TABLEstatements for tables involved:CREATE TABLE strarr (id UInt8, ns Array(Nullable(String)), ns_nonull Array(Nullable(String)), ns_allnull Array(Nullable(String)), ns_empty Array(Nullable(String)), nfs Array(Nullable(FixedString(3))), lcns Array(LowCardinality(Nullable(String))), nen Array(Nullable(Enum8('a' = 1, 'b' = 2))), s Array(String), lcs Array(LowCardinality(String)), en Array(Enum8('a' = 1, 'b' = 2)), tail Float64) ENGINE = Memory- Sample data for all these tables:
INSERT INTO strarr VALUES (1, ['x', NULL, 'z'], ['x', 'y'], [NULL], [], ['abc', NULL], ['l1', NULL], ['a', NULL, 'b'], ['p', 'q'], ['m', 'n'], ['b', 'a'], 1.5)
Classification: impact: none · area: Data types & formats (Array(Nullable(String)))
Found by automated analysis (Polyglot AI) while working on #2953. Verified against a live server. Shortened on 2026-11-20: the edit history has the first version.
- Vorherrschende Sprache
- Java
- Sterne
- 1.6k
- Forks
- 657
- Ø Merge
- 2 T. 6 Std.
- Gemergte PRs (30 T.)
- 36
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus ClickHouse/clickhouse-java
-
api-diagnostics bug jdbc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
ClickHouse/clickhouse-java#3464 ·
Maintainer antworten meist innerhalb von 1 Tag
-
tests
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
ClickHouse/clickhouse-java#3452 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug jdbc performance queries sql-parser
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
ClickHouse/clickhouse-java#3451 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug jdbc legacy queries
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
ClickHouse/clickhouse-java#3444 ·
Maintainer antworten meist innerhalb von 1 Tag
-
api-diagnostics bug client jdbc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
ClickHouse/clickhouse-java#3439 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in ClickHouse/clickhouse-java
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 60/100
quelea-projection/Quelea#749 ·
Maintainer antworten meist innerhalb von 1 Tag
-
free_port can hand one port to two callers, so the fixed-port http tests fail in parallel runsOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 92/100
erkamyaman/rust-anything#963 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 76/100
-
Deferred
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Sanne/incus-spawn#2768 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
morluto/rea#15041 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag