Skip to content

Commit 933ad85

Browse files
committed
Use absolute path pattern match.
1 parent c74191b commit 933ad85

File tree

1 file changed

+2
-3
lines changed
  • sql/core/src/main/scala/org/apache/spark/sql/execution/command

1 file changed

+2
-3
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ case class LoadDataCommand(
252252
val fileSystem = FileSystems.getDefault
253253
val pathPattern = fileSystem.getPath(filePath)
254254
val dir = pathPattern.getParent.toString
255-
val filePattern = pathPattern.getFileName.toString
256255
if (dir.contains("*")) {
257256
throw new AnalysisException(
258257
s"LOAD DATA input path allows only filename wildcard: $path")
@@ -262,8 +261,8 @@ case class LoadDataCommand(
262261
if (files == null) {
263262
false
264263
} else {
265-
val matcher = fileSystem.getPathMatcher("glob:" + filePattern)
266-
files.exists(f => matcher.matches(fileSystem.getPath(f.getName)))
264+
val matcher = fileSystem.getPathMatcher("glob:" + pathPattern.toAbsolutePath)
265+
files.exists(f => matcher.matches(fileSystem.getPath(f.getAbsolutePath)))
267266
}
268267
} else {
269268
new File(filePath).exists()

0 commit comments

Comments
 (0)