Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
543d046
Add notice
aiyanbo Mar 30, 2021
59a8544
Merge pull request #609 from aiyanbo/master
zhicwu Mar 30, 2021
73ea242
Fix issue #614 and add missing test cases
zhicwu Apr 10, 2021
3eb1a51
Merge pull request #616 from zhicwu/parse-desc-alias(discard build fa…
zhicwu Apr 10, 2021
552b1d7
Fix error when use_new_parser is set to false
zhicwu Apr 10, 2021
b83e74c
Remove useless code
zhicwu Apr 10, 2021
d508f0a
Merge pull request #618 from zhicwu/disable-new-parser
zhicwu Apr 10, 2021
7dd05b7
added shared cookie store
Cheppali-Reddy Apr 15, 2021
f09ea11
scope cookie store to db
Cheppali-Reddy Apr 15, 2021
c545cfc
fix test cases
Cheppali-Reddy Apr 15, 2021
b3b6908
Disable DEBUG and INFO logs during testing
zhicwu Apr 19, 2021
6aa7fca
Simplify warning when failed to parse SQL
zhicwu Apr 19, 2021
55f1398
Use latest LTS to run timezone test
zhicwu Apr 19, 2021
39fe3ed
Fix #603 - make RoaringBitmap dependency optional, and remove jitpack…
zhicwu Apr 19, 2021
5cc67aa
Fix build break in 21.3
zhicwu Apr 19, 2021
b3b504e
Merge pull request #629 from zhicwu/update-pom
zhicwu Apr 19, 2021
46c8f47
Merge pull request #626 from Cheppali-Reddy/shared_cookie_store
zhicwu Apr 19, 2021
b1e7254
Remove obsolete code, and enable multi-statement support
zhicwu Apr 20, 2021
cb613ba
Merge pull request #632 from zhicwu/clean-up
zhicwu Apr 20, 2021
a46a368
Add more query parameters
zhicwu Apr 20, 2021
f2a2b6c
Fix build break found on 20.8
zhicwu Apr 20, 2021
8a3f25c
Disable bigint/map tests when they're not supported
zhicwu Apr 20, 2021
0720d97
Merge pull request #633 from zhicwu/more-query-options
zhicwu Apr 20, 2021
f106d76
Enable batch execution in Statement
zhicwu Apr 20, 2021
57bdef3
Benchmark against LTS version
zhicwu Apr 21, 2021
2db368e
Mark known issue for future enhancement
zhicwu Apr 21, 2021
f7b1bfe
Support arbitrary SQL in prepared statement
zhicwu Apr 21, 2021
af73772
Merge pull request #635 from zhicwu/batch-process
zhicwu Apr 21, 2021
76a5d3d
Move query to request body
zhicwu Apr 21, 2021
5900247
Merge pull request #636 from zhicwu/large-request
zhicwu Apr 21, 2021
589f086
Move query to request body along with external data
zhicwu Apr 21, 2021
994b899
Merge pull request #637 from zhicwu/long-query-with-external-data
zhicwu Apr 21, 2021
88e8aa4
Dedup code
zhicwu Apr 22, 2021
f528752
Reformat code
zhicwu Apr 22, 2021
f273e8f
Add RowBinaryWithNamesAndTypes
zhicwu Apr 22, 2021
b89e023
Merge pull request #638 from zhicwu/binary-format
zhicwu Apr 22, 2021
aa67a79
Add CustomSeparated for #474 and #606
zhicwu Apr 27, 2021
500aa98
Add example for use of ClickHouseProperties and ClickHouseQueryParam(…
zhicwu Apr 27, 2021
4fade07
Bump dependency - merge PR #640
zhicwu Apr 27, 2021
aa2dfc3
Prepare 0.3.1 release
zhicwu Apr 27, 2021
b097be5
Merge pull request #643 from zhicwu/prepare-release
zhicwu Apr 27, 2021
46ec9cc
Disable testMaps for 21.4
zhicwu Apr 27, 2021
023b174
Merge pull request #644 from zhicwu/fix-build-break
zhicwu Apr 27, 2021
9603356
Add missing properties
zhicwu Apr 27, 2021
9b72c8a
Merge pull request #645 from zhicwu/update-poms
zhicwu Apr 27, 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
6 changes: 3 additions & 3 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.0-SNAPSHOT"
default: "0.3.1-SNAPSHOT"
options:
description: "Benchmark options"
required: true
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
mvn --batch-mode --update-snapshots -q -DskipTests install
cd clickhouse-benchmark
mvn --batch-mode --update-snapshots install
java -jar target/benchmarks.jar -rf text -p client=clickhouse-jdbc Basic
java -DclickhouseVersion="21.3" -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 @@ -110,7 +110,7 @@ jobs:
run: |
mvn --batch-mode --update-snapshots -DskipTests -pl clickhouse-benchmark -am package
cd clickhouse-benchmark
java -jar target/benchmarks.jar -rf json ${{ github.event.inputs.options }} > output.txt
java -DclickhouseVersion="21.3" -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
2 changes: 1 addition & 1 deletion .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.0-SNAPSHOT"
default: "0.3.1-SNAPSHOT"

jobs:
release:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/timezone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ jobs:
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 \
-Duser.timezone=${{ matrix.clientTz }} verify
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ log/
target/

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

# Shell scripts
*.sh
12 changes: 12 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
0.3.1
* BREAKING CHANGE - move query from url to request body
* BREAKING CHANGE - always parse SQL(use extended API to skip that)
* BREAKING CHANGE - remove keepAliveTimeout and useNewParser from ClickHouseProperties
* BREAKING CHANGE - exclude RoaringBitmap from shaded jar
* add new connection setting useSharedCookieStore for load balancing
* add new query parameters: allow_experimental_bigint_types, allow_experimental_map_type, and join_algorithm
* add new format: CustomSeparated and RowBinaryWithNamesAndTypes
* fix 400 bad request error when dealing with large query
* 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 Down
27 changes: 25 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.3.0</version>
<version>0.3.1</version>
</dependency>
```

Expand All @@ -20,8 +20,31 @@ URL syntax:
JDBC Driver Class:
`ru.yandex.clickhouse.ClickHouseDriver`

additionally, if you have a few instances, you can use `BalancedClickhouseDataSource`.
For example:
```java
String url = "jdbc:clickhouse://localhost:8123/test";
ClickHouseProperties properties = new ClickHouseProperties();
// set connection options - see more defined in ClickHouseConnectionSettings
properties.setClientName("Agent #1");
...
// set default request options - more in ClickHouseQueryParam
properties.setSessionId("default-session-id");
...

ClickHouseDataSource dataSource = new ClickHouseDataSource(url, properties)
String sql = "select * from mytable";
Map<ClickHouseQueryParam, String> additionalDBParams = new HashMap<>();
// set request options, which will override the default ones in ClickHouseProperties
additionalDBParams.put(ClickHouseQueryParam.SESSION_ID, "new-session-id");
...
try (ClickHouseConnection conn = dataSource.getConnection();
ClickHouseStatement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql, additionalDBParams)) {
...
}
```

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.
Expand Down
4 changes: 2 additions & 2 deletions clickhouse-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<version>${revision}</version>
</parent>

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

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

<properties>
<clickhouse4j-driver.version>1.4.4</clickhouse4j-driver.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public void doSetup(ServerState serverState) throws Exception {
serverState.getUser(), serverState.getPassword()), new Properties());

try (Statement s = conn.createStatement()) {
s.execute(
"create table if not exists test_insert(i Nullable(UInt64), s Nullable(String), t Nullable(DateTime))engine=Memory");
s.execute("create table if not exists system.test_insert(i Nullable(UInt64), s Nullable(String), t Nullable(DateTime))engine=Memory");
}
} catch (SQLException e) {
e.printStackTrace();
Expand All @@ -43,9 +42,9 @@ public void doSetup(ServerState serverState) throws Exception {
}

@TearDown(Level.Trial)
public void doTearDown() throws SQLException {
public void doTearDown(ServerState serverState) throws SQLException {
try (Statement s = conn.createStatement()) {
s.execute("drop table if exists test_insert");
s.execute("drop table if exists system.test_insert");
}
conn.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public int insert10kUInt64Rows(ClientState state) throws Throwable {
final int rows = 10000;
final int num = new Random().nextInt(rows);

return executeInsert(state, "insert into test_insert(i) values(?)", new Enumeration<Object[]>() {
return executeInsert(state, "insert into system.test_insert(i) values(?)", new Enumeration<Object[]>() {
int counter = 0;

@Override
Expand All @@ -39,7 +39,7 @@ public int insert10kStringRows(ClientState state) throws Throwable {
final int rows = 10000;
final int num = new Random().nextInt(rows);

return executeInsert(state, "insert into test_insert(s) values(?)", new Enumeration<Object[]>() {
return executeInsert(state, "insert into system.test_insert(s) values(?)", new Enumeration<Object[]>() {
int counter = 0;

@Override
Expand All @@ -59,7 +59,7 @@ public int insert10kTimestampRows(ClientState state) throws Throwable {
final int rows = 10000;
final int num = new Random().nextInt(rows);

return executeInsert(state, "insert into test_insert(t) values(?)", new Enumeration<Object[]>() {
return executeInsert(state, "insert into system.test_insert(t) values(?)", new Enumeration<Object[]>() {
int counter = 0;

@Override
Expand Down
100 changes: 98 additions & 2 deletions clickhouse-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,94 @@
<version>${revision}</version>
</parent>

<groupId>${parent.groupId}</groupId>
<artifactId>clickhouse-client</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
<description>Unified Java client for ClickHouse</description>
<url>https://github.com/ClickHouse/clickhouse-jdbc/tree/master/clickhouse-client</url>

<properties>
<javacc-plugin.version>4.1.4</javacc-plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dnsjava</groupId>
<artifactId>dnsjava</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.roaringbitmap</groupId>
<artifactId>RoaringBitmap</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<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>tech.clickhouse.client.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 All @@ -31,10 +105,32 @@
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Werror</arg>
<!-- arg>-Werror</arg -->
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<TEST_ENV_STRING>env_str</TEST_ENV_STRING>
<TEST_ENV_INTEGER>416</TEST_ENV_INTEGER>
<TEST_ENV_BOOLEAN>false</TEST_ENV_BOOLEAN>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
7 changes: 5 additions & 2 deletions clickhouse-grpc-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
<version>${revision}</version>
</parent>

<groupId>${parent.groupId}</groupId>
<artifactId>clickhouse-grpc-client</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
<description>gRPC client for ClickHouse</description>
<url>https://github.com/ClickHouse/clickhouse-jdbc/tree/master/clickhouse-grpc-client</url>

<dependencies>
<dependency>
<groupId>${parent.groupId}</groupId>
<groupId>${project.parent.groupId}</groupId>
<artifactId>clickhouse-client</artifactId>
<version>${revision}</version>
</dependency>
Expand Down
Loading