@@ -38,6 +38,46 @@ cd databend-jdbc
3838mvn 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:
145185The 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 ;
148191import 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 ;
178233import 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
0 commit comments