Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3535d11
Fix custom properties lost issue and add more tests
zhicwu Jul 4, 2022
142944b
Remove hard-coded protocol
zhicwu Jul 4, 2022
e59bd46
Merge pull request #980 from zhicwu/develop
zhicwu Jul 4, 2022
844b2b8
Stop throwing exception when executing empty batch
zhicwu Jul 4, 2022
2f2f2ea
Merge pull request #981 from zhicwu/develop
zhicwu Jul 4, 2022
70612d8
Return null instead of default value for nullable types
zhicwu Jul 4, 2022
d0284d2
Merge pull request #982 from zhicwu/develop
zhicwu Jul 4, 2022
9f9ef67
More tests to cover socket timeout and error during query/insert
zhicwu Jul 6, 2022
57d8d76
Fixes number cast exception when Boolean[] is used in ClickHouseArray…
subkanthi Jul 6, 2022
82eb49a
Skip failed test case
zhicwu Jul 6, 2022
890f602
convert long[] to BigInteger[] - #984
zhicwu Jul 6, 2022
24035e6
Only run the test for http implementation
zhicwu Jul 8, 2022
702a638
add test to ensure BigInteger[] can be converted back to long[] as well
zhicwu Jul 8, 2022
b468f1d
Skip the tests for non-http implementation
zhicwu Jul 8, 2022
8cc6033
Convert byte[] to Boolean[] and more tests
zhicwu Jul 8, 2022
3a71503
Merge pull request #983 from zhicwu/develop
zhicwu Jul 8, 2022
1f633d6
implement getParameterMetadata method in PreparedStatement
zhicwu Jul 10, 2022
3129c3c
Merge pull request #988 from zhicwu/develop
zhicwu Jul 10, 2022
4be83e5
Merge pull request #985 from subkanthi/fix_clickhousearrayvalue_Boolean
zhicwu Jul 10, 2022
8d6ce58
Clean up pom files
zhicwu Jul 11, 2022
8b8415f
Fix build failure
zhicwu Jul 13, 2022
52de029
Fix incorrect error code when using HttpClient on 21.3
zhicwu Jul 13, 2022
9b21161
Merge pull request #992 from zhicwu/develop
zhicwu Jul 13, 2022
04b9c4b
Fix slowness in performance mode and failover not working when protoc…
zhicwu Jul 13, 2022
9326785
Fix format error when last argument is Throwable
zhicwu Jul 15, 2022
0780c7c
Correct node config overloading and failover from one protocol to ano…
zhicwu Jul 15, 2022
6a56549
Use named container in CI when using CLI client
zhicwu Jul 15, 2022
c010b4d
Skip the failed case for now
zhicwu Jul 15, 2022
db0bd80
Merge pull request #995 from zhicwu/develop
zhicwu Jul 15, 2022
81168a2
max_result_rows should never be applied to metadata queries
zhicwu Jul 15, 2022
9e58b36
Merge pull request #997 from zhicwu/develop
zhicwu Jul 15, 2022
9be9db2
Add use_no_proxy option to avoid using proxy
zhicwu Jul 15, 2022
823b32a
Merge branch 'develop' of github.com:zhicwu/clickhouse-jdbc into develop
zhicwu Jul 15, 2022
a95ea43
Add missing config
zhicwu Jul 15, 2022
4fd3358
Merge pull request #998 from zhicwu/develop
zhicwu Jul 15, 2022
aeb5878
Use unbounded queue for batch insert
zhicwu Jul 15, 2022
6a11320
Rename test and consider clearBatch
zhicwu Jul 15, 2022
b1b4cc1
Merge pull request #1000 from zhicwu/develop
zhicwu Jul 15, 2022
d1a97b1
support direct upload/download in http client
zhicwu Jul 18, 2022
7dcfae5
Merge pull request #1004 from zhicwu/develop
zhicwu Jul 18, 2022
4baa9c9
Experimental transaction support
zhicwu Jul 24, 2022
3c4b863
Fix compile error on JDK 8
zhicwu Jul 24, 2022
de97ada
Fix test failures on 22.7
zhicwu Jul 24, 2022
77f949e
Fix Roaring64NavigableMap reading mismatches
wzqiang1332 Jul 26, 2022
86fe010
improve implicit transaction support and error handling
zhicwu Jul 26, 2022
9633bf8
Improve error message as suggested in #1010
zhicwu Jul 26, 2022
d7a6f77
Roll back unnecessary changes
zhicwu Jul 26, 2022
33cf266
Enable repeat_on_session_lock to test CI
zhicwu Jul 26, 2022
1d68dcd
Bump ClickHouse version and test again
zhicwu Jul 26, 2022
b5d610f
Merge pull request #1008 from zhicwu/develop
zhicwu Jul 26, 2022
811f3fb
Merge pull request #1011 from wzqiang1332/develop
zhicwu Jul 26, 2022
439d345
Update doc for build and testing
zhicwu Jul 28, 2022
cdaf8f3
Merge pull request #1018 from zhicwu/develop
zhicwu Jul 28, 2022
537663b
Return read/written rows whenever possible
zhicwu Jul 28, 2022
5f6d8b7
Reduce object creation
zhicwu Jul 28, 2022
0e0a214
Merge pull request #1019 from zhicwu/develop
zhicwu Jul 28, 2022
d4a0b61
apply timezone to datetime default value
zhicwu Jul 28, 2022
a3a8995
Merge pull request #1020 from zhicwu/develop
zhicwu Jul 28, 2022
44b3579
Update latest version
zhicwu Jul 28, 2022
4f3bfb0
Deprecate method executeWithinTransaction(boolean)
zhicwu Jul 28, 2022
dea41df
Merge branch 'ClickHouse:develop' into develop
zhicwu Jul 28, 2022
27f8951
Merge pull request #1021 from zhicwu/develop
zhicwu Jul 28, 2022
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
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ jobs:
strategy:
matrix:
# most recent LTS releases as well as latest stable builds
clickhouse: ["21.3", "21.8", "latest"]
clickhouse: ["21.8", "22.3", "latest"]
# http2 here represents http protocol + JDK HttpClient(http_connection_provider=HTTP_CLIENT)
protocol: ["http", "http2", "grpc"]
exclude:
- clickhouse: "21.3"
protocol: grpc
- clickhouse: "21.8"
protocol: grpc
fail-fast: false
Expand Down
96 changes: 47 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ Note: in general, the new driver(v0.3.2) is a few times faster with less memory
| | UUID | :white_check_mark: | |
| High Availability | Load Balancing | :white_check_mark: | supported since 0.3.2-patch10 |
| | Failover | :white_check_mark: | supported since 0.3.2-patch10 |
| Transaction | Transaction | :white_check_mark: | supported since 0.3.2-patch11, use ClickHouse 22.7+ for native implicit transaction support |
| | Savepoint | :x: | |
| | XAConnection | :x: | |

## Examples

Expand All @@ -61,7 +64,7 @@ Note: in general, the new driver(v0.3.2) is a few times faster with less memory
<groupId>com.clickhouse</groupId>
<!-- or clickhouse-grpc-client if you prefer gRPC -->
<artifactId>clickhouse-http-client</artifactId>
<version>0.3.2-patch10</version>
<version>0.3.2-patch11</version>
</dependency>
```

Expand Down Expand Up @@ -97,7 +100,7 @@ try (ClickHouseClient client = ClickHouseClient.newInstance(ClickHouseProtocol.H
<!-- please stop using ru.yandex.clickhouse as it's been deprecated -->
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.2-patch10</version>
<version>0.3.2-patch11</version>
<!-- use uber jar with all dependencies included, change classifier to http for smaller jar -->
<classifier>all</classifier>
<exclusions>
Expand Down Expand Up @@ -129,64 +132,44 @@ try (Connection conn = dataSource.getConnection();

## Build with Maven

Use `mvn clean verify` to compile, test and generate shaded packages if you're using JDK 8. To create a multi-release jar file(see [JEP-238](https://openjdk.java.net/jeps/238)), please use JDK 11 or above and follow instructions below:

- make sure you have `~/.m2/toolchains.xml`, for example:

```xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-11-openjdk</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>17</version>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-17-openjdk</jdkHome>
</configuration>
</toolchain>
</toolchains>
```

- run `mvn -Drelease clean install` to build and install the artificat to local repository

Note: if you need to build modules separately, please start with `clickhouse-client`, followed by `clickhouse-http-client` and `clickhouse-grpc-client`, and then `clickhouse-jdbc` and `clickhouse-benchmark`.

## Benchmark

To benchmark JDBC drivers:
Use `mvn -DskipITs clean verify` to compile and generate packages if you're using JDK 8. To create a multi-release jar (see [JEP-238](https://openjdk.java.net/jeps/238)), please use JDK 11+ with `~/.m2/toolchains.xml` like below, and run `mvn -Drelease -DskipITs clean verify` instead.

```bash
cd clickhouse-benchmark
mvn -Drelease clean package
# single thread mode
java -DdbHost=localhost -jar target/benchmarks.jar -t 1 \
-p client=clickhouse-jdbc -p connection=reuse \
-p statement=prepared Query.selectInt8
```xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-11-openjdk</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>17</version>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-17-openjdk</jdkHome>
</configuration>
</toolchain>
</toolchains>
```

It's time consuming to run all benchmarks against all drivers using different parameters for comparison. If you just need some numbers to understand performance, please refer to table below and some more details like CPU and memory usage mentioned at [here](https://github.com/ClickHouse/clickhouse-jdbc/issues/768)(still have plenty of room to improve according to ranking at [here](https://github.com/go-faster/ch-bench)).

## Testing

By default, docker container will be created automatically during integration test. You can pass system property like `-DclickhouseVersion=21.8` to specify version of ClickHouse.
By default, [docker](https://docs.docker.com/engine/install/) is required to run integration test. Docker image(defaults to `clickhouse/clickhouse-server`) will be pulled from Internet, and containers will be created automatically by [testcontainers](https://www.testcontainers.org/) before testing. To test against specific version of ClickHouse, you can pass parameter like `-DclickhouseVersion=22.3` to Maven.

In the case you prefer to test against an existing server, please follow instructions below:
In the case you don't want to use docker and/or prefer to test against an existing server, please follow instructions below:

- make sure the server can be accessed using default account(user `default` and no password), which has both DDL and DML privileges
- add below two configuration files to the existing server and expose all ports for external access
- add below two configuration files to the existing server and expose all defaults ports for external access
- [ports.xml](../../blob/master/clickhouse-client/src/test/resources/containers/clickhouse-server/config.d/ports.xml) - enable all ports
- and [users.xml](../../blob/master/clickhouse-client/src/test/resources/containers/clickhouse-server/users.d/users.xml) - accounts used for integration test
Note: you may need to change root element from `clickhouse` to `yandex` when testing old version of ClickHouse.
- make sure ClickHouse binary(usually `/usr/bin/clickhouse`) is available in PATH, as it's required to test `clickhouse-cli-client`
- put `test.properties` under either `~/.clickhouse` or `src/test/resources` of your project, with content like below:
```properties
clickhouseServer=x.x.x.x
Expand All @@ -196,3 +179,18 @@ In the case you prefer to test against an existing server, please follow instruc
#clickhouseImage=clickhouse/clickhouse-server
#additionalPackages=
```

## Benchmark

To benchmark JDBC drivers:

```bash
cd clickhouse-benchmark
mvn -Drelease clean package
# single thread mode
java -DdbHost=localhost -jar target/benchmarks.jar -t 1 \
-p client=clickhouse-jdbc -p connection=reuse \
-p statement=prepared Query.selectInt8
```

It's time consuming to run all benchmarks against all drivers using different parameters for comparison. If you just need some numbers to understand performance, please refer to table below and some more details like CPU and memory usage mentioned at [here](https://github.com/ClickHouse/clickhouse-jdbc/issues/768)(still have plenty of room to improve according to ranking at [here](https://github.com/go-faster/ch-bench)).
3 changes: 1 addition & 2 deletions clickhouse-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
</parent>

<artifactId>clickhouse-benchmark</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
<name>ClickHouse Client Benchmarks</name>
<description>Benchmarks for ClickHouse clients</description>
<url>https://github.com/ClickHouse/clickhouse-jdbc/tree/master/clickhouse-benchmark</url>

Expand Down
12 changes: 6 additions & 6 deletions clickhouse-cli-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ This is a thin wrapper of ClickHouse native command-line client. It provides an
- native CLI client instead of pure Java implementation
- an example of implementing SPI defined in `clickhouse-client` module

Either [clickhouse-client](https://clickhouse.com/docs/en/interfaces/cli/) or [docker](https://docs.docker.com/get-docker/) must be installed prior to use. And it's important to understand that this module uses sub-process(in addition to threads) and file-based streaming, meaning 1) it's not as fast as native CLI client or pure Java implementation, although it's close in the case of dumping and loading data; and 2) it's not suitable for scenarios like dealing with many queries in short period of time.
Either [clickhouse](https://clickhouse.com/docs/en/interfaces/cli/) or [docker](https://docs.docker.com/get-docker/) must be installed prior to use. And it's important to understand that this module uses sub-process(in addition to threads) and file-based streaming, meaning 1) it's not as fast as native CLI client or pure Java implementation, although it's close in the case of dumping and loading data; and 2) it's not suitable for scenarios like dealing with many queries in short period of time.

## Limitations and Known Issues

- Only `max_result_rows` and `result_overflow_mode` two settings are currently supported
- Only `max_result_rows`, `result_overflow_mode` and `readonly` 3 settings are currently supported
- ClickHouseResponseSummary is always empty - see ClickHouse/ClickHouse#37241
- Session is not supported - see ClickHouse/ClickHouse#37308

Expand All @@ -21,17 +21,17 @@ Either [clickhouse-client](https://clickhouse.com/docs/en/interfaces/cli/) or [d
<!-- please stop using ru.yandex.clickhouse as it's been deprecated -->
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-cli-client</artifactId>
<version>0.3.2-patch10</version>
<version>0.3.2-patch11</version>
</dependency>
```

## Examples

```java
// make sure 'clickhouse-client' or 'docker' is in PATH before you start the program
// make sure 'clickhouse' or 'docker' is in PATH before you start the program
// alternatively, configure CLI path in either Java system property or environment variable, for examples:
// CHC_CLICKHOUSE_CLI_PATH=/path/to/clickhouse-client CHC_DOCKER_CLI_PATH=/path/to/docker java MyProgram
// java -Dchc_clickhouse_cli_path=/path/to/clickhouse-client -Dchc_docker_cli_path=/path/to/docker MyProgram
// CHC_CLICKHOUSE_CLI_PATH=/path/to/clickhouse CHC_DOCKER_CLI_PATH=/path/to/docker java MyProgram
// java -Dchc_clickhouse_cli_path=/path/to/clickhouse -Dchc_docker_cli_path=/path/to/docker MyProgram

// clickhouse-cli-client uses TCP protocol
ClickHouseProtocol preferredProtocol = ClickHouseProtocol.TCP;
Expand Down
65 changes: 41 additions & 24 deletions clickhouse-cli-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,21 @@
</parent>

<artifactId>clickhouse-cli-client</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
<name>ClickHouse Native Command-line Wrapper</name>
<description>Wrapper of ClickHouse native command-line client</description>
<url>https://github.com/ClickHouse/clickhouse-jdbc/tree/master/clickhouse-cli-client</url>

<properties>
<shade.base>${project.parent.groupId}.client.internal</shade.base>
</properties>

<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>clickhouse-client</artifactId>
<version>${revision}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
</dependency>

<!-- necessary for Java 9+ -->
Expand Down Expand Up @@ -65,6 +58,19 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<environmentVariables>
<CHC_TEST_CONTAINER_ID>clickhouse-cli-client</CHC_TEST_CONTAINER_ID>
</environmentVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand All @@ -77,13 +83,24 @@
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<createDependencyReducedPom>true</createDependencyReducedPom>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<shadedClassifierName>shaded</shadedClassifierName>
<relocations>
<relocation>
<pattern>net.jpountz</pattern>
<shadedPattern>${shade.base}.jpountz</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Automatic-Module-Name>com.clickhouse.client.cli</Automatic-Module-Name>
</manifestEntries>
</transformer>
</transformers>
<filters>
<filter>
Expand All @@ -104,17 +121,17 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<environmentVariables>
<CHC_TEST_CONTAINER_ID>clickhouse-cli-client</CHC_TEST_CONTAINER_ID>
</environmentVariables>
</configuration>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<executions>
<execution>
<id>flatten</id>
<phase>package</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Loading