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

    https://github.com/apache/spark/pull/1919#discussion_r16338954
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala
 ---
    @@ -159,6 +159,28 @@ case class InsertIntoHiveTable(
         writer.commitJob()
       }
     
    +  def getDynamicPartDir(tableInfo: TableDesc, row: Row, dynamicPartNum2: 
Int) :String = {
    +    dynamicPartNum2 match {
    +      case 0 =>""
    +      case i => {
    +        val colsNum = 
tableInfo.getProperties.getProperty("columns").split("\\,").length
    +        val partColStr = 
tableInfo.getProperties.getProperty("partition_columns")
    +        val partCols = partColStr.split("/")
    +        var buf = new StringBuffer()
    --- End diff --
    
    I think we can simplify line 169 to line 179 to:
    
    ```scala
    partCols
      .takeRight(dynamicPartNum2)
      .zip(row.takeRight(dynamicPartNum2))
      .map { case (c, v) => s"/$c=$v" }
      .mkString
    ```
    
    Also, I'm not very sure whether `toString` is adequate enough to be part of 
the partition directory name...


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