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

    https://github.com/apache/spark/pull/16451#discussion_r94563417
  
    --- 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
    --- End diff --
    
    Here, it threw the exception as below:
    
    ```
    java.nio.file.InvalidPathException: Illegal char <:> at index 2: 
/C:/projects/spark/target/tmp/spark-8e874658-3e0d-4622-a999-d4305954d2c1/*part-r*
    ```
    
    because the leading `/` is not allowed. After converting it into `C:\a\b\c` 
format, then it throws an exception as below:
    
    ```
    java.nio.file.InvalidPathException: Illegal char <*> at index 72: 
C:\projects\spark\target\tmp\spark-2f34e61d-9951-43fe-bb7d-32248fa55b22\*part-r*
    ```
    
    Special characters such as "*" on Windows are not allowed as a path. So, 
calling `WindowsFileSystem.getPath` throws an exception if there are in the 
path.
    
    So, here, I separated the file name and the dir path.



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