Skip to content

Commit d2359e8

Browse files
committed
Merge branch develop into failed-to-respond
2 parents 41bccff + 8e68aa4 commit d2359e8

25 files changed

+1173
-175
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ jobs:
2020
uses: actions/setup-java@v1
2121
with:
2222
java-version: 1.8
23+
- run: sed -i -e 's|^\( <version>\).*\(</version>\)$|\1${{ github.event.inputs.version }}\2|' pom.xml
2324
- name: Release Maven package
2425
uses: samuelmeuli/action-maven-publish@v1
2526
with:
2627
maven_profiles: release
27-
maven_args: -Drevision=${{ github.event.inputs.version }} --batch-mode
28+
maven_args: --batch-mode
2829
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
2930
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
3031
nexus_username: ${{ secrets.SONATYPE_USER }}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ sth
3535
.write() // Write API entrypoint
3636
.table("default.my_table") // where to write data
3737
.option("format_csv_delimiter", ";") // specific param
38-
.data(new File("/path/to/file.csv"), ClickHouseFormat.CSV) // specify input
38+
.data(new File("/path/to/file.csv.gz"), ClickHouseFormat.CSV, ClickHouseCompression.gzip) // specify input
3939
.send();
4040
```
4141
#### Configurable send
@@ -46,6 +46,7 @@ sth
4646
.write()
4747
.sql("INSERT INTO default.my_table (a,b,c)")
4848
.data(new MyCustomInputStream(), ClickHouseFormat.JSONEachRow)
49+
.dataCompression(ClickHouseCompression.brotli)
4950
.addDbParam(ClickHouseQueryParam.MAX_PARALLEL_REPLICAS, 2)
5051
.send();
5152
```

pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>ru.yandex.clickhouse</groupId>
66
<artifactId>clickhouse-jdbc</artifactId>
7-
<version>${revision}</version>
7+
<version>0.2.6</version>
88
<packaging>jar</packaging>
99

1010
<name>clickhouse-jdbc</name>
@@ -52,7 +52,6 @@
5252
</developers>
5353

5454
<properties>
55-
<revision>0.2.6</revision>
5655
<slf4j.version>1.7.30</slf4j.version>
5756
<project.current.year>2021</project.current.year>
5857
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -155,7 +154,7 @@
155154
</dependency>
156155
<dependency>
157156
<groupId>com.github.tomakehurst</groupId>
158-
<artifactId>wiremock</artifactId>
157+
<artifactId>wiremock-jre8</artifactId>
159158
<version>${wiremock.version}</version>
160159
<scope>test</scope>
161160
</dependency>

src/main/java/ru/yandex/clickhouse/ClickHouseConnectionImpl.java

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ public ClickHouseStatement createStatement() throws SQLException {
111111
}
112112

113113
public ClickHouseStatement createStatement(int resultSetType) throws SQLException {
114-
return LogProxy.wrap(ClickHouseStatement.class, new ClickHouseStatementImpl(httpclient, this, properties, resultSetType));
114+
return LogProxy.wrap(
115+
ClickHouseStatement.class,
116+
new ClickHouseStatementImpl(
117+
httpclient,
118+
this,
119+
properties,
120+
resultSetType));
115121
}
116122

117123
@Deprecated
@@ -126,15 +132,37 @@ public TimeZone getTimeZone() {
126132
}
127133

128134
private ClickHouseStatement createClickHouseStatement(CloseableHttpClient httpClient) throws SQLException {
129-
return LogProxy.wrap(ClickHouseStatement.class, new ClickHouseStatementImpl(httpClient, this, properties, DEFAULT_RESULTSET_TYPE));
135+
return LogProxy.wrap(
136+
ClickHouseStatement.class,
137+
new ClickHouseStatementImpl(
138+
httpClient,
139+
this,
140+
properties,
141+
DEFAULT_RESULTSET_TYPE));
130142
}
131143

132144
public PreparedStatement createPreparedStatement(String sql, int resultSetType) throws SQLException {
133-
return LogProxy.wrap(PreparedStatement.class, new ClickHousePreparedStatementImpl(httpclient, this, properties, sql, getTimeZone(), resultSetType));
145+
return LogProxy.wrap(
146+
PreparedStatement.class,
147+
new ClickHousePreparedStatementImpl(
148+
httpclient,
149+
this,
150+
properties,
151+
sql,
152+
getTimeZone(),
153+
resultSetType));
134154
}
135155

136156
public ClickHousePreparedStatement createClickHousePreparedStatement(String sql, int resultSetType) throws SQLException {
137-
return LogProxy.wrap(ClickHousePreparedStatement.class, new ClickHousePreparedStatementImpl(httpclient, this, properties, sql, getTimeZone(), resultSetType));
157+
return LogProxy.wrap(
158+
ClickHousePreparedStatement.class,
159+
new ClickHousePreparedStatementImpl(
160+
httpclient,
161+
this,
162+
properties,
163+
sql,
164+
getTimeZone(),
165+
resultSetType));
138166
}
139167

140168

@@ -385,8 +413,10 @@ public boolean isValid(int timeout) throws SQLException {
385413
closeableHttpClient = this.httpclient;
386414
} else {
387415
ClickHouseProperties properties = new ClickHouseProperties(this.properties);
388-
properties.setConnectionTimeout((int) TimeUnit.SECONDS.toMillis(timeout));
416+
int timeoutMs = (int) TimeUnit.SECONDS.toMillis(timeout);
417+
properties.setConnectionTimeout(timeoutMs);
389418
properties.setMaxExecutionTime(timeout);
419+
properties.setSocketTimeout(timeoutMs);
390420
closeableHttpClient = new ClickHouseHttpClientBuilder(properties).buildClient();
391421
isAnotherHttpClient = true;
392422
}
@@ -406,12 +436,13 @@ public boolean isValid(int timeout) throws SQLException {
406436

407437
return false;
408438
} finally {
409-
if (isAnotherHttpClient)
439+
if (isAnotherHttpClient) {
410440
try {
411441
closeableHttpClient.close();
412442
} catch (IOException e) {
413443
log.warn("Can't close a http client", e);
414444
}
445+
}
415446
}
416447
}
417448

@@ -460,22 +491,27 @@ public boolean isWrapperFor(Class<?> iface) throws SQLException {
460491
return iface.isAssignableFrom(getClass());
461492
}
462493

494+
@Override
463495
public void setSchema(String schema) throws SQLException {
464496
properties.setDatabase(schema);
465497
}
466498

499+
@Override
467500
public String getSchema() throws SQLException {
468501
return properties.getDatabase();
469502
}
470503

504+
@Override
471505
public void abort(Executor executor) throws SQLException {
472506
this.close();
473507
}
474508

509+
@Override
475510
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
476511

477512
}
478513

514+
@Override
479515
public int getNetworkTimeout() throws SQLException {
480516
return 0;
481517
}

src/main/java/ru/yandex/clickhouse/ClickHousePreparedStatementImpl.java

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
11
package ru.yandex.clickhouse;
22

3-
import org.apache.http.entity.AbstractHttpEntity;
4-
import org.apache.http.impl.client.CloseableHttpClient;
5-
import ru.yandex.clickhouse.response.ClickHouseResponse;
6-
import ru.yandex.clickhouse.settings.ClickHouseProperties;
7-
import ru.yandex.clickhouse.settings.ClickHouseQueryParam;
8-
import ru.yandex.clickhouse.util.ClickHouseArrayUtil;
9-
import ru.yandex.clickhouse.util.ClickHouseValueFormatter;
10-
import ru.yandex.clickhouse.util.guava.StreamUtils;
11-
123
import java.io.IOException;
134
import java.io.InputStream;
145
import java.io.OutputStream;
156
import java.io.Reader;
167
import java.math.BigDecimal;
178
import java.net.URL;
9+
import java.sql.Array;
10+
import java.sql.Blob;
11+
import java.sql.Clob;
1812
import java.sql.Date;
19-
import java.sql.*;
20-
import java.util.*;
13+
import java.sql.NClob;
14+
import java.sql.ParameterMetaData;
15+
import java.sql.Ref;
16+
import java.sql.ResultSet;
17+
import java.sql.ResultSetMetaData;
18+
import java.sql.RowId;
19+
import java.sql.SQLException;
20+
import java.sql.SQLFeatureNotSupportedException;
21+
import java.sql.SQLSyntaxErrorException;
22+
import java.sql.SQLXML;
23+
import java.sql.Time;
24+
import java.sql.Timestamp;
25+
import java.util.ArrayList;
26+
import java.util.Arrays;
27+
import java.util.Calendar;
28+
import java.util.Collection;
29+
import java.util.Collections;
30+
import java.util.List;
31+
import java.util.Map;
32+
import java.util.TimeZone;
2133
import java.util.regex.Matcher;
2234
import java.util.regex.Pattern;
2335

36+
import org.apache.http.entity.AbstractHttpEntity;
37+
import org.apache.http.impl.client.CloseableHttpClient;
38+
39+
import ru.yandex.clickhouse.response.ClickHouseResponse;
40+
import ru.yandex.clickhouse.settings.ClickHouseProperties;
41+
import ru.yandex.clickhouse.settings.ClickHouseQueryParam;
42+
import ru.yandex.clickhouse.util.ClickHouseArrayUtil;
43+
import ru.yandex.clickhouse.util.ClickHouseValueFormatter;
44+
import ru.yandex.clickhouse.util.guava.StreamUtils;
45+
2446

2547
public class ClickHousePreparedStatementImpl extends ClickHouseStatementImpl implements ClickHousePreparedStatement {
2648

@@ -36,11 +58,11 @@ public class ClickHousePreparedStatementImpl extends ClickHouseStatementImpl imp
3658
private final ClickHousePreparedStatementParameter[] binds;
3759
private final List<List<String>> parameterList;
3860
private final boolean insertBatchMode;
39-
private List<byte[]> batchRows = new ArrayList<byte[]>();
61+
private List<byte[]> batchRows = new ArrayList<>();
4062

41-
public ClickHousePreparedStatementImpl(CloseableHttpClient client, ClickHouseConnection connection,
42-
ClickHouseProperties properties, String sql, TimeZone serverTimeZone,
43-
int resultSetType) throws SQLException
63+
public ClickHousePreparedStatementImpl(CloseableHttpClient client,
64+
ClickHouseConnection connection, ClickHouseProperties properties, String sql,
65+
TimeZone serverTimeZone, int resultSetType) throws SQLException
4466
{
4567
super(client, connection, properties, resultSetType);
4668
this.sql = sql;
@@ -295,7 +317,7 @@ public void addBatch() throws SQLException {
295317

296318
private List<byte[]> buildBatch() throws SQLException {
297319
checkBinded();
298-
List<byte[]> newBatches = new ArrayList<byte[]>(parameterList.size());
320+
List<byte[]> newBatches = new ArrayList<>(parameterList.size());
299321
StringBuilder sb = new StringBuilder();
300322
for (int i = 0, p = 0; i < parameterList.size(); i++) {
301323
List<String> pList = parameterList.get(i);
@@ -338,7 +360,7 @@ public int[] executeBatch(Map<ClickHouseQueryParam, String> additionalDBParams)
338360
sendStream(entity, insertSql, additionalDBParams);
339361
int[] result = new int[batchRows.size()];
340362
Arrays.fill(result, 1);
341-
batchRows = new ArrayList<byte[]>();
363+
batchRows = new ArrayList<>();
342364
return result;
343365
}
344366

src/main/java/ru/yandex/clickhouse/ClickHouseStatement.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ru.yandex.clickhouse;
22

33
import ru.yandex.clickhouse.response.ClickHouseResponse;
4+
import ru.yandex.clickhouse.response.ClickHouseResponseSummary;
45
import ru.yandex.clickhouse.settings.ClickHouseQueryParam;
56
import ru.yandex.clickhouse.util.ClickHouseRowBinaryInputStream;
67
import ru.yandex.clickhouse.util.ClickHouseStreamCallback;
@@ -105,4 +106,6 @@ ResultSet executeQuery(String sql,
105106
* Returns extended write-API
106107
*/
107108
Writer write();
109+
110+
ClickHouseResponseSummary getResponseSummary();
108111
}

0 commit comments

Comments
 (0)