Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f67ae74
row_binary_fixed_string support
den-crane Jun 11, 2021
265db6d
row_binary_fixed_string support
den-crane Jun 12, 2021
b8ca0e9
more tests
den-crane Jun 12, 2021
3c4862f
fix tests
den-crane Jun 12, 2021
9bf36f1
fix tests
den-crane Jun 12, 2021
d280e43
Merge pull request #673 from den-crane/feature/row_binary_fixed_string
zhicwu Jun 12, 2021
2f9145b
Added explicit setting of the request encoding when using external data
Jun 25, 2021
989f9f7
Merge pull request #677 from MikhailMel/fix_query_charset_with_ed
zhicwu Jun 25, 2021
41779b0
Fix NPE caued by initConnection method
zhicwu Jul 11, 2021
3dea256
Skip BigInt support test for 21.7 and above
zhicwu Jul 11, 2021
0f20121
Merge pull request #685 from zhicwu/fix-npe
zhicwu Jul 11, 2021
e97d8db
Column comment is only avaiable since 18.16
zhicwu Jul 11, 2021
5d952a9
Merge pull request #686 from zhicwu/column-comment
zhicwu Jul 11, 2021
4184d6b
Enable ipv6 support in BalancedClickHouseDataSource
zhicwu Jul 11, 2021
fccde91
Merge pull request #687 from zhicwu/ipv6
zhicwu Jul 11, 2021
b8b8aa8
Remove duplicated class
zhicwu Jul 11, 2021
5770ae4
Add two query parameters as requested in #679
zhicwu Jul 11, 2021
8d00ec6
Backport full list of ClickHouseFormat, which also fixed incorrect fo…
zhicwu Jul 11, 2021
d3c7a5e
Merge pull request #688 from zhicwu/update-enums
zhicwu Jul 11, 2021
e6e92bf
Add unit test for query with multiple external tables
zhicwu Jul 11, 2021
2fbbb31
Merge pull request #689 from zhicwu/add-test
zhicwu Jul 11, 2021
660f013
Prepare 0.3.2
zhicwu Jul 11, 2021
e55b88a
Update benchmarks
zhicwu Jul 11, 2021
d3db68c
Merge pull request #690 from zhicwu/update-benchmark
zhicwu Jul 11, 2021
25fe149
Change log level to debug
buremba Jul 30, 2021
a5666f7
Merge pull request #699 from metriql/master
zhicwu Aug 15, 2021
8afe49a
remove redundant data transfer timeout property
Aug 16, 2021
6729d5a
Merge pull request #703 from rubtsovnyu/develop
zhicwu Aug 16, 2021
58ef06b
support Clickhouse 21.8 in tests
den-crane Aug 18, 2021
b85837f
Merge pull request #706 from den-crane/feature/21.8
zhicwu Aug 19, 2021
005038d
Bump version to 0.3.2 and add repackaged 3rd party libs
zhicwu Oct 5, 2021
ec0388c
Merge pull request #731 from zhicwu/3rd-party-libs
zhicwu Oct 5, 2021
adc6525
Update build config for repackaging 3rd party libs
zhicwu Oct 6, 2021
34ada5f
Merge pull request #732 from zhicwu/update-build-config
zhicwu Oct 6, 2021
c602020
Rename workflow to avoid naming conflict
zhicwu Oct 6, 2021
9be20e2
Merge pull request #733 from zhicwu/rename-workflow
zhicwu Oct 6, 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
10 changes: 5 additions & 5 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ on:
driver:
description: "Driver version"
required: true
default: "0.3.1-SNAPSHOT"
default: "0.3.2-SNAPSHOT"
options:
description: "Benchmark options"
required: true
Expand Down Expand Up @@ -55,14 +55,14 @@ jobs:
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ steps.version.outputs.value }}|g' \
-e 's|^\( <version>\).*\(</version>\)$|\1${{ steps.version.outputs.value }}\2|' \
-e 's|${parent.groupId}|tech.clickhouse|g' -e 's|.*argLine.*timezone=.*||g' '{}' \;
-e 's|${parent.groupId}|com.clickhouse|g' '{}' \;
find . -type f -name "log4j.*" -exec rm -fv '{}' \;
- name: Build project
run: |
mvn --batch-mode --update-snapshots -q -DskipTests install
cd clickhouse-benchmark
mvn --batch-mode --update-snapshots install
java -DclickhouseVersion="21.3" -jar target/benchmarks.jar -rf text -p client=clickhouse-jdbc Basic
java -DclickhouseVersion="21.8" -jar target/benchmarks.jar -rf text -p client=clickhouse-jdbc Basic
echo "BENCHMARK_REPORT<<EOF" >> $GITHUB_ENV
cat jmh-result.text >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ github.event.inputs.version }}|g' \
-e 's|^\( <version>\).*\(</version>\)$|\1${{ github.event.inputs.driver }}\2|' \
-e 's|${parent.groupId}|tech.clickhouse|g' -e 's|.*argLine.*timezone=.*||g' '{}' \;
-e 's|${parent.groupId}|com.clickhouse|g' '{}' \;
find . -type f -name "log4j.*" -exec rm -fv '{}' \;
continue-on-error: true
- name: Install driver as needed
Expand All @@ -110,7 +110,7 @@ jobs:
run: |
mvn --batch-mode --update-snapshots -DskipTests -pl clickhouse-benchmark -am package
cd clickhouse-benchmark
java -DclickhouseVersion="21.3" -jar target/benchmarks.jar -rf json ${{ github.event.inputs.options }} > output.txt
java -DclickhouseVersion="21.8" -jar target/benchmarks.jar -rf json ${{ github.event.inputs.options }} > output.txt
echo "BENCHMARK_REPORT<<EOF" >> $GITHUB_ENV
tail -n +$(grep -n '^REMEMBER:' output.txt | tail -1 | awk -F: '{print $1+6}') output.txt | head -n -2 | grep -v ':·' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11, 15]
java: [8, 11, 17]
# most recent LTS releases as well as latest stable builds
clickhouse: ["20.8", "21.3", "latest"]
clickhouse: ["21.3", "21.8", "latest"]
fail-fast: false
name: Build using JDK ${{ matrix.java }} against ClickHouse ${{ matrix.clickhouse }}
steps:
Expand All @@ -59,4 +59,4 @@ jobs:
${{ runner.os }}-build-
- name: Build with Maven
run: |
mvn --batch-mode --update-snapshots -DclickhouseVersion=${{ matrix.clickhouse }} verify
mvn --batch-mode --update-snapshots -Drelease -DclickhouseVersion=${{ matrix.clickhouse }} verify
4 changes: 2 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.3.1-SNAPSHOT"
default: "0.3.2-SNAPSHOT"

jobs:
release:
Expand All @@ -24,7 +24,7 @@ jobs:
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ github.event.inputs.version }}|g' \
-e 's|^\( <version>\).*\(</version>\)$|\1${{ github.event.inputs.version }}\2|' \
-e 's|${parent.groupId}|tech.clickhouse|g' -e 's|.*argLine.*timezone=.*||g' '{}' \;
-e 's|${parent.groupId}|com.clickhouse|g' '{}' \;
find . -type f -name "log4j.*" -exec rm -fv '{}' \;
- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/third_party_libs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ThirdPartyLibs

on:
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
default: "1.0.0"

jobs:
release:
name: "Build and Publish Repackaged 3rd Party Libraries"
runs-on: "ubuntu-latest"

steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Install Java and Maven
uses: actions/setup-java@v1
with:
java-version: 9
- name: Update pom files and reduce logs
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ github.event.inputs.version }}|g' \
-e 's|^\( <version>\).*\(</version>\)$|\1${{ github.event.inputs.version }}\2|' \
-e 's|${parent.groupId}|com.clickhouse|g' '{}' \;
find . -type f -name "log4j.*" -exec rm -fv '{}' \;
- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1
with:
directory: third-party-libraries
maven_profiles: release
maven_args: -q --batch-mode
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.SONATYPE_USER }}
nexus_password: ${{ secrets.SONATYPE_PASSWD }}
3 changes: 1 addition & 2 deletions .github/workflows/timezone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ jobs:
${{ runner.os }}-build-
- name: Test using Maven
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|.*argLine.*timezone=.*||g' '{}' \;
mvn --batch-mode --update-snapshots \
-DclickhouseTimezone=${{ matrix.serverTz }} \
-DclickhouseVersion=21.3 \
-DclickhouseVersion=21.8 \
-Duser.timezone=${{ matrix.clientTz }} verify
2 changes: 0 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ jobs:
- name: Verify with Maven
if: steps.check.outputs.triggered == 'true'
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|.*argLine.*timezone=.*||g' '{}' \;
mvn --batch-mode --update-snapshots \
-DclickhouseVersion=${{ fromJSON(steps.commented.outputs.result).clickhouse }} \
-DclickhouseTimezone=Asia/Chongqing \
Expand Down Expand Up @@ -129,7 +128,6 @@ jobs:
continue-on-error: true
- name: Verify with Maven
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|.*argLine.*timezone=.*||g' '{}' \;
mvn --batch-mode --update-snapshots \
-DclickhouseVersion=${{ github.event.inputs.clickhouse }} \
-DclickhouseTimezone=${{ github.event.inputs.chTz }} \
Expand Down
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.class
# MacOS
.DS_Store

# Package Files #
# Java Files
*.class
*.jar
*.war
*.ear
Expand Down Expand Up @@ -30,13 +32,19 @@ target/

# Generated files
.flattened-pom.xml
dependency-reduced-pom.xml
**/parser/*CharStream.java
**/parser/ClickHouseSqlParser.java
**/parser/ClickHouseSqlParserConstants.java
**/parser/ClickHouseSqlParserTokenManager.java
**/parser/Token*.java
**/parser/ParseException.java
java.prof
jmh-result.*
profile.html

# Shell scripts
*.sh

# test configuration
**/test/resources/test.properties
14 changes: 14 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.3.1-patch
* fix incorrect database used in DDL
* fix batch insert issue when no VALUES used in SQL statement
* fix issue of handling negative decimal128/256 values

0.3.1
* BREAKING CHANGE - move query from url to request body
* BREAKING CHANGE - always parse SQL(use extended API to skip that)
Expand All @@ -10,6 +15,7 @@
* fix parser issue when DESC statement contains alias
* support batch processing with arbitrary query - update and delete are not recommended so there'll be warnings
* support multi-statement sql - session will be used automatically and only the last result will be returned

0.3.0
* BREAKING CHANGE - dropped JDK 7 support
* BREAKING CHANGE - removed Guava dependency(and so is UnsignedLong)
Expand All @@ -23,6 +29,7 @@
* fix error when using ClickHouseCompression.none against 19.16
* fix NegativeArraySizeException when dealing with large array
* fix datetime/date display issue caused by timezone differences(between client and column/server)

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
Expand All @@ -33,6 +40,7 @@
* 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[])
Expand All @@ -42,20 +50,26 @@
* fix ResultSet.findColumn(String) issue
* fix the issue of not being able to use NULL constant in PreparedStatement
* fix toLowerCase issue for Turkish

0.2.4
* fix FORMAT clause append for queries, ending with comment

0.2.3
* added support for Decimals in RowBinary protocol

0.2.2
* close certificate keystore
* fix for Boolean data type

0.2.1
* implement some ResultSet metadata methods
* added support for "any_join_distinct_right_table_keys" setting
* nested array support

0.2
* new API for writing streams of data
* deprecation of send* methods in ClickHouseStatement interface

0.1.55
NOTE: behavior for byte[] parameters changed. See https://github.com/yandex/clickhouse-jdbc/pull/352
* support for sending stream of CSV data
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ ClickHouse JDBC driver
This is a basic and restricted implementation of jdbc driver for ClickHouse.
It has support of a minimal subset of features to be usable.


### Usage
```xml
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.1</version>
<version>0.3.2</version>
</dependency>
```

Expand Down Expand Up @@ -46,6 +47,7 @@ try (ClickHouseConnection conn = dataSource.getConnection();

Additionally, if you have a few instances, you can use `BalancedClickhouseDataSource`.


### Extended API
In order to provide non-JDBC complaint data manipulation functionality, proprietary API exists.
Entry point for API is `ClickHouseStatement#write()` method.
Expand All @@ -61,6 +63,7 @@ sth
.data(new File("/path/to/file.csv.gz"), ClickHouseFormat.CSV, ClickHouseCompression.gzip) // specify input
.send();
```

#### Configurable send
```java
import ru.yandex.clickhouse.ClickHouseStatement;
Expand All @@ -73,6 +76,7 @@ sth
.addDbParam(ClickHouseQueryParam.MAX_PARALLEL_REPLICAS, 2)
.send();
```

#### Send data in binary formatted with custom user callback
```java
import ru.yandex.clickhouse.ClickHouseStatement;
Expand All @@ -88,6 +92,12 @@ sth.write().send("INSERT INTO test.writer", new ClickHouseStreamCallback() {
},
ClickHouseFormat.RowBinary); // RowBinary or Native are supported
```


### Supported Server Versions
All [active releases](../ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease) are supported. You can still use the driver for older versions like 18.14 or 19.16 but please keep in mind that they're no longer supported.


### Compiling with maven
The driver is built with maven.
`mvn package -DskipTests=true`
Expand All @@ -96,5 +106,6 @@ To build a jar with dependencies use

`mvn package assembly:single -DskipTests=true`


### Build requirements
In order to build the jdbc client one need to have jdk 1.7 or higher.
In order to build the jdbc client one need to have jdk 1.8 or higher.
21 changes: 16 additions & 5 deletions clickhouse-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

<properties>
<clickhouse4j-driver.version>1.4.4</clickhouse4j-driver.version>
<mariadb-driver.version>2.7.2</mariadb-driver.version>
<mysql-driver.version>8.0.23</mysql-driver.version>
<native-driver.version>2.5.4</native-driver.version>
<testcontainers.version>1.15.2</testcontainers.version>
<mariadb-driver.version>2.7.3</mariadb-driver.version>
<mysql-driver.version>8.0.25</mysql-driver.version>
<native-driver.version>2.5.6</native-driver.version>
<postgresql-driver.version>42.2.22</postgresql-driver.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.27</jmh.version>
<jmh.version>1.32</jmh.version>
<shade.name>benchmarks</shade.name>
</properties>

Expand Down Expand Up @@ -97,6 +97,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql-driver.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Collections;
import java.util.Random;
import org.openjdk.jmh.annotations.Benchmark;

public class Basic extends JdbcBenchmark {
@Benchmark
public int selectOneRandomNumber(ClientState state) throws Throwable {
final int num = new Random().nextInt(1000);
public int insertOneRandomNumber(ClientState state) throws Throwable {
final int num = state.getRandomSample();

try (Statement stmt = executeQuery(state, "select ? as n", num)) {
ResultSet rs = stmt.getResultSet();
return executeInsert(state, "insert into test_insert(i) values(?)",
Collections.enumeration(Collections.singletonList(new Object[] { num })));
}

rs.next();
@Benchmark
public int selectOneRandomNumber(ClientState state) throws Throwable {
final int num = state.getRandomSample();

if (num != rs.getInt(1)) {
try (Statement stmt = executeQuery(state, "select ? as n", num); ResultSet rs = stmt.getResultSet();) {
if (!rs.next() || num != rs.getInt(1)) {
throw new IllegalStateException();
}

return num;
}
}

@Benchmark
public int insertOneRandomNumber(ClientState state) throws Throwable {
final int num = new Random().nextInt(1000);

return executeInsert(state, "insert into test_insert(i) values(?)",
Collections.enumeration(Collections.singletonList(new Object[] { num })));
}
}
Loading