Skip to content

Commit a90cf60

Browse files
committed
Merge branch 'main' into dependabot/maven/dnsjava-dnsjava-3.6.0
2 parents 679b6b0 + bc1f50d commit a90cf60

File tree

81 files changed

+4071
-822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4071
-822
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,20 @@ jobs:
5151
uses: actions/setup-java@v4
5252
with:
5353
distribution: "temurin"
54-
java-version: 8
54+
java-version: |
55+
8
56+
21
5557
cache: "maven"
5658
- name: Build and install libraries
5759
run: mvn --batch-mode --no-transfer-progress --show-version --strict-checksums --threads 2 -Dmaven.wagon.rto=30000 -DclickhouseVersion=$PREFERRED_LTS_VERSION -Dj8 install
5860
- name: Compile examples
5961
run: |
6062
export LIB_VER=$(grep '<revision>' pom.xml | sed -e 's|[[:space:]]*<[/]*revision>[[:space:]]*||g')
6163
find `pwd`/examples -type f -name pom.xml -exec sed -i -e "s|\(<clickhouse-java.version>\).*\(<\)|\1$LIB_VER\2|g" {} \;
62-
for d in $(ls -d `pwd`/examples/*/); do cd $d && mvn --batch-mode --no-transfer-progress clean compile; done
64+
for d in $(ls -d `pwd`/examples/*/); do \
65+
if [ -e $d/pom.xml ]; then cd $d && mvn --batch-mode --no-transfer-progress clean compile; fi;
66+
if [ -e $d/gradlew ]; then cd $d && ./gradlew clean build; fi;
67+
done
6368
- name: Upload test results
6469
uses: actions/upload-artifact@v4
6570
if: failure()
@@ -141,45 +146,6 @@ jobs:
141146
- name: Test compressed native image
142147
run: ./clickhouse-jdbc/target/clickhouse-jdbc-bin
143148

144-
test-cli-client:
145-
runs-on: ubuntu-latest
146-
needs: compile
147-
timeout-minutes: 10
148-
name: CLI client + CH LTS
149-
steps:
150-
- name: Check out repository
151-
uses: actions/checkout@v4
152-
- name: Check out PR
153-
run: |
154-
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 \
155-
origin pull/${{ github.event.inputs.pr }}/merge:merged-pr && git checkout merged-pr
156-
if: github.event.inputs.pr != ''
157-
- name: Install JDK 8 and Maven
158-
uses: actions/setup-java@v4
159-
with:
160-
distribution: "temurin"
161-
java-version: 8
162-
cache: "maven"
163-
- name: Install ClickHouse native command line
164-
run: |
165-
sudo apt-get update \
166-
&& sudo apt-get install -y apt-transport-https ca-certificates dirmngr \
167-
&& sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754 \
168-
&& echo "deb https://packages.clickhouse.com/deb lts main" | sudo tee /etc/apt/sources.list.d/clickhouse.list \
169-
&& sudo apt-get update && sudo apt-get install -y clickhouse-client \
170-
&& clickhouse client --version
171-
- name: Test CLI client
172-
run: |
173-
mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-cli-client -DclickhouseVersion=$PREFERRED_LTS_VERSION -Dj8 -DskipUTs verify
174-
- name: Upload test results
175-
uses: actions/upload-artifact@v4
176-
if: failure()
177-
with:
178-
name: result ${{ github.job }}
179-
path: |
180-
**/target/failsafe-reports
181-
**/target/surefire-reports
182-
183149
test-java-client:
184150
runs-on: ubuntu-latest
185151
needs: compile
@@ -230,7 +196,7 @@ jobs:
230196
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
231197
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
232198
run: |
233-
mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-cli-client,clickhouse-grpc-client,clickhouse-http-client -DclickhouseVersion=${{ matrix.clickhouse }} verify
199+
mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-http-client -DclickhouseVersion=${{ matrix.clickhouse }} verify
234200
- name: Upload test results
235201
uses: actions/upload-artifact@v4
236202
if: failure()
@@ -265,6 +231,7 @@ jobs:
265231
java-version: |
266232
8
267233
17
234+
21
268235
cache: "maven"
269236
- name: Setup Toolchain
270237
shell: bash
@@ -308,7 +275,7 @@ jobs:
308275
matrix:
309276
clickhouse: ["23.8", "24.3", "24.6", "latest", "cloud"]
310277
# here http, http_client and apache_http_client represent different value of http_connection_provider
311-
protocol: ["http", "http_client", "apache_http_client", "grpc"]
278+
protocol: ["http", "http_client", "apache_http_client"]
312279
fail-fast: false
313280
timeout-minutes: 15
314281
name: JDBC driver + CH ${{ matrix.clickhouse }} (${{ matrix.protocol }})
@@ -347,7 +314,7 @@ jobs:
347314
</toolchains>
348315
EOF
349316
- name: Install Java client
350-
run: mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-cli-client,clickhouse-grpc-client,clickhouse-http-client -DskipTests install
317+
run: mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-http-client -DskipTests install
351318
- name: Test JDBC driver
352319
env:
353320
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
@@ -463,7 +430,7 @@ jobs:
463430
java-version: 8
464431
cache: "maven"
465432
- name: Install Java client
466-
run: mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-cli-client,clickhouse-grpc-client,clickhouse-http-client -Dj8 -DskipTests install
433+
run: mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-http-client -Dj8 -DskipTests install
467434
- name: Test JDBC and R2DBC drivers
468435
run: |
469436
mvn --batch-mode --no-transfer-progress --projects clickhouse-jdbc,clickhouse-r2dbc -DclickhouseVersion=$PREFERRED_LTS_VERSION \

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
env:
1414
CHC_BRANCH: "main"
15-
CHC_VERSION: "0.6.3"
15+
CHC_VERSION: "0.6.4"
1616

1717
jobs:
1818
nightly:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
version:
77
description: "Release version"
88
required: true
9-
default: "0.6.3-SNAPSHOT"
9+
default: "0.6.4-SNAPSHOT"
1010

1111
jobs:
1212
release:

CHANGELOG.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,56 @@
11
## Latest
22

3+
## 0.6.4
4+
5+
### Deprecations
6+
- Following components will be deprecated and archived in next release:
7+
- clickhouse-cli-client
8+
- clickhouse-grpc-client
9+
- No more builds for non-lts Java versions - no more Java 9 release builds.
10+
- Lowest supported Java version will be 11.
11+
- Java 11 support will be ended before the end of 2023.
12+
- It is recommended to use Java 21.
13+
14+
### Important Changes
15+
- [Client-V1] Fix for handling DateTime without timezone when `session_timezone` is set. Now server timezone
16+
is parsed from server response when present (https://github.com/ClickHouse/clickhouse-java/issues/1464)
17+
18+
### New Features
19+
- [Client-V1/Apache HTTP] More configuration parameters for connection management. Useful for tuning performance.
20+
(https://github.com/ClickHouse/clickhouse-java/pull/1771)
21+
- com.clickhouse.client.config.ClickHouseClientOption#CONNECTION_TTL - to configure connection time-to-live
22+
- com.clickhouse.client.http.config.ClickHouseHttpOption#KEEP_ALIVE_TIMEOUT - to configure keep-alive timeout
23+
- com.clickhouse.client.http.config.ClickHouseHttpOption#CONNECTION_REUSE_STRATEGY - defines how connection pool behaves.
24+
If `FIFO` is selected then connections are reused in the order they were created. It results in even distribution of connections.
25+
If `LIFO` is selected then connections are reused as soon they are returned to the pool.
26+
Note: only for `APACHE_HTTP_CLIENT` connection provider.
27+
- Additionally switched to using LAX connection pool for Apache Connection Manager to improve performance
28+
for concurrent requests.
29+
- [Client-V2] Connection pool configuration https://github.com/ClickHouse/clickhouse-java/pull/1766
30+
- com.clickhouse.client.api.Client.Builder.setConnectionRequestTimeout - to configure connection request timeout.
31+
Important when there are no connections available in the pool to fail fast.
32+
- com.clickhouse.client.api.Client.Builder.setMaxConnections - configures how soft limit of connections per host.
33+
Note: Total number of connections is unlimited because in most cases there is one host.
34+
- com.clickhouse.client.api.Client.Builder.setConnectionTTL - to limit connection live ignoring keep-alive from server.
35+
- com.clickhouse.client.api.Client.Builder.setConnectionReuseStrategy - to configure how connections are used.
36+
Select FIFO to reuse connections evenly or LIFO (default) to reuse the most recently active connections.
37+
- [Client-V2] All operations are now executed in calling thread to avoid extra threads creation.
38+
Async operations can be enabled by `com.clickhouse.client.api.Client.Builder.useAsyncRequests` (https://github.com/ClickHouse/clickhouse-java/pull/1767)
39+
- [Client-V2] Content and HTTP native compression is supported now Currently only LZ4 is available. (https://github.com/ClickHouse/clickhouse-java/pull/1761)
40+
- [Client-V2] HTTPS support added. Required to communicate with ClickHouse Cloud Services.
41+
Client certificates are supported, too. (https://github.com/ClickHouse/clickhouse-java/pull/1753)
42+
- [Client-V2] Added support for HTTP proxy (https://github.com/ClickHouse/clickhouse-java/pull/1748)
43+
44+
### Documentation
45+
- [Client-V2] Spring Demo Service as usage example (https://github.com/ClickHouse/clickhouse-java/pull/1765)
46+
- [Client-V2] Examples for using text based formats (https://github.com/ClickHouse/clickhouse-java/pull/1752)
47+
48+
49+
### Bug Fixes
50+
- [Client-V2] Data is read fully from a stream. Important for Cloud instances (https://github.com/ClickHouse/clickhouse-java/pull/1759)
51+
- [Client-V2] Timezone from a server response is now used to parse DateTime values (https://github.com/ClickHouse/clickhouse-java/pull/1763)
52+
- [Client-V1] Timezone from a server response is now used to parse DateTime values (https://github.com/ClickHouse/clickhouse-java/issues/1464)
53+
354
## 0.6.3
455

556
### Important Changes

clickhouse-cli-client/src/main/java/com/clickhouse/client/cli/ClickHouseCommandLineResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ClickHouseCommandLineResponse extends ClickHouseStreamResponse {
1414
private final transient ClickHouseCommandLine cli;
1515

1616
protected ClickHouseCommandLineResponse(ClickHouseConfig config, ClickHouseCommandLine cli) throws IOException {
17-
super(config, cli.getInputStream(), null, null, ClickHouseResponseSummary.EMPTY);
17+
super(config, cli.getInputStream(), null, null, ClickHouseResponseSummary.EMPTY, null);
1818
this.cli = cli;
1919

2020
if (processor.getInputStream().available() < 1) {

clickhouse-cli-client/src/test/java/com/clickhouse/client/cli/ClickHouseCommandLineClientTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.clickhouse.client.ClientIntegrationTest;
1111
import com.clickhouse.client.cli.config.ClickHouseCommandLineOption;
1212
import com.clickhouse.data.ClickHouseCompression;
13+
import com.clickhouse.data.ClickHouseFormat;
1314
import org.testcontainers.containers.GenericContainer;
1415
import org.testng.SkipException;
1516
import org.testng.annotations.BeforeClass;
@@ -199,4 +200,9 @@ public void testLoadBalancingPolicyFailover(ClickHouseLoadBalancingPolicy loadBa
199200
public void testFailover() {
200201
throw new SkipException("Skip due to failover is not supported");
201202
}
203+
204+
@Override
205+
public void testServerTimezoneAppliedFromHeader(ClickHouseFormat format) throws Exception {
206+
throw new SkipException("Skip due to session timezone is not supported");
207+
}
202208
}

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseResponse.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.NoSuchElementException;
1010
import java.util.Spliterator;
1111
import java.util.Spliterators;
12+
import java.util.TimeZone;
1213
import java.util.stream.Stream;
1314
import java.util.stream.StreamSupport;
1415

@@ -39,7 +40,7 @@ public interface ClickHouseResponse extends AutoCloseable, Serializable {
3940
/**
4041
* Empty response that can never be closed.
4142
*/
42-
static final ClickHouseResponse EMPTY = new ClickHouseResponse() {
43+
ClickHouseResponse EMPTY = new ClickHouseResponse() {
4344
@Override
4445
public List<ClickHouseColumn> getColumns() {
4546
return Collections.emptyList();
@@ -75,6 +76,11 @@ public boolean isClosed() {
7576
// ensure the instance is "stateless"
7677
return false;
7778
}
79+
80+
@Override
81+
public TimeZone getTimeZone() {
82+
return null;
83+
}
7884
};
7985

8086
/**
@@ -102,6 +108,15 @@ public boolean isClosed() {
102108
*/
103109
ClickHouseInputStream getInputStream();
104110

111+
/**
112+
* Returns a server timezone if it is returned by server in a header {@code X-ClickHouse-Timezone } or
113+
* other way. If not, it returns null
114+
* @return server timezone from server response or null
115+
*/
116+
default TimeZone getTimeZone() {
117+
return null;
118+
}
119+
105120
/**
106121
* Gets the first record only. Please use {@link #records()} instead if you need
107122
* to access the rest of records.

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseSimpleResponse.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
package com.clickhouse.client;
22

3-
import java.util.ArrayList;
4-
import java.util.Collections;
5-
import java.util.LinkedList;
6-
import java.util.List;
7-
83
import com.clickhouse.data.ClickHouseColumn;
94
import com.clickhouse.data.ClickHouseInputStream;
105
import com.clickhouse.data.ClickHouseRecord;
@@ -13,12 +8,19 @@
138
import com.clickhouse.data.ClickHouseSimpleRecord;
149
import com.clickhouse.data.ClickHouseValue;
1510

11+
import java.util.ArrayList;
12+
import java.util.Collections;
13+
import java.util.LinkedList;
14+
import java.util.List;
15+
import java.util.TimeZone;
16+
1617
/**
1718
* A simple response built on top of two lists: columns and records.
1819
*/
1920
public class ClickHouseSimpleResponse implements ClickHouseResponse {
2021
private static final long serialVersionUID = 6883452584393840649L;
2122

23+
private final TimeZone timeZone;
2224
/**
2325
* Creates a response object using columns definition and raw values.
2426
*
@@ -28,7 +30,7 @@ public class ClickHouseSimpleResponse implements ClickHouseResponse {
2830
* @return response object
2931
*/
3032
public static ClickHouseResponse of(ClickHouseConfig config, List<ClickHouseColumn> columns, Object[][] values) {
31-
return of(config, columns, values, null);
33+
return of(config, columns, values, null, null);
3234
}
3335

3436
/**
@@ -41,7 +43,7 @@ public static ClickHouseResponse of(ClickHouseConfig config, List<ClickHouseColu
4143
* @return response object
4244
*/
4345
public static ClickHouseResponse of(ClickHouseConfig config, List<ClickHouseColumn> columns, Object[][] values,
44-
ClickHouseResponseSummary summary) {
46+
ClickHouseResponseSummary summary, TimeZone timeZone) {
4547
if (columns == null) {
4648
columns = Collections.emptyList();
4749
}
@@ -69,7 +71,7 @@ public static ClickHouseResponse of(ClickHouseConfig config, List<ClickHouseColu
6971
}
7072
}
7173

72-
return new ClickHouseSimpleResponse(columns, wrappedValues, summary);
74+
return new ClickHouseSimpleResponse(columns, wrappedValues, summary, timeZone);
7375
}
7476

7577
/**
@@ -118,7 +120,7 @@ public static ClickHouseResponse of(ClickHouseResponse response, ClickHouseRecor
118120
records.add(rec);
119121
}
120122

121-
return new ClickHouseSimpleResponse(response.getColumns(), records, response.getSummary());
123+
return new ClickHouseSimpleResponse(response.getColumns(), records, response.getSummary(), response.getTimeZone());
122124
}
123125

124126
private final List<ClickHouseColumn> columns;
@@ -129,14 +131,15 @@ public static ClickHouseResponse of(ClickHouseResponse response, ClickHouseRecor
129131
private volatile boolean closed;
130132

131133
protected ClickHouseSimpleResponse(List<ClickHouseColumn> columns, List<ClickHouseRecord> records,
132-
ClickHouseResponseSummary summary) {
134+
ClickHouseResponseSummary summary, TimeZone timeZone) {
133135
this.columns = columns;
134136
this.records = Collections.unmodifiableList(records);
135137
this.summary = summary != null ? summary : ClickHouseResponseSummary.EMPTY;
138+
this.timeZone = timeZone;
136139
}
137140

138141
protected ClickHouseSimpleResponse(List<ClickHouseColumn> columns, ClickHouseValue[][] values,
139-
ClickHouseResponseSummary summary) {
142+
ClickHouseResponseSummary summary, TimeZone timeZone) {
140143
this.columns = columns;
141144

142145
int len = values.length;
@@ -148,6 +151,7 @@ protected ClickHouseSimpleResponse(List<ClickHouseColumn> columns, ClickHouseVal
148151
this.records = Collections.unmodifiableList(list);
149152

150153
this.summary = summary != null ? summary : ClickHouseResponseSummary.EMPTY;
154+
this.timeZone = timeZone;
151155
}
152156

153157
@Override
@@ -165,6 +169,11 @@ public ClickHouseInputStream getInputStream() {
165169
throw new UnsupportedOperationException("An in-memory response does not have input stream");
166170
}
167171

172+
@Override
173+
public TimeZone getTimeZone() {
174+
return timeZone;
175+
}
176+
168177
@Override
169178
public Iterable<ClickHouseRecord> records() {
170179
return records;

0 commit comments

Comments
 (0)