Skip to content

Commit 091d259

Browse files
committed
Fix file not found for path with url encoded character
1 parent 01be207 commit 091d259

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.apache.spark.sql.blaze
2+
3+
import org.apache.spark.sql.Row
4+
5+
class BlazeQuerySuite extends org.apache.spark.sql.QueryTest with BaseBlazeSQLSuite {
6+
7+
test("test partition path has url encoded character") {
8+
withTable("t1") {
9+
sql("create table t1 using parquet PARTITIONED BY (part) as select 1 as c1, 2 as c2, 'test test' as part")
10+
val df = sql("select * from t1")
11+
checkAnswer(df, Seq(Row(1, 2, "test test")))
12+
}
13+
}
14+
15+
}

spark-extension/src/main/java/org/apache/spark/sql/blaze/JniBridge.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.lang.management.BufferPoolMXBean;
1919
import java.lang.management.ManagementFactory;
20+
import java.net.URI;
2021
import java.util.List;
2122
import java.util.concurrent.ConcurrentHashMap;
2223
import org.apache.hadoop.fs.FileSystem;
@@ -85,7 +86,8 @@ public static boolean isDriverSide() {
8586
}
8687

8788
public static FSDataInputWrapper openFileAsDataInputWrapper(FileSystem fs, String path) throws Exception {
88-
return FSDataInputWrapper$.MODULE$.wrap(fs.open(new Path(path)));
89+
// the path is a URI string, so we need to convert it to a URI object, ref: org.apache.spark.paths.SparkPath.toPath
90+
return FSDataInputWrapper$.MODULE$.wrap(fs.open(new Path(new URI(path))));
8991
}
9092

9193
public static FSDataOutputWrapper createFileAsDataOutputWrapper(FileSystem fs, String path) throws Exception {

0 commit comments

Comments
 (0)