Repository navigation
Open
Labels
bugdata-typesArea: type names, value encoding and decoding, row mapping, data formatsjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)
Description
Description
Hi ClickHouse team,
I'm encountering an issue when trying to write to a column of type AggregateFunction(groupBitmap, UInt64) via Spark using clickhouse-jdbc and clickhouse-data libraries. This used to work in older versions of the driver, but no longer does.
Details can be found here:
https://clickhousedb.slack.com/archives/CU478UEQZ/p1747041808183739
Details log and code files:
https://gist.github.com/hotstar-xia/e90cd64443ac5deadaf69107978295d4
Steps to reproduce
- Create the target table
- Use Spark JDBC to write a row into this table. The uv column is constructed via serialized bitmap (using Roaring64NavigableMap + ClickHouseBitmap wrapper).
Error Log or Exception StackTrace
Job aborted due to stage failure: Only singleton array is allowed, but we got: [0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0]
Caused by: IllegalArgumentException: Only singleton array is allowed, but we got: [0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0]
at com.clickhouse.data.ClickHouseValue.update(ClickHouseValue.java:782)
at com.clickhouse.jdbc.internal.InputBasedPreparedStatement.setBytes(InputBasedPreparedStatement.java:286)
...
Expected Behaviour
Writing bitmap to the AggregateFunction(groupBitmap, UInt64) column should succeed, as it did in prior driver versions.
Code Example
df.write
.format("jdbc")
.mode("append")
.option("driver", "com.clickhouse.jdbc.ClickHouseDriver")
.option("url", "jdbc:clickhouse://ip-10-10-240-59:8123")
.option("user", "default")
.option("password", "")
.option("dbtable", "label_tmp_table")
.option("batchsize", 10000)
.option("isolationLevel", "NONE")
// .option("createTableOptions", "ENGINE = AggregatingMergeTree ORDER BY (label_table, label_name, value_type, value_op)")
.option("truncate", "true")
.save()Configuration
Client Configuration
- ClickHouse version: 25.4.3.22
Environment
- clickhouse-jdbc: 0.6.0-patch3
- clickhouse-data: 0.8.5
- Spark version: Databricks Runtime 12.2 LTS (Apache Spark 3.3.2, Scala 2.12)
- Cluster type: Single-node
- Target column: AggregateFunction(groupBitmap, UInt64)
ClickHouse Server
-
ClickHouse version: 25.4.3.22
-
CREATE TABLEstatements for tables involved:
CREATE TABLE default.label_tmp_table
(
`label_table` String,
`label_name` String,
`value_type` String,
`value_float64` Float64,
`value_int64` UInt64,
`value_string` String,
`value_datetime` DateTime,
`value_boolean` Bool,
`value_op` String,
`uv` AggregateFunction(groupBitmap, UInt64)
)
ENGINE = AggregatingMergeTree
ORDER BY (label_table, label_name, value_type, value_op)
Metadata
Metadata
Assignees
Labels
bugdata-typesArea: type names, value encoding and decoding, row mapping, data formatsjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)
Activity
mshustov commentedon Sep 27, 2025
depends on #2599
polyglotAI-bot commentedon Nov 28, 2026
Recommendation: Close — already fixed
The issue's driver class
ClickHouseDriverruns jdbc-v2 since 0.8.0, and jdbc-v2 writes thegroupBitmapstate withsetBytessince #2734, first released in v0.9.7. Only the opt-in v1 driver (clickhouse.jdbc.v1=true) still rejects it.main: Fixed on main — with jdbc-v2, the JDBC calls of Spark's writer store the issue's state as[2,4,7].groupBitmapwrite does not need it.setObject(ClickHouseBitmap.wrap(bitmap, ClickHouseDataType.UInt64))stores the value.Analysis: jdbc-v2 writes a
byte[]parameter asunhex('…')(jdbc-v2/src/main/java/com/clickhouse/jdbc/PreparedStatementImpl.java:794-795), which the server reads as the aggregate state; before #2734 it sent the bytes as anArray. The v1 driver passes the bytes toClickHouseValue.update(byte[])(clickhouse-jdbc/src/main/java/com/clickhouse/jdbc/internal/InputBasedPreparedStatement.java:287), which accepts only one byte (clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseValue.java:782), becauseClickHouseBitmapValuedoes not override it.Reproduction: complete program and output
Changed from the issue's steps: the JDBC calls that Spark's writer makes (
setBytes,addBatch,executeBatch) in place of Spark, a table with only a key and theuvcolumn, and the state from the issue's error message.Output on
main(8480ca001), ClickHouse 26.11.4.11:Output of the jdbc-v2 case on the releases v0.9.6 and v0.9.7 (Maven Central), ClickHouse 26.11.4.11, with
?compress=0in the jdbc-v2 URL (with compression, these releases cannot read the responses of this server):Automated triage by Polyglot AI. A maintainer makes the final decision.