cloud-fan commented on code in PR #32987: URL: https://github.com/apache/spark/pull/32987#discussion_r1948345527
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala: ########## @@ -255,4 +304,26 @@ case class ExpressionEquals(e: Expression) { * Instead of appending to a mutable list/buffer of Expressions, just update the "flattened" * useCount in this wrapper in-place. */ -case class ExpressionStats(expr: Expression)(var useCount: Int) +case class ExpressionStats(expr: Expression)( + var useCount: Int = 1, + var conditionalUseCount: Int = 0) { + def getUseCount(): Int = if (useCount > 0) { + useCount + conditionalUseCount + } else { + 0 + } +} + +/** + * A wrapper for the different types of children of expressions. `alwaysChildren` are child + * expressions that will always be evaluated and should be considered for subexpressions. + * `commonChildren` are children such that if there are any common expressions among them, those + * should be considered for subexpressions. `conditionalChildren` are children that are + * conditionally evaluated, such as in If, CaseWhen, or Coalesce expressions, and should only + * be considered for subexpressions if they are evaluated non-conditionally elsewhere. + */ +case class RecurseChildren( + alwaysChildren: Seq[Expression], + commonChildren: Seq[Seq[Expression]] = Nil, Review Comment: do we have an example this `commonChildren`? -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org