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

    https://github.com/apache/spark/pull/11435#discussion_r54939618
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
 ---
    @@ -246,9 +284,25 @@ private[sql] object DataSourceStrategy extends 
Strategy with Logging {
             val unsafeProjection =
               UnsafeProjection.create(requiredColumns, dataColumns ++ 
partitionColumns)
     
    -        iterator.map { unsafeDataRow =>
    -          unsafeProjection(mutableJoinedRow(unsafeDataRow, 
unsafePartitionValues))
    -        }
    +        // If we are returning batches directly, we need to augment them 
with the partitioning
    +        // columns. We want to do this without a row by row operation.
    +        var columnBatch: ColumnarBatch = null
    +
    +        iterator.map { input => {
    +          if (input.isInstanceOf[InternalRow]) {
    +            unsafeProjection(mutableJoinedRow(
    +              input.asInstanceOf[InternalRow], unsafePartitionValues))
    +          } else {
    +            require(input.isInstanceOf[ColumnarBatch])
    +            val inputBatch = input.asInstanceOf[ColumnarBatch]
    +            if (columnBatch == null) {
    +              columnBatch = projectedColumnBatch(inputBatch, 
requiredColumns,
    --- End diff --
    
    Could you add a comment that say we already return the same ColumnarBatch 
object from reader?
    
    And we should add a `require` for that.


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