Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
079dfaa
restore public getColumnNames method
Oct 5, 2020
1897e2e
Translate comment and fix #462
zhicwu Jan 7, 2021
ec83d06
Prepare 0.2.6 release
zhicwu Jan 31, 2021
1db44b1
Merge pull request #553 from zhicwu/develop
zhicwu Jan 31, 2021
9268a23
Upgrade to lz4-java and improve performance of LZ4 stream
zhicwu Jan 31, 2021
1699863
Merge pull request #554 from zhicwu/lz4
zhicwu Jan 31, 2021
9559483
Set socket timeout in health check
zhicwu Feb 1, 2021
0b73e11
Set timeout for getting http connection from pool
zhicwu Feb 1, 2021
7485bfd
Merge branch 'ch_develop' into failed-to-respond
zhicwu Feb 1, 2021
3767957
give access to stats returned by server in X-ClickHouse-Summary
bgranvea Oct 5, 2020
52d3ce5
- added WAIT_END_OF_QUERY param
bgranvea Oct 5, 2020
2505101
updated ClickHouseProperties with new query params
bgranvea Oct 5, 2020
00e531b
parse X-ClickHouse-Summary only if it asked in query param (otherwise…
bgranvea Oct 5, 2020
85d1fcc
cleaner test of query param
bgranvea Oct 6, 2020
12319c6
make ClickHouseStatementImpl extend ConfigurableApi
bgranvea Oct 13, 2020
d514053
Add maxRetries setting and tests
zhicwu Feb 1, 2021
e44a78c
use TestContainers
bgranvea Feb 1, 2021
e3ec5a4
Skip NoHttpResponseException test
zhicwu Feb 1, 2021
af87f8b
Skip httpclient tests as they're not stable in CI
zhicwu Feb 1, 2021
cefd262
Merge pull request #557 from zhicwu/timeout
zhicwu Feb 1, 2021
e6d0037
Use static version instead of property-based revision
zhicwu Feb 1, 2021
38ae23b
Correct path
zhicwu Feb 1, 2021
e811a7e
Only replace the first version
zhicwu Feb 1, 2021
f933823
Merge pull request #558 from zhicwu/develop
zhicwu Feb 1, 2021
df180d9
Merge pull request #498 from infovista/result-summary
zhicwu Feb 2, 2021
2eaa6f6
ability to send compressed files/streams
den-crane Feb 3, 2021
1107226
fix test against 19.14
den-crane Feb 3, 2021
09ab375
Merge pull request #562 from den-crane/feature/send-compressed-stream
zhicwu Feb 4, 2021
bf88177
Use Basic auth for credentials instead of query params
enqueue Jan 24, 2021
8e68aa4
Merge pull request #548 from enqueue/basicauth
zhicwu Feb 6, 2021
9cf4c73
Add JavaCC based new parser
zhicwu Feb 7, 2021
1347cec
Enhance parser and add more test cases
zhicwu Feb 8, 2021
6f618bf
Fix javadoc errors
zhicwu Feb 8, 2021
f6a0d54
Merge pull request #499 from Okapist/getColumnNames
zhicwu Feb 10, 2021
b0eea78
Enhance the parser so that it can deal with test cases from ClickHous…
zhicwu Feb 12, 2021
41bccff
Only retry for idempotent operation
zhicwu Feb 12, 2021
d2359e8
Merge branch develop into failed-to-respond
zhicwu Feb 12, 2021
8216d2f
Correct description
zhicwu Feb 12, 2021
7106b19
Correct retry test case
zhicwu Feb 12, 2021
f90acb0
Disable unstable test cases
zhicwu Feb 12, 2021
41f3e34
Merge pull request #540 from zhicwu/failed-to-respond
zhicwu Feb 12, 2021
4c51d65
Merge branch 'ch_develop' into new-sql-parser
zhicwu Feb 12, 2021
91c0059
Enhance parser to recognize idempotent operations
zhicwu Feb 13, 2021
d6acab2
Merge pull request #563 from zhicwu/new-sql-parser
zhicwu Feb 13, 2021
6aa52da
Update changelog for 0.2.6
zhicwu Feb 15, 2021
6800fef
Merge pull request #567 from zhicwu/develop
zhicwu Feb 15, 2021
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
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
version:
description: "Release version"
required: true
default: "0.2.5-SNAPSHOT"
default: "0.2.6-SNAPSHOT"

jobs:
release:
Expand All @@ -20,11 +20,12 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- run: sed -i -e 's|^\( <version>\).*\(</version>\)$|\1${{ github.event.inputs.version }}\2|' pom.xml
- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1
with:
maven_profiles: release
maven_args: -Drevision=${{ github.event.inputs.version }} --batch-mode
maven_args: --batch-mode
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.SONATYPE_USER }}
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ out/
.antlr/
log/
target/

# Generated files
src/main/java/ru/yandex/clickhouse/jdbc/parser/*CharStream.java
src/main/java/ru/yandex/clickhouse/jdbc/parser/ClickHouseSqlParser*.java
src/main/java/ru/yandex/clickhouse/jdbc/parser/Token*.java
src/main/java/ru/yandex/clickhouse/jdbc/parser/ParseException.java

# Shell scripts
*.sh
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
0.2.6
* add new feature for sending compressed files/streams
* introduce an experimental SQL parser to fix parsing related issues - set connection setting use_new_parser to false to disable
* restore String[] getColumnNames() method for backward compatibility
* retry idempotent operation up to 3 times when server closed connection - set connection setting maxRetries to zero to disable
* return inserted rows(not accurate) when query parameter send_progress_in_http_headers is set to true
* set socket timeout in ClickHouseConnectionImpl.isValid()
* upgrade to lz4-java and improve performance of LZ4 stream
* use HTTP Basic Auth for credentials instead of query parameters
* use static version instead of property-based revision in pom.xml
0.2.5
* bump dependencies and include lz4 in shaded jar
* new API: ClickHouseRowBinaryStream.writeUInt64Array(UnsignedLong[])
* support column comments
* support explain queries
* fix keep-alive timeout issue by reusing validated connection
* fix ResultSet.findColumn(String) issue
* fix the issue of not being able to use NULL constant in PreparedStatement
* fix toLowerCase issue for Turkish
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It has support of a minimal subset of features to be usable.
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.2.5</version>
<version>0.2.6</version>
</dependency>
```

Expand All @@ -35,7 +35,7 @@ sth
.write() // Write API entrypoint
.table("default.my_table") // where to write data
.option("format_csv_delimiter", ";") // specific param
.data(new File("/path/to/file.csv"), ClickHouseFormat.CSV) // specify input
.data(new File("/path/to/file.csv.gz"), ClickHouseFormat.CSV, ClickHouseCompression.gzip) // specify input
.send();
```
#### Configurable send
Expand All @@ -46,6 +46,7 @@ sth
.write()
.sql("INSERT INTO default.my_table (a,b,c)")
.data(new MyCustomInputStream(), ClickHouseFormat.JSONEachRow)
.dataCompression(ClickHouseCompression.brotli)
.addDbParam(ClickHouseQueryParam.MAX_PARALLEL_REPLICAS, 2)
.send();
```
Expand Down
38 changes: 33 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>${revision}</version>
<version>0.2.6</version>
<packaging>jar</packaging>

<name>clickhouse-jdbc</name>
Expand Down Expand Up @@ -52,12 +52,11 @@
</developers>

<properties>
<revision>0.2.5</revision>
<slf4j.version>1.7.30</slf4j.version>
<project.current.year>2021</project.current.year>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<httpclient.version>4.5.13</httpclient.version>
<lz4.version>1.3.0</lz4.version>
<lz4.version>1.7.1</lz4.version>
<jackson-core.version>2.9.10</jackson-core.version>
<jackson-databind.version>2.9.10.8</jackson-databind.version>
<guava.version>29.0-jre</guava.version>
Expand All @@ -66,10 +65,12 @@
<testcontainers.version>1.15.1</testcontainers.version>
<testng.version>6.14.3</testng.version>
<mockito.version>1.10.19</mockito.version>
<wiremock.version>2.27.2</wiremock.version>
<helper-plugin.version>3.2.0</helper-plugin.version>
<deploy-plugin.version>3.0.0-M1</deploy-plugin.version>
<staging-plugin.version>1.6.8</staging-plugin.version>
<gpg-plugin.version>1.6</gpg-plugin.version>
<javacc-plugin.version>4.1.4</javacc-plugin.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<source-plugin.version>3.2.1</source-plugin.version>
<jar-plugin.version>3.2.0</jar-plugin.version>
Expand Down Expand Up @@ -98,8 +99,8 @@
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>net.jpountz.lz4</groupId>
<artifactId>lz4</artifactId>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
<version>${lz4.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -152,6 +153,12 @@
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<distributionManagement>
Expand Down Expand Up @@ -282,6 +289,27 @@
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>com.helger.maven</groupId>
<artifactId>ph-javacc-maven-plugin</artifactId>
<version>${javacc-plugin.version}</version>
<executions>
<execution>
<id>jjc</id>
<phase>generate-sources</phase>
<goals>
<goal>javacc</goal>
</goals>
<configuration>
<jdkVersion>${jdk.version}</jdkVersion>
<javadocFriendlyComments>true</javadocFriendlyComments>
<packageName>ru.yandex.clickhouse.jdbc.parser</packageName>
<sourceDirectory>src/main/javacc</sourceDirectory>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
48 changes: 42 additions & 6 deletions src/main/java/ru/yandex/clickhouse/ClickHouseConnectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ public ClickHouseStatement createStatement() throws SQLException {
}

public ClickHouseStatement createStatement(int resultSetType) throws SQLException {
return LogProxy.wrap(ClickHouseStatement.class, new ClickHouseStatementImpl(httpclient, this, properties, resultSetType));
return LogProxy.wrap(
ClickHouseStatement.class,
new ClickHouseStatementImpl(
httpclient,
this,
properties,
resultSetType));
}

@Deprecated
Expand All @@ -126,15 +132,37 @@ public TimeZone getTimeZone() {
}

private ClickHouseStatement createClickHouseStatement(CloseableHttpClient httpClient) throws SQLException {
return LogProxy.wrap(ClickHouseStatement.class, new ClickHouseStatementImpl(httpClient, this, properties, DEFAULT_RESULTSET_TYPE));
return LogProxy.wrap(
ClickHouseStatement.class,
new ClickHouseStatementImpl(
httpClient,
this,
properties,
DEFAULT_RESULTSET_TYPE));
}

public PreparedStatement createPreparedStatement(String sql, int resultSetType) throws SQLException {
return LogProxy.wrap(PreparedStatement.class, new ClickHousePreparedStatementImpl(httpclient, this, properties, sql, getTimeZone(), resultSetType));
return LogProxy.wrap(
PreparedStatement.class,
new ClickHousePreparedStatementImpl(
httpclient,
this,
properties,
sql,
getTimeZone(),
resultSetType));
}

public ClickHousePreparedStatement createClickHousePreparedStatement(String sql, int resultSetType) throws SQLException {
return LogProxy.wrap(ClickHousePreparedStatement.class, new ClickHousePreparedStatementImpl(httpclient, this, properties, sql, getTimeZone(), resultSetType));
return LogProxy.wrap(
ClickHousePreparedStatement.class,
new ClickHousePreparedStatementImpl(
httpclient,
this,
properties,
sql,
getTimeZone(),
resultSetType));
}


Expand Down Expand Up @@ -385,8 +413,10 @@ public boolean isValid(int timeout) throws SQLException {
closeableHttpClient = this.httpclient;
} else {
ClickHouseProperties properties = new ClickHouseProperties(this.properties);
properties.setConnectionTimeout((int) TimeUnit.SECONDS.toMillis(timeout));
int timeoutMs = (int) TimeUnit.SECONDS.toMillis(timeout);
properties.setConnectionTimeout(timeoutMs);
properties.setMaxExecutionTime(timeout);
properties.setSocketTimeout(timeoutMs);
closeableHttpClient = new ClickHouseHttpClientBuilder(properties).buildClient();
isAnotherHttpClient = true;
}
Expand All @@ -406,12 +436,13 @@ public boolean isValid(int timeout) throws SQLException {

return false;
} finally {
if (isAnotherHttpClient)
if (isAnotherHttpClient) {
try {
closeableHttpClient.close();
} catch (IOException e) {
log.warn("Can't close a http client", e);
}
}
}
}

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

@Override
public void setSchema(String schema) throws SQLException {
properties.setDatabase(schema);
}

@Override
public String getSchema() throws SQLException {
return properties.getDatabase();
}

@Override
public void abort(Executor executor) throws SQLException {
this.close();
}

@Override
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {

}

@Override
public int getNetworkTimeout() throws SQLException {
return 0;
}
Expand Down
Loading