maropu commented on a change in pull request #29585:
URL: https://github.com/apache/spark/pull/29585#discussion_r490635004
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/subquery.scala
##########
@@ -342,11 +342,12 @@ object RewriteCorrelatedScalarSubquery extends
Rule[LogicalPlan] {
*/
private def extractCorrelatedScalarSubqueries[E <: Expression](
expression: E,
- subqueries: ArrayBuffer[ScalarSubquery]): E = {
+ subqueries: ArrayBuffer[(ScalarSubquery, ExprId)]): E = {
val newExpression = expression transform {
case s: ScalarSubquery if s.children.nonEmpty =>
- subqueries += s
- s.plan.output.head
+ val newExprId = NamedExpression.newExprId
+ subqueries += s -> newExprId
+ s.plan.output.head.withExprId(newExprId)
Review comment:
> BTW I feel it's more natural to replace attributes after the subquery
rewriting, instead of generating the expr id here.
Yea, that refactoring looks reasonable and the current logic (top-down
rewriting) looks a bit weird. But, I wanna keep the current logic in this PR in
order to avoid making new bugs. Is it okay to do it in a separate PR?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]