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

    https://github.com/apache/spark/pull/17858#discussion_r115415586
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala
 ---
    @@ -97,12 +97,23 @@ case class InsertIntoHiveTable(
         val inputPathUri: URI = inputPath.toUri
         val inputPathName: String = inputPathUri.getPath
         val fs: FileSystem = inputPath.getFileSystem(hadoopConf)
    -    val stagingPathName: String =
    +    var stagingPathName: String =
           if (inputPathName.indexOf(stagingDir) == -1) {
             new Path(inputPathName, stagingDir).toString
           } else {
             inputPathName.substring(0, inputPathName.indexOf(stagingDir) + 
stagingDir.length)
           }
    +
    +    // SPARK-20594: The staging directory should be a child directory 
starts with "." to avoid
    +    // being deleted if we set hive.exec.stagingdir under the table 
directory.
    +    if (FileUtils.isSubDir(new Path(stagingPathName), inputPath, fs)
    +      && !stagingPathName.stripPrefix(inputPathName).startsWith(".")) {
    --- End diff --
    
    Sorry i do not follow your logic. Correct me if I'm wrong, but isn't the 
logic of dropping the created staging directory was already there before with 
`fs.deleteOnExit(dir)`?
    As @cloud-fan said this patch seems a valid workaround in Spark SQL for 
this case.


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