-
Notifications
You must be signed in to change notification settings - Fork 608
Description
Is there have right demo to use clickhouse-jdbc save bitmap to ck server . I faced this problem maybe isn't a bug . Is there anybody can help me to solve this problems.
My Env
<dependency> <!-- will stop using ru.yandex.clickhouse starting from 0.4.0 --> <groupId>com.clickhouse</groupId> <artifactId>clickhouse-jdbc</artifactId> <version>0.3.2-patch6</version> <!-- below is only needed when all you want is a shaded jar --> </dependency>
CK server version is 21.6.5.37
Create table SQL
CREATE TABLE abTest.xabtest_dispatch_bitmap_v2 (
xabtest_idString,
dtString,
create_atString,
bitmap AggregateFunction(groupBitmap, UInt64) ) ENGINE = MergeTree PARTITION BY dt ORDER BY xabtest_id SETTINGS index_granularity = 64
Java Code
@test
public void test12() throws SQLException {
String url = "jdbc:ch://ip:port/abTest";
Properties properties = new Properties();
properties.setProperty("user", "username");
properties.setProperty("password","password");
ClickHouseDataSource dataSource = new ClickHouseDataSource(url, properties);
Roaring64NavigableMap bitmap = Roaring64NavigableMap.bitmapOf(1L);
Connection conn = dataSource.getConnection();
PreparedStatement statement = conn
.prepareStatement("insert into abTest.xabtest_dispatch_bitmap_v2 values (?,?,now(),?)");
statement.setString(1,"a");
statement.setString(2,"2022-01-01");
statement.setObject(3, ClickHouseBitmap.wrap(bitmap,ClickHouseDataType.UInt64));
System.out.println(statement.execute());
}
RUN the java code . The server repsonse the error message as below.
java.sql.BatchUpdateException: Code: 62, e.displayText() = DB::Exception: Cannot parse expression of type AggregateFunction(groupBitmap, UInt64) here: ru.yandex.clickhouse.util.ClickHouseBitmap$ClickHouseRoaring64NavigableMap@b00da3fb) (version 21.6.5.37 (official build))
, server ClickHouseNode(addr=http:sh-nh-b24-302-n15-clickhouse-89-249:8123, db=abTest)@-881958936
at com.clickhouse.jdbc.SqlExceptionUtils.batchUpdateError(SqlExceptionUtils.java:90)