Skip to content

Commit 159f43a

Browse files
Address review: clarify serializeNestedData SAF exception, fix CHANGELOG code spans
- SerializerUtils: expand the top-level SimpleAggregateFunction case comment and serializeNestedData's Javadoc to note the deliberate exception to the "nested elements only" contract (the SAF wrapper is non-nullable so writeValuePreamble writes no marker, but a Nullable underlying still needs one). - CHANGELOG: reflow the SimpleAggregateFunction entry so no inline-code span wraps across a line break (renders correctly in Markdown), matching the file's other entries. Both changes are documentation-only; no behavior change.
1 parent 9209449 commit 159f43a

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
### Bug Fixes
66

7-
- **[client-v2]** Fixed the `RowBinary` writer throwing `UnsupportedOperationException: Unsupported data type:
8-
SimpleAggregateFunction` when inserting into a `SimpleAggregateFunction(func, T)` column (the reader already
9-
supported these columns). The value is now serialized identically to its underlying type `T`, writing the
10-
`Nullable` null-marker byte when the underlying type is nullable (e.g. `SimpleAggregateFunction(anyLast,
11-
Nullable(String))`), mirroring the read path. (https://github.com/ClickHouse/clickhouse-java/issues/2477)
7+
- **[client-v2]** Fixed the `RowBinary` writer throwing
8+
`UnsupportedOperationException: Unsupported data type: SimpleAggregateFunction` when inserting into a
9+
`SimpleAggregateFunction(func, T)` column (the reader already supported these columns). The value is now
10+
serialized identically to its underlying type `T`, writing the `Nullable` null-marker byte when the
11+
underlying type is nullable (e.g. `SimpleAggregateFunction(anyLast, Nullable(String))`), mirroring the
12+
read path. (https://github.com/ClickHouse/clickhouse-java/issues/2477)
1213

1314
- **[client-v2]** Fixed binary array decoding for nullable element types so `Array(Nullable(Float64))` and similar columns now return boxed arrays such as `Double[]` instead of `Object[]`. This keeps null-supporting arrays aligned with their element type while preserving the existing `Object[]` fallback for Variant/Dynamic/Geometry arrays. (https://github.com/ClickHouse/clickhouse-java/issues/2846)
1415

client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ public static void serializeData(OutputStream stream, Object value, ClickHouseCo
7474
break;
7575
case SimpleAggregateFunction:
7676
// A SimpleAggregateFunction(func, T) value serializes identically to its underlying
77-
// type T; delegate through serializeNestedData so a Nullable underlying still gets
78-
// its RowBinary null-marker byte, mirroring BinaryStreamReader's read path.
77+
// type T. This is a deliberate exception to serializeNestedData's "nested elements
78+
// only" contract: the SAF wrapper is itself non-nullable, so writeValuePreamble emits
79+
// no null-marker for a top-level SAF column, yet a Nullable underlying still needs one.
80+
// serializeNestedData writes that marker iff the underlying is nullable, mirroring
81+
// BinaryStreamReader's read path.
7982
serializeNestedData(stream, value, column.getNestedColumns().get(0));
8083
break;
8184
case AggregateFunction:
@@ -123,7 +126,10 @@ public static void serializeData(OutputStream stream, Object value, ClickHouseCo
123126
* {@code 0x01} when null), as the server expects for {@code Nullable} sub-columns in
124127
* {@code RowBinary}. For a top-level column this marker is instead written by
125128
* {@link com.clickhouse.client.api.data_formats.RowBinaryFormatSerializer#writeValuePreamble},
126-
* so this helper must only be used for nested elements.
129+
* so this helper is normally used only for nested elements. The one deliberate exception is a
130+
* top-level {@code SimpleAggregateFunction} column: its wrapper is itself non-nullable (so
131+
* {@code writeValuePreamble} writes no marker), but its underlying type may be {@code Nullable}
132+
* and still needs the marker, which this helper supplies.
127133
*/
128134
private static void serializeNestedData(OutputStream stream, Object value, ClickHouseColumn column) throws IOException {
129135
if (column.isNullable()) {

0 commit comments

Comments
 (0)