Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18600#discussion_r126803119
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
 ---
    @@ -395,25 +367,33 @@ case class DataSourceStrategy(conf: SQLConf) extends 
Strategy with Logging with
             .asInstanceOf[Seq[Attribute]]
             // Match original case of attributes.
             .map(relation.attributeMap)
    -        // Don't request columns that are only referenced by pushed 
filters.
    -        .filterNot(handledSet.contains)
     
           val scan = RowDataSourceScanExec(
    -        projects.map(_.toAttribute),
    +        relation.output,
    +        requestedColumns.map(relation.output.indexOf),
    +        pushedFilters.toSet,
             scanBuilder(requestedColumns, candidatePredicates, pushedFilters),
    -        relation.relation, UnknownPartitioning(0), metadata,
    -        relation.catalogTable.map(_.identifier))
    +        relation.relation, relation.catalogTable.map(_.identifier))
           filterCondition.map(execution.FilterExec(_, scan)).getOrElse(scan)
         } else {
    +      // A set of column attributes that are only referenced by pushed 
down filters.  We can
    +      // eliminate them from requested columns.
    +      val handledSet = {
    +        val handledPredicates = 
filterPredicates.filterNot(unhandledPredicates.contains)
    +        val unhandledSet = 
AttributeSet(unhandledPredicates.flatMap(_.references))
    +        AttributeSet(handledPredicates.flatMap(_.references)) --
    +          (projectSet ++ unhandledSet).map(relation.attributeMap)
    +      }
           // Don't request columns that are only referenced by pushed filters.
           val requestedColumns =
             (projectSet ++ filterSet -- 
handledSet).map(relation.attributeMap).toSeq
     
           val scan = RowDataSourceScanExec(
    -        requestedColumns,
    +        relation.output,
    +        requestedColumns.map(relation.output.indexOf),
    +        pushedFilters.toSet,
             scanBuilder(requestedColumns, candidatePredicates, pushedFilters),
    -        relation.relation, UnknownPartitioning(0), metadata,
    -        relation.catalogTable.map(_.identifier))
    +        relation.relation, relation.catalogTable.map(_.identifier))
    --- End diff --
    
    ditto.


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