Skip to content

Commit 999c070

Browse files
committed
Merge branch 'main' into feat_client_protobuf_example
2 parents 8cdea89 + 287919a commit 999c070

File tree

34 files changed

+815
-212
lines changed

34 files changed

+815
-212
lines changed

.github/workflows/nightly.yml

Lines changed: 5 additions & 5 deletions
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.0"
15+
CHC_VERSION: "0.6.2"
1616

1717
jobs:
1818
nightly:
@@ -69,8 +69,8 @@ jobs:
6969
maven_args: -q --batch-mode
7070
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
7171
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
72-
nexus_username: ${{ secrets.SONATYPE_USER }}
73-
nexus_password: ${{ secrets.SONATYPE_PASSWD }}
72+
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
73+
nexus_password: ${{ secrets.SONATYPE_TOKEN }}
7474
- name: Release R2DBC 0.9.1 Snapshot
7575
uses: samuelmeuli/action-maven-publish@v1
7676
with:
@@ -79,5 +79,5 @@ jobs:
7979
maven_args: -q --batch-mode -Dr2dbc-spi.version=0.9.1.RELEASE
8080
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
8181
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
82-
nexus_username: ${{ secrets.SONATYPE_USER }}
83-
nexus_password: ${{ secrets.SONATYPE_PASSWD }}
82+
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
83+
nexus_password: ${{ secrets.SONATYPE_TOKEN }}

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
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.0-SNAPSHOT"
9+
default: "0.6.2-SNAPSHOT"
1010

1111
jobs:
1212
release:
@@ -57,8 +57,8 @@ jobs:
5757
maven_args: -q --batch-mode
5858
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
5959
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
60-
nexus_username: ${{ secrets.SONATYPE_USER }}
61-
nexus_password: ${{ secrets.SONATYPE_PASSWD }}
60+
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
61+
nexus_password: ${{ secrets.SONATYPE_TOKEN }}
6262
- name: Release R2DBC 0.9.1
6363
uses: samuelmeuli/action-maven-publish@v1
6464
with:
@@ -67,8 +67,8 @@ jobs:
6767
maven_args: -q --batch-mode -Dr2dbc-spi.version=0.9.1.RELEASE
6868
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
6969
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
70-
nexus_username: ${{ secrets.SONATYPE_USER }}
71-
nexus_password: ${{ secrets.SONATYPE_PASSWD }}
70+
nexus_username: ${{ secrets.SONATYPE_TOKEN_USER }}
71+
nexus_password: ${{ secrets.SONATYPE_TOKEN }}
7272
- name: Create Pre-release on Github
7373
uses: "zhicwu/action-automatic-releases@latest"
7474
with:

CHANGELOG.md

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

3+
## 0.6.2
4+
5+
### New Features
6+
- Describe non-executed SELECT queries in prepared statements to provide metadata (https://github.com/ClickHouse/clickhouse-java/issues/1430)
7+
- Command execution in the client API (https://github.com/ClickHouse/clickhouse-java/pull/1693)
8+
- Added `com.clickhouse.client.ClickHouseResponseSummary#getQueryId()` (https://github.com/ClickHouse/clickhouse-java/issues/1636)
9+
- Added support for SSL for the Client V2
10+
- Added proxy support for Client V2 (https://github.com/ClickHouse/clickhouse-java/pull/1694)
11+
- Added more examples for Client V2 (https://github.com/ClickHouse/clickhouse-java/pull/1709)
12+
313
## 0.6.1
414

515
### New Features

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,10 @@ public static ClickHouseNode of(String uri, Map<?, ?> options) {
787787
String scheme = normalizedUri.getScheme();
788788
ClickHouseProtocol protocol = ClickHouseProtocol.fromUriScheme(scheme);
789789
int port = extract(scheme, normalizedUri.getPort(), protocol, params);
790-
790+
if ((options == null || options.get(ClickHouseClientOption.SSL.getKey()) == null)
791+
&& scheme.equalsIgnoreCase("https")) {
792+
params.put(ClickHouseClientOption.SSL.getKey(), "true");
793+
}
791794
ClickHouseCredentials credentials = extract(normalizedUri.getRawUserInfo(), params, null);
792795

793796
return new ClickHouseNode(normalizedUri.getHost(), protocol, port, credentials, params, tags);

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ClickHouseResponseSummary implements Serializable {
2020
public static final class Progress implements Serializable {
2121
private static final long serialVersionUID = -1447066780591278108L;
2222

23-
static final Progress EMPTY = new Progress(0L, 0L, 0L, 0L, 0L, 0L, 0L);
23+
static final Progress EMPTY = new Progress(0L, 0L, 0L, 0L, 0L, 0L, 0L, "");
2424

2525
private final long read_rows;
2626
private final long read_bytes;
@@ -29,6 +29,7 @@ public static final class Progress implements Serializable {
2929
private final long written_bytes;
3030
private final long elapsed_time;
3131
private final long result_rows;
32+
private final String query_id;
3233

3334
/**
3435
* Default constructor.
@@ -39,16 +40,34 @@ public static final class Progress implements Serializable {
3940
* @param written_rows Number of rows written
4041
* @param written_bytes Volume of data written in bytes
4142
* @param elapsed_time Query processing time in (ns)
43+
* @param result_rows Number of rows in the result
4244
*/
4345
public Progress(long read_rows, long read_bytes, long total_rows_to_read, long written_rows,
44-
long written_bytes, long elapsed_time, long result_rows) {
46+
long written_bytes, long elapsed_time, long result_rows) {
47+
this(read_rows, read_bytes, total_rows_to_read, written_rows, written_bytes, elapsed_time, result_rows, "");
48+
}
49+
/**
50+
* Default constructor.
51+
*
52+
* @param read_rows Number of rows read
53+
* @param read_bytes Volume of data read in bytes
54+
* @param total_rows_to_read Total number of rows to be read
55+
* @param written_rows Number of rows written
56+
* @param written_bytes Volume of data written in bytes
57+
* @param elapsed_time Query processing time in (ns)
58+
* @param result_rows Number of rows in the result
59+
* @param query_id Query ID
60+
*/
61+
public Progress(long read_rows, long read_bytes, long total_rows_to_read, long written_rows,
62+
long written_bytes, long elapsed_time, long result_rows, String query_id) {
4563
this.read_rows = read_rows;
4664
this.read_bytes = read_bytes;
4765
this.total_rows_to_read = total_rows_to_read;
4866
this.written_rows = written_rows;
4967
this.written_bytes = written_bytes;
5068
this.elapsed_time = elapsed_time;
5169
this.result_rows = result_rows;
70+
this.query_id = query_id;
5271
}
5372

5473
public long getReadRows() {
@@ -78,6 +97,10 @@ public long getElapsedTime() {
7897
public long getResultRows() {
7998
return result_rows;
8099
}
100+
101+
public String getQueryId() {
102+
return query_id;
103+
}
81104
public Progress add(Progress progress) {
82105
if (progress == null) {
83106
return this;
@@ -86,7 +109,7 @@ public Progress add(Progress progress) {
86109
return new Progress(read_rows + progress.read_rows, read_bytes + progress.read_bytes,
87110
total_rows_to_read + progress.total_rows_to_read, written_rows + progress.written_rows,
88111
written_bytes + progress.written_bytes,elapsed_time + progress.elapsed_time,
89-
result_rows + progress.result_rows);
112+
result_rows + progress.result_rows, query_id + ", " + progress.query_id);
90113
}
91114

92115
public boolean isEmpty() {
@@ -322,6 +345,10 @@ public long getResultRows() {
322345
return progress.get().getResultRows();
323346
}
324347

348+
public String getQueryId() {
349+
return progress.get().getQueryId();
350+
}
351+
325352
public boolean isEmpty() {
326353
return progress.get().isEmpty() && stats.get().isEmpty();
327354
}

clickhouse-client/src/test/java/com/clickhouse/client/ClickHouseResponseSummaryTest.java

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

99
public class ClickHouseResponseSummaryTest {
1010
@Test(groups = { "unit" })
11-
public void testConsutrctor() {
11+
public void testConstructor() {
1212
ClickHouseResponseSummary summary = new ClickHouseResponseSummary(null, null);
1313
Assert.assertNotNull(summary.getProgress());
1414
Assert.assertNotNull(summary.getStatistics());

clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseColumn.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ private ClickHouseColumn(ClickHouseDataType dataType, String columnName, String
589589
this.originalTypeName = originalTypeName == null ? dataType.name() : originalTypeName;
590590
this.nullable = nullable;
591591
this.lowCardinality = lowCardinality;
592-
this.hasDefault = originalTypeName != null && originalTypeName.toUpperCase().contains("DEFAULT");
592+
this.hasDefault = false;
593593

594594
if (parameters == null || parameters.isEmpty()) {
595595
this.parameters = Collections.emptyList();
@@ -734,6 +734,10 @@ public boolean hasDefault() {
734734
return hasDefault;
735735
}
736736

737+
public void setHasDefault(boolean hasDefault) {
738+
this.hasDefault = hasDefault;
739+
}
740+
737741
public boolean isLowCardinality() {
738742
return !lowCardinalityDisabled && lowCardinality;
739743
}

clickhouse-http-client/src/main/java/com/clickhouse/client/http/ClickHouseHttpResponse.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.clickhouse.data.ClickHouseFormat;
1515
import com.clickhouse.data.ClickHouseInputStream;
1616
import com.clickhouse.data.ClickHouseUtils;
17+
import com.clickhouse.logging.Logger;
1718

1819
public class ClickHouseHttpResponse {
1920
private static long getLongValue(Map<String, String> map, String key) {
@@ -70,7 +71,7 @@ public ClickHouseHttpResponse(ClickHouseHttpConnection connection, ClickHouseInp
7071
new ClickHouseResponseSummary.Progress(getLongValue(map, "read_rows"), getLongValue(map, "read_bytes"),
7172
getLongValue(map, "total_rows_to_read"), getLongValue(map, "written_rows"),
7273
getLongValue(map, "written_bytes"), getLongValue(map, "elapsed_ns"),
73-
getLongValue(map, "result_rows")),
74+
getLongValue(map, "result_rows"), this.queryId),
7475
null);
7576

7677
this.format = format != null ? format : connection.config.getFormat();

clickhouse-http-client/src/test/java/com/clickhouse/client/http/ClickHouseHttpClientTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,21 @@ public void testPost() throws ClickHouseException {
414414
}
415415
}
416416

417+
@Test(groups = {"integration"})
418+
public void testQueryId() throws ClickHouseException {
419+
ClickHouseNode server = getServer(ClickHouseProtocol.HTTP);
420+
String uuid = UUID.randomUUID().toString();
421+
422+
try (ClickHouseClient client = ClickHouseClient.builder().options(getClientOptions())
423+
.defaultCredentials(ClickHouseCredentials.fromUserAndPassword("foo", "bar")).build()) {
424+
try (ClickHouseResponse resp = newRequest(client, server).compressServerResponse(false)
425+
.format(ClickHouseFormat.RowBinaryWithNamesAndTypes)
426+
.query("select 1,2", uuid).executeAndWait()) {
427+
Assert.assertEquals(resp.getSummary().getQueryId(), uuid);
428+
}
429+
}
430+
}
431+
417432
@Test(groups = {"integration"})
418433
public void testProxyConnection() throws ClickHouseException, IOException {
419434
ToxiproxyContainer toxiproxy = null;

clickhouse-jdbc/src/main/java/com/clickhouse/jdbc/ClickHousePreparedStatement.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,17 @@ default void setClob(int parameterIndex, Clob x) throws SQLException {
109109
@Override
110110
default ResultSetMetaData getMetaData() throws SQLException {
111111
ResultSet currentResult = getResultSet();
112-
return currentResult != null ? currentResult.getMetaData() : null;
112+
if (currentResult != null) {
113+
return currentResult.getMetaData();
114+
} else if (getLargeUpdateCount() != -1L) {
115+
return null; // Update query
116+
}
117+
118+
return describeQueryResult();
119+
}
120+
121+
default ResultSetMetaData describeQueryResult() throws SQLException {
122+
return null;
113123
}
114124

115125
@Override

0 commit comments

Comments
 (0)