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

    https://github.com/apache/spark/pull/15819#discussion_r87676512
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala
 ---
    @@ -54,6 +61,61 @@ case class InsertIntoHiveTable(
       @transient private lazy val hiveContext = new Context(sc.hiveconf)
       @transient private lazy val catalog = sc.catalog
     
    +  val stagingDir = new HiveConf().getVar(HiveConf.ConfVars.STAGINGDIR)
    +
    +  private def executionId: String = {
    +    val rand: Random = new Random
    +    val format: SimpleDateFormat = new 
SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_SSS")
    +    val executionId: String = "hive_" + format.format(new Date) + "_" + 
Math.abs(rand.nextLong)
    +    return executionId
    +  }
    +
    +  private def getStagingDir(inputPath: Path, hadoopConf: Configuration): 
Path = {
    +    val inputPathUri: URI = inputPath.toUri
    +    val inputPathName: String = inputPathUri.getPath
    +    val fs: FileSystem = inputPath.getFileSystem(hadoopConf)
    +    val stagingPathName: String =
    +      if (inputPathName.indexOf(stagingDir) == -1) {
    +        new Path(inputPathName, stagingDir).toString
    +      } else {
    +        inputPathName.substring(0, inputPathName.indexOf(stagingDir) + 
stagingDir.length)
    +      }
    +    val dir: Path =
    +      fs.makeQualified(
    +        new Path(stagingPathName + "_" + executionId + "-" + 
TaskRunner.getTaskRunnerID))
    +    logDebug("Created staging dir = " + dir + " for path = " + inputPath)
    +    try {
    +      if (!FileUtils.mkdir(fs, dir, true, hadoopConf)) {
    +        throw new IllegalStateException("Cannot create staging directory  
'" + dir.toString + "'")
    +      }
    +      fs.deleteOnExit(dir)
    +    }
    +    catch {
    +      case e: IOException =>
    +        throw new RuntimeException(
    +          "Cannot create staging directory '" + dir.toString + "': " + 
e.getMessage, e)
    +
    +    }
    +    return dir
    --- End diff --
    
    Can the extra noise (return statement) in scala code be removed please.


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