cloud-fan commented on code in PR #49202:
URL: https://github.com/apache/spark/pull/49202#discussion_r1897206348
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -1978,6 +1988,62 @@ object PushPredicateThroughNonJoin extends
Rule[LogicalPlan] with PredicateHelpe
case _ => false
}
}
+
+ /**
+ * Use [[With]] to rewrite condition which contains attribute that are not
cheap and be consumed
+ * multiple times. Each predicate generates one or 0 With. For facilitates
subsequent merge
+ * [[With]], use the same CommonExpressionDef ids for different [[With]].
+ */
+ private def rewriteConditionByWith(
+ cond: Seq[Expression],
+ aliasMap: AttributeMap[Alias]): Seq[Expression] = {
+ if (!SQLConf.get.getConf(SQLConf.ALWAYS_INLINE_COMMON_EXPR)) {
+ val canRewriteConf = cond.filter(canRewriteByWith)
+ if (canRewriteConf.nonEmpty) {
+ val replaceWithMap = canRewriteConf.reduce(And)
Review Comment:
we can do `canRewriteConf.flatMap(_.collect...)`
--
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]