Skip to content

Commit 76eb3e5

Browse files
authored
feat(jdbc): add Arrow HTTP results and page-based prefetch
2 parents c2c9a0e + efcf730 commit 76eb3e5

40 files changed

Lines changed: 2296 additions & 296 deletions

.github/workflows/test_cluster.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,18 @@ jobs:
3636
DATABEND_QUERY_VERSION: ${{ matrix.version }}
3737

3838
- name: Test with conn to nginx
39-
run: mvn test -DexcludedGroups=FLAKY
39+
working-directory: tests
40+
run: make test TEST_MVN_ARGS='-DexcludedGroups=FLAKY'
41+
env:
42+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
43+
DATABEND_TEST_CONN_PORT: 8000
44+
DATABEND_QUERY_VERSION: ${{ matrix.version }}
45+
46+
- name: Test Arrow IT with conn to nginx
47+
working-directory: tests
48+
run: make test TEST_MVN_ARGS='-Dgroups=IT -DexcludedGroups=FLAKY'
4049
env:
4150
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
4251
DATABEND_TEST_CONN_PORT: 8000
4352
DATABEND_QUERY_VERSION: ${{ matrix.version }}
53+
DATABEND_JDBC_TEST_QUERY_RESULT_FORMAT: arrow

.github/workflows/test_standalone.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ jobs:
5050
docker logs ${cid}
5151
curl -u databend:databend --request POST localhost:8000/v1/query --header 'Content-Type:application/json' --data-raw '{"sql":"select 1"}'
5252
53-
- name: Run Maven clean deploy with release profile
54-
run: mvn test -DexcludedGroups=MULTI_HOST,FLAKY
53+
- name: Run Tests
54+
working-directory: tests
55+
run: make test TEST_MVN_ARGS='-DexcludedGroups=FLAKY'
5556
env:
5657
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
58+
59+
- name: Run Arrow IT
60+
working-directory: tests
61+
run: make test TEST_MVN_ARGS='-Dgroups=IT -DexcludedGroups=FLAKY'
62+
env:
63+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
64+
DATABEND_JDBC_TEST_QUERY_RESULT_FORMAT: arrow

README.md

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,46 @@ cd databend-jdbc
3838
mvn clean install -DskipTests
3939
```
4040

41+
## Testing
42+
43+
Start the local integration test environment from `tests/Makefile`:
44+
45+
```shell
46+
cd tests
47+
make up
48+
make test
49+
```
50+
51+
The default `make test` command runs `databend-jdbc` tests only.
52+
53+
### Run integration tests with Arrow
54+
55+
To run tests with Arrow result pages, set `DATABEND_JDBC_TEST_QUERY_RESULT_FORMAT=arrow`:
56+
57+
```shell
58+
cd tests
59+
make test DATABEND_JDBC_TEST_QUERY_RESULT_FORMAT=arrow TEST_MVN_ARGS='-Dgroups=IT -DexcludedGroups=FLAKY'
60+
```
61+
62+
When Arrow mode is enabled through `make test`, the required JVM options are added automatically:
63+
64+
```shell
65+
--add-opens=java.base/java.nio=ALL-UNNAMED
66+
-Dio.netty.tryReflectionSetAccessible=true
67+
```
68+
69+
If you run Maven directly instead of `make test`, you must set both the Arrow test environment variable and the JVM options yourself:
70+
71+
```shell
72+
JAVA_TOOL_OPTIONS='--add-opens=java.base/java.nio=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true' \
73+
DATABEND_JDBC_TEST_QUERY_RESULT_FORMAT=arrow \
74+
mvn -pl databend-jdbc test -Dgroups=IT -DexcludedGroups=FLAKY
75+
```
76+
77+
CI note:
78+
- `Standalone Test` runs the regular suite and an extra Arrow IT pass.
79+
- `Cluster Tests` runs the regular suite and an extra Arrow IT pass for each cluster matrix entry.
80+
4181
### Download jar from maven central
4282

4383
```shell
@@ -145,9 +185,18 @@ old Timestamp/Date are also supported, note that:
145185
The following code shows how to unwrap a JDBC Connection object to expose the methods of the DatabendConnection interface.
146186

147187
```java
188+
import java.sql.DriverManager;
189+
import java.sql.Connection;
190+
import java.sql.SQLException;
148191
import com.databend.jdbc.DatabendConnection;
149-
Connection conn = DriverManager.getConnection("jdbc:databend://localhost:8000");
150-
DatabendConnection databendConnection = conn.unwrap(DatabendConnection.class);
192+
193+
public class UnwrapExample {
194+
public static void main(String[] args) throws SQLException {
195+
try (Connection conn = DriverManager.getConnection("jdbc:databend://localhost:8000")) {
196+
DatabendConnection databendConnection = conn.unwrap(DatabendConnection.class);
197+
}
198+
}
199+
}
151200
```
152201

153202
### method `loadStreamToTable`
@@ -175,16 +224,29 @@ example:
175224

176225

177226
```java
227+
import java.io.FileInputStream;
228+
import java.nio.file.Files;
229+
import java.nio.file.Paths;
230+
import java.sql.Connection;
231+
import java.sql.DriverManager;
232+
import java.sql.SQLException;
178233
import com.databend.jdbc.DatabendConnection;
179-
try(Connection conn = DriverManager.getConnection("jdbc:databend://localhost:8000")) {
180-
try(FileInputStream fileStream = new FileInputStream("data.csv")) {
181-
// unwrap
182-
DatabendConnection databendConnection = conn.unwrap(DatabendConnection.class);
183-
184-
// use special stage `_databend_load`
185-
String sql = "insert into my_table from @_databend_load file_format=(type=csv)";
186-
187-
databendConnection.loadStreamToTable(sql, fileStream, Files.size(Paths.get("data.csv")), DatabendConnection.LoadMethod.STAGE);
234+
235+
public class LoadStreamExample {
236+
public static void main(String[] args) throws SQLException {
237+
try (Connection conn = DriverManager.getConnection("jdbc:databend://localhost:8000");
238+
FileInputStream fileStream = new FileInputStream("data.csv")) {
239+
DatabendConnection databendConnection = conn.unwrap(DatabendConnection.class);
240+
241+
// use special stage `_databend_load`
242+
String sql = "insert into my_table from @_databend_load file_format=(type=csv)";
243+
244+
databendConnection.loadStreamToTable(
245+
sql,
246+
fileStream,
247+
Files.size(Paths.get("data.csv")),
248+
DatabendConnection.LoadMethod.STAGE);
249+
}
188250
}
189251
}
190252

databend-jdbc/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
<groupId>com.squareup.okhttp3</groupId>
2020
<artifactId>okhttp</artifactId>
2121
</dependency>
22+
<dependency>
23+
<groupId>org.apache.arrow</groupId>
24+
<artifactId>arrow-vector</artifactId>
25+
<version>17.0.0</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.apache.arrow</groupId>
29+
<artifactId>arrow-memory-unsafe</artifactId>
30+
<version>17.0.0</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.apache.arrow</groupId>
34+
<artifactId>arrow-compression</artifactId>
35+
<version>17.0.0</version>
36+
</dependency>
2237
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
2338
<dependency>
2439
<groupId>org.apache.commons</groupId>

0 commit comments

Comments
 (0)