Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9ffd9a4
Implemented JSONEachrow support in client-v2
chernser Apr 10, 2026
090fb85
Added primitive tests for JSON each row
chernser Apr 10, 2026
f88047c
Merge branch 'main' into 04/10/26/json_format_support
chernser Apr 24, 2026
9d281d9
removed JSON processor from driver properties
chernser Apr 24, 2026
8337656
Added examples for json processors
chernser Apr 24, 2026
c5388f0
made both examples runnable. added wrapper
chernser Apr 25, 2026
9135c88
Made examples workable and simple
chernser Apr 25, 2026
f513bb5
Added gradle wrapper jars
chernser Apr 25, 2026
3829736
Added required server settings
chernser Apr 26, 2026
e764960
initial docs
chernser Apr 27, 2026
272aa16
Created a text reader interface to separate binary and text readers.
chernser Apr 27, 2026
a140306
Added more tests
chernser Apr 27, 2026
bd1481e
Merge branch 'main' into 04/10/26/json_format_support
chernser May 6, 2026
eac6c95
Implemented client-v2 part according to the spec
chernser May 19, 2026
ac6eaba
Merge branch 'main' into 04/10/26/json_format_support
chernser May 19, 2026
e848f38
implemented support in JDBC
chernser May 20, 2026
295b9c6
fixed tests to be more stable and test more
chernser May 20, 2026
2dc0c7c
Complete client-v2 example
chernser May 20, 2026
fd6db02
Corrected examples according to the implementation
chernser May 20, 2026
11950bd
removed generate artifacts. added more documentation
chernser May 21, 2026
4eb1cfe
Fixed documentation and typo
chernser May 21, 2026
a640112
fixed problem with next() == true forever
chernser May 21, 2026
c31679b
Fixed type inference for JSON
chernser May 21, 2026
a6e969c
Fixed NPE and mapping
chernser May 21, 2026
aaffb6f
Fixed breaking change and documented more
chernser May 21, 2026
4d4fc7b
Fixed tuples
chernser May 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ public static Map<Class<?>, Integer> buildVariantMapping(List<ClickHouseDataType
return variantMapping;
}

static final Map<ClickHouseDataType, Set<Class<?>>> DATA_TYPE_TO_CLASS = dataTypeClassMap();
public static final Map<ClickHouseDataType, Set<Class<?>>> DATA_TYPE_TO_CLASS =
Collections.unmodifiableMap(dataTypeClassMap());
static Map<ClickHouseDataType, Set<Class<?>>> dataTypeClassMap() {
Map<ClickHouseDataType, Set<Class<?>>> map = new HashMap<>();

Expand Down
20 changes: 19 additions & 1 deletion client-v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,26 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>test</scope>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
Expand Down
25 changes: 25 additions & 0 deletions client-v2/src/main/java/com/clickhouse/client/api/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,7 @@ public CompletableFuture<QueryResponse> query(String sqlQuery, Map<String, Objec
if (requestSettings.getFormat() == null) {
requestSettings.setFormat(ClickHouseFormat.RowBinaryWithNamesAndTypes);
}
applyFormatSpecificSettings(requestSettings);
ClientStatisticsHolder clientStats = new ClientStatisticsHolder();
clientStats.start(ClientMetrics.OP_DURATION);

Expand Down Expand Up @@ -2216,6 +2217,30 @@ private Map<String, Object> buildRequestSettings(Map<String, Object> opSettings)
return requestSettings;
}

/**
* Applies format-specific server-side settings to the already merged request settings.
* Must be called after {@link #buildRequestSettings(Map)} and after the request format has been resolved
* (either provided by the caller or defaulted), so that the inspected format reflects the final value.
*
* <p>For {@link ClickHouseFormat#JSONEachRow}, callers may opt in to plain JSON numbers by setting
* {@link ClientConfigProperties#JSON_DISABLE_NUMBER_QUOTING}. Explicit server settings are otherwise
* left untouched.</p>
* <ul>
* <li>{@code output_format_json_quote_64bit_integers}</li>
* <li>{@code output_format_json_quote_64bit_floats}</li>
* <li>{@code output_format_json_quote_decimals}</li>
* </ul>
*/
private static void applyFormatSpecificSettings(QuerySettings requestSettings) {
boolean disableNumberQuoting = ClientConfigProperties.JSON_DISABLE_NUMBER_QUOTING
.getOrDefault(requestSettings.getAllSettings());
if (requestSettings.getFormat() == ClickHouseFormat.JSONEachRow && disableNumberQuoting) {
requestSettings.serverSetting("output_format_json_quote_64bit_integers", "0");
requestSettings.serverSetting("output_format_json_quote_64bit_floats", "0");
requestSettings.serverSetting("output_format_json_quote_decimals", "0");
}
}

private Duration durationSince(long sinceNanos) {
return Duration.ofNanos(System.nanoTime() - sinceNanos);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public Object parseValue(String value) {
*/
HTTP_SEND_PARAMS_IN_BODY("client.http.use_form_request_for_query", Boolean.class, "false"),

/**
* When enabled for JSONEachRow queries, asks ClickHouse to emit large integer,
* floating-point, and decimal values as JSON numbers instead of quoted strings.
*/
JSON_DISABLE_NUMBER_QUOTING("json_disable_number_quoting", Boolean.class, "false"),

/**
* Prefix for custom settings. Should be aligned with server configuration.
Expand Down
Loading
Loading