viirya commented on code in PR #60643:
URL: https://github.com/apache/spark/pull/60643#discussion_r4608531672


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala:
##########
@@ -231,14 +232,33 @@ trait PredicateHelper extends AliasHelper with Logging {
   }
 
   /**
-   * The output columns of `plan` that can fail to compute: the deterministic 
columns of a
-   * [[Project]] whose expression [[ExprUtils.canEvaluateUnconditionally]] 
rejects or reads such a
-   * column of its child, looking through [[Filter]] and [[Sample]]. A 
condition over such a column
-   * can fail as its expression does: under whole-stage codegen, the 
projection computes a
-   * deterministic column for a row only when a condition above first reads 
it, and
-   * `PushPredicateThroughNonJoin` pushes a condition below the projection 
with the expression
-   * substituted. A non-deterministic column is computed on every row the 
projection gets, so it
-   * does not count. Other operators are not looked through.
+   * The output columns of `plan` that can fail to compute. Under whole-stage 
codegen, a
+   * projection or an aggregation computes a deterministic column for a row 
only when a condition
+   * above first reads it, and `PushPredicateThroughNonJoin` pushes a 
condition below a projection
+   * with the expression substituted. So a condition over such a column can 
fail as its expression
+   * does. The columns are:
+   *  - A deterministic column of a [[Project]] whose expression
+   *    [[ExprUtils.canEvaluateUnconditionally]] rejects or reads such a 
column of its child.
+   *  - A result column of an [[Aggregate]] whose expression, with each 
aggregate function taken
+   *    as its value, is deterministic and rejected by it. Only an aggregation 
with grouping keys
+   *    under whole-stage codegen computes it lazily, so this is conservative 
for the others,
+   *    e.g. a global aggregation or an `ObjectHashAggregateExec`.
+   *
+   * These operators pass such columns of their children through:
+   *  - [[Filter]] and [[Sample]].
+   *  - [[LocalLimit]], [[GlobalLimit]] and [[Offset]]. A global limit or an 
offset passes them
+   *    through only when its input has a single partition; otherwise the 
exchange below it
+   *    computes every column, and this is conservative.
+   *  - [[Join]], from both sides. Only the streamed side of a hash join 
passes them through, so
+   *    this is conservative for the others.
+   *
+   * Other columns and operators do not count:
+   *  - A non-deterministic column, computed for every row the operator 
outputs, and the grouping
+   *    keys and aggregate functions of an aggregation, computed on every row 
it gets.
+   *  - The columns through any other operator, e.g. a `Union`, `Generate`, 
`Deduplicate`,
+   *    `Sort`, `Window` or `Repartition`, whose input rows get every column 
computed.
+   *    `FinishAnalysis`, the first batch of the optimizer, removes 
`SubqueryAlias` and

Review Comment:
   nit: `FinishAnalysis` is not the first optimizer batch: `Convert python UDFs 
to Catalyst` runs before it. Maybe just say it runs before 
`InferFiltersFromConstraints`.



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