Skip to content

Commit 1265bd0

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: #55
1 parent 8ec83e1 commit 1265bd0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

+7
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

+7
Original file line numberDiff line numberDiff line change
@@ -4869,6 +4869,13 @@ public static void test_empty_typemap_allowed() throws Exception {
48694869
}
48704870
}
48714871

4872+
public static void test_spark_path_option_ignored() throws Exception {
4873+
Properties config = new Properties();
4874+
config.put("path", "path/to/spark/catalog/dir");
4875+
Connection conn = DriverManager.getConnection(JDBC_URL, config);
4876+
conn.close();
4877+
}
4878+
48724879
public static void main(String[] args) throws Exception {
48734880
String arg1 = args.length > 0 ? args[0] : "";
48744881
final int statusCode;

0 commit comments

Comments
 (0)