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

    https://github.com/apache/spark/pull/4792#discussion_r25533640
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala ---
    @@ -483,16 +487,42 @@ private[sql] case class ParquetRelation2(
     
             val requiredPartOrdinal = partitionKeyLocations.keys.toSeq
     
    -        iterator.map { pair =>
    -          val row = pair._2.asInstanceOf[SpecificMutableRow]
    -          var i = 0
    -          while (i < requiredPartOrdinal.size) {
    -            // TODO Avoids boxing cost here!
    -            val partOrdinal = requiredPartOrdinal(i)
    -            row.update(partitionKeyLocations(partOrdinal), 
partValues(partOrdinal))
    -            i += 1
    +        if (primitiveRow) {
    +          iterator.map { pair =>
    +            // We are using CatalystPrimitiveRowConverter and it returns a 
SpecificMutableRow.
    +            val row = pair._2.asInstanceOf[SpecificMutableRow]
    +            var i = 0
    +            while (i < requiredPartOrdinal.size) {
    +              // TODO Avoids boxing cost here!
    +              val partOrdinal = requiredPartOrdinal(i)
    +              row.update(partitionKeyLocations(partOrdinal), 
partValues(partOrdinal))
    +              i += 1
    +            }
    +            row
    +          }
    +        } else {
    +          // Create a mutable row since we need to fill in values from 
partition columns.
    +          val mutableRow = new GenericMutableRow(requestedSchema.size)
    --- End diff --
    
    Seems it will be safer if we get `requestedSchema.size` out side of 
`mapPartitionsWithInputSplit`.


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