Skip to content

Commit 5b681e1

Browse files
committed
Ignore path option passed by Spark
Apache Spark passes the `path` option when a SELECT on a JDBC DataSource table is performed. It is the internal Spark option and is likely passed by mistake, so we need to ignore it to allow the connection to be established. Testing: new test added that checks that the `path` option is ognored. Fixes: duckdb#55
1 parent d392e43 commit 5b681e1

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ add_library(duckdb_java SHARED
561561
src/jni/duckdb_java.cpp
562562
src/jni/functions.cpp
563563
src/jni/refs.cpp
564+
src/jni/types.cpp
564565
src/jni/util.cpp
565566
${DUCKDB_SRC_FILES})
566567

CMakeLists.txt.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ add_library(duckdb_java SHARED
103103
src/jni/duckdb_java.cpp
104104
src/jni/functions.cpp
105105
src/jni/refs.cpp
106+
src/jni/types.cpp
106107
src/jni/util.cpp
107108
${DUCKDB_SRC_FILES})
108109

src/main/java/org/duckdb/DuckDBDriver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ public Connection connect(String url, Properties info) throws SQLException {
3838
read_only = prop_clean.equals("1") || prop_clean.equals("true") || prop_clean.equals("yes");
3939
}
4040
info.put("duckdb_api", "jdbc");
41+
42+
// Apache Spark passes this option when SELECT on a JDBC DataSource
43+
// table is performed. It is the internal Spark option and is likely
44+
// passed by mistake, so we need to ignore it to allow the connection
45+
// to be established.
46+
info.remove("path");
47+
4148
return DuckDBConnection.newConnection(url, read_only, info);
4249
}
4350

src/test/java/org/duckdb/TestDuckDBJDBC.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4793,6 +4793,13 @@ public static void test_client_config_retained_on_dup() throws Exception {
47934793
}
47944794
}
47954795

4796+
public static void test_spark_path_option_ignored() throws Exception {
4797+
Properties config = new Properties();
4798+
config.put("path", "path/to/spark/catalog/dir");
4799+
Connection conn = DriverManager.getConnection(JDBC_URL, config);
4800+
conn.close();
4801+
}
4802+
47964803
public static void main(String[] args) throws Exception {
47974804
String arg1 = args.length > 0 ? args[0] : "";
47984805
final int statusCode;

0 commit comments

Comments
 (0)