n-young commented on code in PR #58867:
URL: https://github.com/apache/spark/pull/58867#discussion_r4509788838


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/NondeterministicExpressionCollection.scala:
##########
@@ -22,19 +22,42 @@ import java.util.LinkedHashMap
 import org.apache.spark.sql.catalyst.expressions._
 
 object NondeterministicExpressionCollection {
+  /**
+   * Returns a copy used only to classify the parent, plus the minimal 
nondeterministic
+   * evaluation frontier below `expression`.
+   *
+   * A selected expression is represented by a deterministic attribute while 
walking upward. If
+   * its parent is still nondeterministic after that substitution, the parent 
is the evaluation
+   * unit and replaces the selected descendants in the frontier.
+   */
+  private def collectNondeterministicFrontier(
+      expression: Expression): (Expression, Seq[Expression]) = {
+    if (expression.deterministic) {
+      (expression, Seq.empty)
+    } else {
+      val childResults = 
expression.children.map(collectNondeterministicFrontier)
+      val expressionWithDeterministicChildren =
+        expression.withNewChildren(childResults.map(_._1))

Review Comment:
   ListQuery and Exists are no longer selected or traversed as extraction 
units, and a containing expression with a predicate subquery cannot become a 
unit. This preserves original placement validation and avoids replacing the 
typed ListQuery child with an attribute. Added checks for the base errors 
across GROUP BY/ORDER BY/DISTRIBUTE BY, single scalar-subquery extraction 
(including valid IN/EXISTS inside the scalar query), and separate extraction of 
rand() in IN values. The placement guard checks the current expression tree 
because subquery-plan pattern bits also include predicates inside scalar 
queries. The UnaryNode rule leaves the plan unchanged when the extraction set 
is empty, preserving Once idempotence before placement validation.



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

Reply via email to