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

    https://github.com/apache/spark/pull/16104#discussion_r90771606
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala
 ---
    @@ -121,21 +121,61 @@ case class InsertIntoHiveTable(
         return dir
       }
     
    -  private def getExternalScratchDir(extURI: URI, hadoopConf: 
Configuration): Path = {
    -    getStagingDir(new Path(extURI.getScheme, extURI.getAuthority, 
extURI.getPath), hadoopConf)
    +  private def getExternalScratchDir(extURI: URI): Path = {
    +    getStagingDir(new Path(extURI.getScheme, extURI.getAuthority, 
extURI.getPath))
       }
     
    -  def getExternalTmpPath(path: Path, hadoopConf: Configuration): Path = {
    +  def getExternalTmpPath(path: Path): Path = {
    +    val hiveVersion = 
externalCatalog.asInstanceOf[HiveExternalCatalog].client.version.fullVersion
    +    if (hiveVersion.startsWith("0.12") ||
    +      hiveVersion.startsWith("0.13") ||
    +      hiveVersion.startsWith("0.14") ||
    +      hiveVersion.startsWith("1.0")) {
    +      oldStyleExternalTempPath(path)
    +    } else if (hiveVersion.startsWith("1.1") || 
hiveVersion.startsWith("1.2")) {
    +      newStyleExternalTempPath(path)
    +    } else {
    +      throw new IllegalStateException("Unsupported hive version: " + 
hiveVersion)
    +    }
    +  }
    +
    +  // Mostly copied from Context.java#getExternalTmpPath of Hive 0.13
    +  def oldStyleExternalTempPath(path: Path): Path = {
    +    val extURI: URI = path.toUri
    +    val scratchPath = new Path(scratchDir, executionId)
    +    var dirPath = new Path(
    +      extURI.getScheme,
    +      extURI.getAuthority,
    +      scratchPath.toUri.getPath + "-" + TaskRunner.getTaskRunnerID())
    +
    +    try {
    +      val fs: FileSystem = dirPath.getFileSystem(hadoopConf)
    +      dirPath = new Path(fs.makeQualified(dirPath).toString())
    +
    +      if (!FileUtils.mkdir(fs, dirPath, true, hadoopConf)) {
    --- End diff --
    
    My above concern is not directly related to this PR. Just submitted a PR to 
resolve the existing issue. https://github.com/apache/spark/pull/16134  I think 
it is a very serious bug.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to