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

    https://github.com/apache/spark/pull/1072#discussion_r13736739
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/columnar/InMemoryColumnarTableScan.scala
 ---
    @@ -55,14 +66,26 @@ private[sql] case class InMemoryColumnarTableScan(
         cached.count()
         cached
       }
    +}
    +
    +private[sql] case class InMemoryColumnarTableScan(
    +    attributes: Seq[Attribute],
    +    relation: InMemoryRelation)
    +  extends LeafNode {
    +
    +  override def output: Seq[Attribute] = attributes
     
       override def execute() = {
    -    cachedColumnBuffers.mapPartitions { iterator =>
    +    relation.cachedColumnBuffers.mapPartitions { iterator =>
           val columnBuffers = iterator.next()
           assert(!iterator.hasNext)
     
           new Iterator[Row] {
    -        val columnAccessors = columnBuffers.map(ColumnAccessor(_))
    +        // Find the ordinals of the requested columns.  If none are 
requested, use the first.
    +        val requestedColumns =
    +          if (attributes.isEmpty) Seq(0) else 
attributes.map(relation.output.indexOf(_))
    --- End diff --
    
    Correct.
    
    That sounds like a nice optimization for a future PR :)  Really at that 
point we might special case COUNT such that we just get that statistic instead 
of calling next() `n` times.


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

Reply via email to