HyukjinKwon commented on a change in pull request #28745:
URL: https://github.com/apache/spark/pull/28745#discussion_r437409581



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -2755,11 +2753,23 @@ class Analyzer(
       case f: Filter => f
 
       case a: Aggregate if a.groupingExpressions.exists(!_.deterministic) =>
-        val nondeterToAttr = getNondeterToAttr(a.groupingExpressions)
-        val newChild = Project(a.child.output ++ nondeterToAttr.values, 
a.child)
-        a.transformExpressions { case e =>
-          nondeterToAttr.get(e).map(_.toAttribute).getOrElse(e)
-        }.copy(child = newChild)
+        projectGroupingExprs(a, a.groupingExpressions)
+
+      case f: FlatMapGroupsInPandas if 
f.groupingExprs.exists(!_.deterministic) =>

Review comment:
       So, basically this is for the case when grouping expressions are 
non-deterministic:
   
   ```bash
   == Physical Plan ==
   FlatMapGroupsInPandas [_nondeterministic#14], my_pandas_udf(column#4L, 
score#6), [column#12, score#13]
   +- *(2) Sort [_nondeterministic#14 ASC NULLS FIRST], false, 0
      +- Exchange hashpartitioning(_nondeterministic#14, 200), true, [id=#19]
         +- *(1) Project [column#4L, score#6, rand(42) AS _nondeterministic#14] 
 # <--- here to evaluate non-deterministic expression only once.
   ...
   ```




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to