ClickHouse / clickhouse-java

ClickHouse Java Clients & JDBC Driver
https://clickhouse.com
Apache License 2.0
1.45k stars 535 forks source link

[client-v2] JSON Support #1833

Open chernser opened 1 month ago

chernser commented 1 month ago

Description

Client should support JSON Data type (https://clickhouse.com/docs/en/integrations/data-formats/json/overview).

Considerations:


See also:

dzmitry-biatenia-smop commented 1 week ago

@chernser any idea when 0.7.2 Java client will be released?

chernser commented 1 week ago

Hi @dzmitry-biatenia-smop! We plan to release 0.7.2 by end of November. However this functionality is not in the 0.7.2: it is a complex and experimental feature - so it will take time to add it to the client. However 0.7.2 might have a minimal support when JSON columns can be read/written as a string.

How would you use JSON? Do you have a DTO object or do you work directly with some generic classes generated by GSON or Jackson ?

Thanks!

dzmitry-biatenia-smop commented 1 week ago

@chernser the basic case - I was able to create a column with JSON type in Clickhouse table with flag _allow_experimental_jsontype enabled, and even was able to insert some JSON data there with com.clickhouse.client.api.Client#execute(), but when can running any com.clickhouse.client.api.Client.query("select * from table_with_json_column") I'm getting Unsupported format: "JSON" coming from here because response has JSON type here. I tried to set _output_format_binary_write_json_asstring , but seems it's not supported by my version of server 24.8.4

chernser commented 1 week ago

@dzmitry-biatenia-smop I will fix this issue for sure.

dzmitry-biatenia-smop commented 1 week ago

@chernser are you going to release that fix separately? any ETA for that fix?

chernser commented 1 week ago

@dzmitry-biatenia-smop patch should be release by end of this week. release is by end of the month another option is to take nightly build.

dzmitry-biatenia-smop commented 1 week ago

@chernser can you please notify me when that patch is ready or point me to the correct nightly build?

chernser commented 1 week ago

@dzmitry-biatenia-smop yes, sure!

chernser commented 5 days ago

Good day, @dzmitry-biatenia-smop ! I've just merged the JSON support (see example). Nightly build should be ready in a several minutes. Here is how to use it https://gist.github.com/chernser/b4eacfde70093847449e3aef8e51ae8e