Skip to content

[client-v2] Fix reading Array(Point) and Array(Array(Point)) - #3381

Open
Indian-boult wants to merge 1 commit into
ClickHouse:mainfrom
Indian-boult:fix/read-array-of-point
Open

Indian-boult wants to merge 1 commit into
ClickHouse:mainfrom
Indian-boult:fix/read-array-of-point

Conversation

@Indian-boult

@Indian-boult Indian-boult commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

Reading Array(Point) or Array(Array(Point)) failed with IllegalArgumentException: array element type mismatch in Client#queryAll, the binary readers and jdbc-v2 ResultSet#next(). An Array(Point) inside a Map, Tuple, Variant or Dynamic value failed the same way. A Point is read as double[], and ArrayValue allocated an Object[][] for every array element class. It now allocates an Object[] when the element is an array of a primitive type. The points stay double[], the same as in Array(Nullable(Point)) and an empty Array(Point). Other arrays keep their classes and allocations. The new check runs once per array and only when the element class is an array.

The Native reader does not decode the Native layout of arrays of tuples, which is #3156. For an Array(Point) with more than one point in a block it now returns wrong values, as it does for Array(Tuple(Float64, Float64)), instead of throwing. In jdbc-v2, getArray and getObject of these columns also need #3378.

Tests. DataTypeTests#testReadArrayOfPoints and JdbcDataTypeTests#testReadArrayOfPoints read Array(Point) and Array(Array(Point)) with an Int64 column after the array and check the whole row. All 4 rows fail on main and pass with the fix.

Closes #3380

Checklist


Note

Medium Risk
Changes core array allocation in the binary reader used by client-v2 and jdbc-v2; scope is narrow but any regression in nested array handling could affect many types.

Overview
Fixes Array(Point) and Array(Array(Point)) decoding in client-v2 (and jdbc-v2 via the shared binary reader), which previously threw IllegalArgumentException: array element type mismatch and could drop whole rows in Client#queryAll, binary readers, and ResultSet#next(). Points are materialized as double[], but nested array backing storage always used Object[][], which cannot hold primitive-array elements.

ArrayValue now allocates an Object[] when the declared element type is an array whose component type is primitive (e.g. double[] for Point), while non-primitive array elements still use Object[][]. Each point remains a double[], consistent with empty Array(Point) and Array(Nullable(Point)).

Adds integration coverage in DataTypeTests#testReadArrayOfPoints and JdbcDataTypeTests#testReadArrayOfPoints for flat and nested point arrays, including a trailing column to ensure the full row is read. Documents the fix in history/latest/3380.md; notes related Native-format limitations (#3156).

Reviewed by Cursor Bugbot for commit a885b85. Bugbot is set up for automated code reviews on this repo. Configure here.

A Point is read as a double[]. A non-empty Array(Point) takes the class
of its first element, and the ArrayValue constructor allocated an
Object[][] for every array class. A double[] is not an Object[], so the
read failed with "array element type mismatch" and the row was lost.
The same happened for an Array(Point) inside a Map, Tuple, Variant or
Dynamic value, and in jdbc-v2 ResultSet#next().

ArrayValue now allocates an Object[] when the element class is an array
of a primitive type. Elements that are arrays of objects, such as a
Ring, keep their Object[][]. The points stay double[], the same as in
Array(Nullable(Point)) and in an empty Array(Point).

Closes ClickHouse#3380
@Indian-boult
Indian-boult requested review from a team and mzitnik as code owners November 18, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[client-v2] Reading Array(Point) or Array(Array(Point)) fails with "array element type mismatch"

1 participant