Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16451#discussion_r94563476
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
    @@ -222,25 +223,34 @@ case class LoadDataCommand(
         val loadPath =
           if (isLocal) {
             val uri = Utils.resolveURI(path)
    -        val filePath = uri.getPath()
    -        val exists = if (filePath.contains("*")) {
    +        val file = new File(uri.getPath)
    +        val exists = if (file.getAbsolutePath.contains("*")) {
               val fileSystem = FileSystems.getDefault
    -          val pathPattern = fileSystem.getPath(filePath)
    -          val dir = pathPattern.getParent.toString
    +          val dir = file.getParentFile.getAbsolutePath
               if (dir.contains("*")) {
                 throw new AnalysisException(
                   s"LOAD DATA input path allows only filename wildcard: $path")
               }
     
    +          // Note that special characters such as "*" on Windows are not 
allowed as a path.
    +          // Calling `WindowsFileSystem.getPath` throws an exception if 
there are in the path.
    +          val dirPath = fileSystem.getPath(dir)
    +          val pathPattern = new File(dirPath.toAbsolutePath.toString, 
file.getName).toURI.getPath
    +          val safePathPattern = if (Utils.isWindows) {
    +            // On Windows, the pattern should not start with slashes for 
absolute file paths.
    +            pathPattern.stripPrefix("/")
    --- End diff --
    
    On Windows, both `C:\\a\\b\\c` and `C:/a/b/c` are allowed here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to