viirya commented on a change in pull request #23701: [SPARK-26741][SQL] Allow
using aggregate expressions in ORDER BY clause
URL: https://github.com/apache/spark/pull/23701#discussion_r253012398
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -1666,10 +1679,12 @@ class Analyzer(
// we need to check this and prevent applying this rule multiple
times
if (sortOrder == finalSortOrders) {
sort
+ } else if (needsPushDown.isEmpty) {
+ Sort(finalSortOrders, global, child)
} else {
- Project(aggregate.output,
+ Project(child.output,
Sort(finalSortOrders, global,
- aggregate.copy(aggregateExpressions = originalAggExprs ++
needsPushDown)))
+ pushDownMissingAttrs(needsPushDown, child)))
Review comment:
oh, for now `pushDownMissingAttrs` will return `child` if it is unexpected.
For that case, we may just return original plan, instead of adding `Project`
and changing `Sort`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]