Skip to content

Commit 337cb64

Browse files
committed
Merge branch 'main' into sql_testing_framework
2 parents 2b52741 + a36728e commit 337cb64

Some content is hidden

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

43 files changed

+1856
-461
lines changed

.github/workflows/analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
required: false
2929

3030
env:
31-
PREFERRED_LTS_VERSION: "24.3"
31+
PREFERRED_LTS_VERSION: "25.3"
3232
PR_NUMBER: ${{ github.event.pull_request.number || '' }}
3333

3434
jobs:

.github/workflows/benchmarks.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-
CH_VERSION: "24.8"
15+
CH_VERSION: "25.3"
1616
JAVA_VERSION: 17
1717

1818
concurrency:

.github/workflows/build.yml

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ concurrency:
3232
cancel-in-progress: true
3333

3434
env:
35-
PREFERRED_LTS_VERSION: "24.3"
35+
PREFERRED_LTS_VERSION: "25.3"
3636

3737
jobs:
3838
compile:
@@ -57,53 +57,63 @@ jobs:
5757
cache: "maven"
5858
- name: Build and install libraries
5959
run: mvn --batch-mode --no-transfer-progress --show-version --strict-checksums --threads 2 -Dmaven.wagon.rto=30000 -Dj8 -DskipITs install
60+
- name: Copy Artifacts to Build dir
61+
run: |
62+
mkdir clickhouse-jdbc-artifacts
63+
cp -rf $HOME/.m2/repository/com/clickhouse/clickhouse-jdbc/* ./clickhouse-jdbc-artifacts/
6064
- name: Compile examples
6165
run: |
6266
export LIB_VER=$(grep '<revision>' pom.xml | sed -e 's|[[:space:]]*<[/]*revision>[[:space:]]*||g')
6367
find `pwd`/examples -type f -name pom.xml -exec sed -i -e "s|\(<clickhouse-java.version>\).*\(<\)|\1$LIB_VER\2|g" {} \;
6468
for d in $(ls -d `pwd`/examples/*/); do \
6569
if [ -e $d/pom.xml ]; then cd $d && mvn --batch-mode --no-transfer-progress clean compile; fi;
6670
if [ -e $d/gradlew ]; then cd $d && ./gradlew clean build; fi;
67-
done
68-
69-
test-multi-env:
70-
needs: compile
71-
strategy:
72-
matrix:
73-
# https://whichjdk.com/
74-
# https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#selecting-a-java-distribution
75-
# add "corretto", "liberica", "microsoft", "zulu" only when needed
76-
dist: ["temurin"]
77-
# fix issue on "macos-latest", "windows-latest"
78-
os: ["ubuntu-latest"]
79-
fail-fast: false
80-
runs-on: ${{ matrix.os }}
81-
timeout-minutes: 10
82-
name: ${{ matrix.dist }} JDK 17 on ${{ matrix.os }}
83-
steps:
84-
- name: Check out repository
85-
uses: actions/checkout@v4
86-
- name: Check out PR
87-
run: |
88-
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 \
89-
origin pull/${{ github.event.inputs.pr }}/merge:merged-pr && git checkout merged-pr
90-
if: github.event.inputs.pr != ''
91-
- name: Install JDK 17 and Maven
92-
uses: actions/setup-java@v4
93-
with:
94-
distribution: ${{ matrix.dist }}
95-
java-version: 17
96-
cache: "maven"
97-
- name: Test libraries
98-
run: mvn --batch-mode --no-transfer-progress -Dj8 -DskipITs verify
99-
- name: Upload test results
71+
done
72+
- name: Save clickhouse-jdbc-all for tests
10073
uses: actions/upload-artifact@v4
101-
if: failure()
10274
with:
103-
name: result ${{ github.job }}
104-
path: |
105-
**/target/failsafe-reports
106-
**/target/surefire-reports
75+
name: clickhouse-jdbc-archive
76+
path: clickhouse-jdbc-artifacts/
77+
retention-days: 5
78+
79+
# test-multi-env:
80+
# needs: compile
81+
# strategy:
82+
# matrix:
83+
# # https://whichjdk.com/
84+
# # https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#selecting-a-java-distribution
85+
# # add "corretto", "liberica", "microsoft", "zulu" only when needed
86+
# dist: ["temurin"]
87+
# # fix issue on "macos-latest", "windows-latest"
88+
# os: ["ubuntu-latest"]
89+
# fail-fast: false
90+
# runs-on: ${{ matrix.os }}
91+
# timeout-minutes: 10
92+
# name: ${{ matrix.dist }} JDK 17 on ${{ matrix.os }}
93+
# steps:
94+
# - name: Check out repository
95+
# uses: actions/checkout@v4
96+
# - name: Check out PR
97+
# run: |
98+
# git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 \
99+
# origin pull/${{ github.event.inputs.pr }}/merge:merged-pr && git checkout merged-pr
100+
# if: github.event.inputs.pr != ''
101+
# - name: Install JDK 17 and Maven
102+
# uses: actions/setup-java@v4
103+
# with:
104+
# distribution: ${{ matrix.dist }}
105+
# java-version: 17
106+
# cache: "maven"
107+
# - name: Test libraries
108+
# run: mvn --batch-mode --no-transfer-progress -Dj8 -DskipITs verify
109+
# - name: Upload test results
110+
# uses: actions/upload-artifact@v4
111+
# if: failure()
112+
# with:
113+
# name: result ${{ github.job }}
114+
# path: |
115+
# **/target/failsafe-reports
116+
# **/target/surefire-reports
107117

108118
test-native-image:
109119
runs-on: ubuntu-latest
@@ -122,8 +132,7 @@ jobs:
122132
uses: graalvm/setup-graalvm@v1
123133
with:
124134
version: "latest"
125-
java-version: "17"
126-
components: "native-image"
135+
java-version: "21"
127136
github-token: ${{ secrets.GITHUB_TOKEN }}
128137
- name: Build native image
129138
run: mvn --batch-mode --no-transfer-progress -Pnative -Dj8 -DskipTests install
@@ -145,7 +154,7 @@ jobs:
145154
matrix:
146155
# most recent LTS releases as well as latest stable builds
147156
# https://github.com/ClickHouse/ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease
148-
clickhouse: ["24.3", "24.8", "latest"]
157+
clickhouse: ["25.3", "25.8", "latest"]
149158
project: ["clickhouse-http-client", "client-v2"]
150159
fail-fast: false
151160
timeout-minutes: 15
@@ -197,16 +206,18 @@ jobs:
197206
path: |
198207
**/target/failsafe-reports
199208
**/target/surefire-reports
209+
retention-days: 5
200210

201211
test-with-cloud:
202212
runs-on: ubuntu-latest
203-
needs: compile
213+
needs: test-jdbc-driver
204214
strategy:
205215
matrix:
206216
# most recent LTS releases as well as latest stable builds
207217
# https://github.com/ClickHouse/ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease
208218
clickhouse: ["cloud"]
209-
project: ["clickhouse-http-client", "clickhouse-jdbc", "client-v2", "jdbc-v2"]
219+
# project: ["clickhouse-http-client", "clickhouse-jdbc", "client-v2", "jdbc-v2"]
220+
project: ["client-v2", "jdbc-v2"]
210221
fail-fast: false
211222
timeout-minutes: 20
212223
name: ${{ matrix.project }} + CH ${{ matrix.clickhouse }}
@@ -265,10 +276,10 @@ jobs:
265276
266277
test-jdbc-driver:
267278
runs-on: ubuntu-latest
268-
needs: compile
279+
needs: test-java-client
269280
strategy:
270281
matrix:
271-
clickhouse: ["24.3", "24.8", "latest"]
282+
clickhouse: ["25.3", "25.8", "latest"]
272283
# here http, http_client and apache_http_client represent different value of http_connection_provider
273284
# protocol: ["http", "http_client", "apache_http_client"]
274285
protocol: ["apache_http_client"]
@@ -328,10 +339,10 @@ jobs:
328339
329340
test-r2dbc-driver:
330341
runs-on: ubuntu-latest
331-
needs: compile
342+
needs: test-jdbc-driver
332343
strategy:
333344
matrix:
334-
clickhouse: ["24.3", "24.8", "latest"]
345+
clickhouse: ["25.3", "25.8", "latest"]
335346
# grpc is not fully supported, and http_client and apache_http_client do not work in CI environment(due to limited threads?)
336347
protocol: ["http"]
337348
r2dbc: ["1.0.0.RELEASE", "0.9.1.RELEASE"]

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
env:
1414
CHC_BRANCH: "main"
1515
# CHC_VERSION: "0.9.0"
16-
CH_VERSION: "24.8"
16+
CH_VERSION: "25.3"
1717

1818
jobs:
1919
nightly:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
required: true
99

1010
env:
11-
CH_VERSION: "24.8"
11+
CH_VERSION: "25.3"
1212

1313
jobs:
1414
release:

.github/workflows/run_examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
ch_version:
77
description: ClickHouse Version
88
required: false
9-
default: 24.8
9+
default: 25.8
1010
client_version:
1111
description: Build Type
1212
type: choice

clickhouse-jdbc/src/test/java/com/clickhouse/jdbc/ClickHouseDriverTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package com.clickhouse.jdbc;
22

3-
import java.sql.Connection;
4-
import java.sql.SQLException;
5-
63
import com.clickhouse.client.ClickHouseProtocol;
7-
84
import com.clickhouse.client.ClickHouseServerForTest;
9-
import com.clickhouse.client.config.ClickHouseDefaults;
10-
import com.clickhouse.jdbc.internal.ClickHouseJdbcUrlParser;
115
import org.testng.Assert;
126
import org.testng.annotations.Test;
137

8+
import java.sql.Connection;
9+
import java.sql.SQLException;
10+
1411
public class ClickHouseDriverTest extends JdbcIntegrationTest {
1512
@Test(groups = "integration")
1613
public void testAcceptUrl() throws SQLException {
@@ -24,13 +21,21 @@ public void testAcceptUrl() throws SQLException {
2421

2522
@Test(groups = "integration")
2623
public void testConnect() throws SQLException {
27-
if (isCloud()) return; //TODO: testConnect - Revisit, see: https://github.com/ClickHouse/clickhouse-java/issues/1747
24+
if (isCloud()) {
25+
return; //
26+
}
27+
2828
System.setProperty("clickhouse.jdbc.v1","true");
2929
String address = getServerAddress(ClickHouseProtocol.HTTP, true);
3030
ClickHouseDriver driver = new ClickHouseDriver();
3131
Connection conn = driver.connect("jdbc:clickhouse://default:" + ClickHouseServerForTest.getPassword() + "@" + address, null);
3232
conn.close();
33+
System.setProperty("clickhouse.jdbc.v1","false");
34+
ClickHouseDriver driver2 = new ClickHouseDriver();
35+
Connection conn2 = driver2.connect("jdbc:clickhouse://default:" + ClickHouseServerForTest.getPassword() + "@" + address, null);
36+
conn2.close();
3337
}
38+
3439
@Test(groups = "integration")
3540
public void testV2Driver() {
3641
System.setProperty("clickhouse.jdbc.v1","false");

clickhouse-jdbc/src/test/java/com/clickhouse/jdbc/ClickHouseStatementTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.util.List;
5353
import java.util.Locale;
5454
import java.util.Properties;
55+
import java.util.ServiceLoader;
5556
import java.util.TimeZone;
5657
import java.util.UUID;
5758
import java.util.concurrent.CountDownLatch;

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public class Client implements AutoCloseable {
136136
private final Map<ClickHouseDataType, Class<?>> typeHintMapping;
137137

138138
// Server context
139+
private String dbUser;
139140
private String serverVersion;
140141
private Object metricsRegistry;
141142
private int retries;
@@ -196,7 +197,7 @@ private Client(Set<String> endpoints, Map<String,String> configuration,
196197
}
197198

198199
this.serverVersion = configuration.getOrDefault(ClientConfigProperties.SERVER_VERSION.getKey(), "unknown");
199-
200+
this.dbUser = configuration.getOrDefault(ClientConfigProperties.USER.getKey(), ClientConfigProperties.USER.getDefObjVal());
200201
this.typeHintMapping = (Map<ClickHouseDataType, Class<?>>) this.configuration.get(ClientConfigProperties.TYPE_HINT_MAPPING.getKey());
201202
}
202203

@@ -208,7 +209,10 @@ public void loadServerInfo() {
208209
try (QueryResponse response = this.query("SELECT currentUser() AS user, timezone() AS timezone, version() AS version LIMIT 1").get()) {
209210
try (ClickHouseBinaryFormatReader reader = this.newBinaryFormatReader(response)) {
210211
if (reader.next() != null) {
211-
this.configuration.put(ClientConfigProperties.USER.getKey(), reader.getString("user"));
212+
String tmpDbUser = reader.getString("user");
213+
if (tmpDbUser != null && !tmpDbUser.isEmpty()) {
214+
this.dbUser = tmpDbUser;
215+
}
212216
this.configuration.put(ClientConfigProperties.SERVER_TIMEZONE.getKey(), reader.getString("timezone"));
213217
serverVersion = reader.getString("version");
214218
}
@@ -766,6 +770,8 @@ public Builder useServerTimeZone(boolean useServerTimeZone) {
766770
*/
767771
public Builder useTimeZone(String timeZone) {
768772
this.configuration.put(ClientConfigProperties.USE_TIMEZONE.getKey(), timeZone);
773+
// switch using server timezone to false
774+
this.configuration.put(ClientConfigProperties.USE_SERVER_TIMEZONE.getKey(), String.valueOf(Boolean.FALSE));
769775
return this;
770776
}
771777

@@ -2039,7 +2045,7 @@ public Set<String> getEndpoints() {
20392045
}
20402046

20412047
public String getUser() {
2042-
return (String) this.configuration.get(ClientConfigProperties.USER.getKey());
2048+
return dbUser;
20432049
}
20442050

20452051
public String getServerVersion() {

client-v2/src/main/java/com/clickhouse/client/api/DataTypeUtils.java

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

3-
import java.time.Instant;
4-
import java.time.ZoneId;
53
import com.clickhouse.client.api.data_formats.internal.BinaryStreamReader;
4+
import com.clickhouse.data.ClickHouseDataType;
65

76
import java.time.Instant;
87
import java.time.ZoneId;
@@ -11,8 +10,6 @@
1110
import java.time.temporal.ChronoField;
1211
import java.util.Objects;
1312

14-
import com.clickhouse.data.ClickHouseDataType;
15-
1613
import static com.clickhouse.client.api.data_formats.internal.BinaryStreamReader.BASES;
1714

1815
public class DataTypeUtils {
@@ -39,6 +36,10 @@ public class DataTypeUtils {
3936
.appendFraction(ChronoField.NANO_OF_SECOND, 9, 9, true)
4037
.toFormatter();
4138

39+
public static final DateTimeFormatter TIME_WITH_NANOS_FORMATTER = INSTANT_FORMATTER;
40+
41+
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss");
42+
4243
/**
4344
* Formats an {@link Instant} object for use in SQL statements or as query
4445
* parameter.

0 commit comments

Comments
 (0)