n-young commented on code in PR #58867:
URL: https://github.com/apache/spark/pull/58867#discussion_r4509788685
##########
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))
+
+ if (!expressionWithDeterministicChildren.deterministic) {
+ val placeholder = AttributeReference(
+ "_nondeterministic", expression.dataType, expression.nullable)()
+ (placeholder, Seq(expression))
Review Comment:
When a selected unit occurs in a higher-order function lambda, the enclosing
higher-order function becomes the extraction unit. This keeps lambda variables
bound and avoids a separate AES alias outside the lambda. Added GROUP BY/ORDER
BY/DISTRIBUTE BY analyzer checks for transform and size(transform(...)), plus
execution coverage.
##########
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, and
separate extraction of rand() in IN values.
--
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]