question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use clickhouse-jdbc save bitmap to CK error .

See original GitHub issue

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)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
standup-jbcommented, Mar 17, 2022

Judging from the exception you provided, it seems you’re mixing new driver and legacy code. Can you use com.clickhouse.client.data.ClickHouseBitmap instead? If it’s still not working, can you run the exact test I mentioned above without modification?

Yes, It is my mistakes. I can run the unit test code success .

0reactions
ywill3commented, Jul 5, 2022

Do you find another solutions?

Hi @ywill3, I didn’t spend time for this one so no progress from my side.

I used insert into xxx(a,b,c) values(?,?,bitmapBuild(?)) for prepareStatement. But it doesn’t work ,The bitmap column is Null.

ClickHouse does not support prepared statement. Your query will be converted to a large SQL statement which will be sent to server in string format. In order to leverage binary streaming, you should use input function or external table as mentioned in batch insert example:

-- JDBC driver will figure out parameters by parsing input function
insert into xxx select a, b, bitmapBuild(c) from input('a UUID, b DateTime64(3), c Array(UInt64)')

OK,Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connecting ClickHouse to external data sources with JDBC
The ClickHouse JDBC Bridge allows ClickHouse to access data from any external data source for which a JDBC driver is available.
Read more >
ClickHouse + Spark - Altinity Knowledge Base
ClickHouse can produce / consume data from/to Kafka to exchange data with Spark. via hdfs. You can load data into hadoop/hdfs using sequence...
Read more >
ClickHouse Documentation
It uses a cluster of 374 servers, which store over 20.3 trillion rows in the database. The volume of compressed data, without counting...
Read more >
Clustering 4000 Stack Overflow tags with BigQuery k-means
So I'll take these relationships and I'll save them on an auxiliary ... Then I can use that string to get a huge...
Read more >
Blog - Apache SeaTunnel
For computing engines, we use Presto, Kylin and Clickhouse. ... SeaTunnel, and write Spark programs and use jdbc to insert ClickHouse among ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found