cloud-fan commented on a change in pull request #35823:
URL: https://github.com/apache/spark/pull/35823#discussion_r828000530
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2ScanRelationPushDown.scala
##########
@@ -93,22 +92,28 @@ object V2ScanRelationPushDown extends Rule[LogicalPlan]
with PredicateHelper {
case aggNode @ Aggregate(groupingExpressions, resultExpressions, child) =>
child match {
case ScanOperation(project, filters, sHolder: ScanBuilderHolder)
- if filters.isEmpty &&
project.forall(_.isInstanceOf[AttributeReference]) =>
+ if filters.isEmpty && project.forall(_.deterministic) =>
sHolder.builder match {
case r: SupportsPushDownAggregates =>
+ val aliasMap = getAliasMap(project)
+ val newResultExpressions =
resultExpressions.map(replaceAliasWithAttr(_, aliasMap))
+ val newGroupingExpressions = groupingExpressions.map {
+ case e: NamedExpression => replaceAliasWithAttr(e, aliasMap)
+ case other => other
+ }
val aggExprToOutputOrdinal = mutable.HashMap.empty[Expression,
Int]
- val aggregates = collectAggregates(resultExpressions,
aggExprToOutputOrdinal)
+ val aggregates = collectAggregates(newResultExpressions,
aggExprToOutputOrdinal)
val normalizedAggregates = DataSourceStrategy.normalizeExprs(
aggregates,
sHolder.relation.output).asInstanceOf[Seq[AggregateExpression]]
val normalizedGroupingExpressions =
DataSourceStrategy.normalizeExprs(
- groupingExpressions, sHolder.relation.output)
+ newGroupingExpressions, sHolder.relation.output)
val translatedAggregates =
DataSourceStrategy.translateAggregation(
normalizedAggregates, normalizedGroupingExpressions)
- val (finalResultExpressions, finalAggregates,
finalTranslatedAggregates) = {
+ val (selectedResultExpressions, selectedAggregates,
selectedTranslatedAggregates) = {
Review comment:
why do we rename these?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]