mgaido91 commented on a change in pull request #25204:
[SPARK-28441][SQL][Python] Fix error when non-foldable expression is used in
correlated scalar subquery
URL: https://github.com/apache/spark/pull/25204#discussion_r307201213
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -650,7 +650,9 @@ object ColumnPruning extends Rule[LogicalPlan] {
*/
private def removeProjectBeforeFilter(plan: LogicalPlan): LogicalPlan = plan
transformUp {
case p1 @ Project(_, f @ Filter(_, p2 @ Project(_, child)))
- if p2.outputSet.subsetOf(child.outputSet) =>
+ if p2.outputSet.subsetOf(child.outputSet) &&
+ // We only remove attribute-only project.
+ p2.projectList.forall(_.isInstanceOf[AttributeReference]) =>
Review comment:
Mmmmh... I may be missing something, but I'd imagine a case like this:
```
select a, b from
(select a, b, very_expensive_operation as c from ... where a = 1)
```
Before this change, would be optimized as:
```
select a, b from
(select a, b from ... where a = 1)
```
while after it is not. Am I wrong?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]