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

    https://github.com/apache/spark/pull/9305#discussion_r43522924
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
 ---
    @@ -201,15 +200,24 @@ private[sql] object DataSourceStrategy extends 
Strategy with Logging {
           // Builds `AttributeReference`s for all partition columns so that we 
can use them to project
           // required partition columns.  Note that if a partition column 
appears in `requiredColumns`,
           // we should use the `AttributeReference` in `requiredColumns`.
    -      val requiredColumnMap = requiredColumns.map(a => a.name -> a).toMap
    -      val partitionColumns = partitionColumnSchema.toAttributes.map { a =>
    -        requiredColumnMap.getOrElse(a.name, a)
    +      val partitionColumns = {
    +        val requiredColumnMap = requiredColumns.map(a => a.name -> a).toMap
    +        partitionColumnSchema.toAttributes.map { a =>
    +          requiredColumnMap.getOrElse(a.name, a)
    +        }
           }
     
           val mapPartitionsFunc = (_: TaskContext, _: Int, iterator: 
Iterator[InternalRow]) => {
    -        val projection = UnsafeProjection.create(requiredColumns, 
dataColumns ++ partitionColumns)
    +        // Note that we can't use an `UnsafeRowJoiner` to replace the 
following `JoinedRow` and
    +        // `UnsafeProjection`.  Because the projection may also adjust 
column order.
             val mutableJoinedRow = new JoinedRow()
    -        iterator.map(dataRow => projection(mutableJoinedRow(dataRow, 
partitionValues)))
    +        val unsafePartitionValues = 
UnsafeProjection.create(partitionColumnSchema)(partitionValues)
    +        val unsafeProjection =
    +          UnsafeProjection.create(requiredColumns, dataColumns ++ 
partitionColumns)
    +
    +        iterator.asInstanceOf[Iterator[UnsafeRow]].map { unsafeDataRow =>
    --- End diff --
    
    Right, thanks. I had once been using a `UnsafeRowJoiner` here, forgot to 
remove this cast.


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