Skip to content

Commit

Permalink
[SPARK-48584][SQL][FOLLOWUP] Improve the unescapePathName
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
This PR follows up #46938 and improve the `unescapePathName`.

### Why are the changes needed?
Improve the `unescapePathName` by cut off slow path.

### Does this PR introduce _any_ user-facing change?
'No'.

### How was this patch tested?
GA.

### Was this patch authored or co-authored using generative AI tooling?
'No'.

Closes #46957 from beliefer/SPARK-48584_followup.

Authored-by: beliefer <beliefer@163.com>
Signed-off-by: beliefer <beliefer@163.com>
  • Loading branch information
beliefer committed Jun 13, 2024
1 parent ea2bca7 commit 78fd4e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ object ExternalCatalogUtils {
}
var plaintextEndIdx = path.indexOf('%')
val length = path.length
if (plaintextEndIdx == -1 || plaintextEndIdx + 2 > length) {
if (plaintextEndIdx == -1 || plaintextEndIdx + 2 >= length) {
// fast path, no %xx encoding found then return the string identity
path
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class ExternalCatalogUtilsSuite extends SparkFunSuite {
assert(unescapePathName("a%2Fb") === "a/b")
assert(unescapePathName("a%2") === "a%2")
assert(unescapePathName("a%F ") === "a%F ")
assert(unescapePathName("%0") === "%0")
assert(unescapePathName("0%") === "0%")
// scalastyle:off nonascii
assert(unescapePathName("a\u00FF") === "a\u00FF")
// scalastyle:on nonascii
Expand Down

0 comments on commit 78fd4e3

Please sign in to comment.