cloud-fan commented on code in PR #49202:
URL: https://github.com/apache/spark/pull/49202#discussion_r1897209992
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/RewriteWithExpression.scala:
##########
@@ -96,14 +96,22 @@ object RewriteWithExpression extends Rule[LogicalPlan] {
val defs = w.defs.map(rewriteWithExprAndInputPlans(_, inputPlans,
isNestedWith = true))
val refToExpr = mutable.HashMap.empty[CommonExpressionId, Expression]
val childProjections =
Array.fill(inputPlans.length)(mutable.ArrayBuffer.empty[Alias])
+ val refsCount = child.collect {
+ case r: CommonExpressionRef
+ if defs.exists {
+ case d: CommonExpressionDef => d.id == r.id
Review Comment:
nit: we can create an id set to avoid repeated linear search.
--
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]