cloud-fan commented on code in PR #47331:
URL: https://github.com/apache/spark/pull/47331#discussion_r1696267761
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/InsertMapSortInGroupingExpressions.scala:
##########
@@ -34,12 +35,46 @@ object InsertMapSortInGroupingExpressions extends
Rule[LogicalPlan] {
_.containsPattern(AGGREGATE), ruleId) {
case a @ Aggregate(groupingExpr, _, _) =>
val newGrouping = groupingExpr.map { expr =>
- if (!expr.isInstanceOf[MapSort] &&
expr.dataType.isInstanceOf[MapType]) {
- MapSort(expr)
+ if (!expr.exists(_.isInstanceOf[MapSort])
+ && expr.dataType.existsRecursively(_.isInstanceOf[MapType])) {
Review Comment:
instead of doing two recursive checks ahead, we can simply skip adding
`MapSort` in `insertMapSortRecursively` if the expression is already `MapSort`.
--
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]