You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
client-v2: reading a SimpleAggregateFunction held in a Dynamic column fails and can desynchronize the RowBinary stream #3005
client-v2 cannot read a SimpleAggregateFunction(func, T) value stored in a Dynamic column. The server keeps SimpleAggregateFunction as a concrete Dynamic subtype (dynamicType() returns e.g. SimpleAggregateFunction(sum, UInt64)), and encodes it in the binary type encoding as
BinaryStreamReader.readDynamicData() has no case SimpleAggregateFunction: branch, so it falls through to default: and consumes none of that encoding (only the 0x2E tag byte). Two things then go wrong:
readValue's case SimpleAggregateFunction: reads column.getNestedColumns().get(0) from column (the Dynamic column, whose nested list is empty) instead of the resolved actualColumn, so the read fails with IndexOutOfBoundsException: Index: 0.
Even without (1), the unconsumed function name / parameter count / argument type encodings would be interpreted as row data, desynchronizing the rest of the RowBinary stream (every following column reads shifted bytes).
Steps to reproduce
client.queryAll("SELECT CAST(CAST(42, 'SimpleAggregateFunction(sum, UInt64)') AS Dynamic) AS d, 42 AS tail "
+ "SETTINGS allow_experimental_dynamic_type = 1");
Expected behaviour
d reads as the value of the underlying type (BigInteger.valueOf(42) for UInt64), and the following column (tail) reads correctly.
Actual behaviour
com.clickhouse.client.api.ClientException: Failed to read value for column d
at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.readValue(BinaryStreamReader.java:283)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0
at java.base/java.util.Collections$EmptyList.get(Collections.java:4587)
at com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.readValue(BinaryStreamReader.java:266)
Reproduced against ClickHouse server 26.5.1.882 on main (1a11756). It affects every argument type (UInt64, Int32, String, LowCardinality(String), DateTime, Array(String), Map(String, UInt8), Tuple(...)), and the same readDynamicData() path is used for Variant and JSON columns.
Activity
Fix client-v2: read SimpleAggregateFunction from a Dynamic column