peter-toth commented on code in PR #52149: URL: https://github.com/apache/spark/pull/52149#discussion_r2321586724
########## sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/CollapseProjectSuite.scala: ########## @@ -298,4 +298,20 @@ class CollapseProjectSuite extends PlanTest { comparePlans(optimized, expected) } } + + test("SPARK-53399: Merge expressions") { + val query = testRelation + .select($"a" + 1 as "a_plus_1", $"b" + 1 as "b_plus_1") + .select($"a_plus_1" + $"a_plus_1", $"b_plus_1") + .analyze + + val optimized = Optimize.execute(query) + + val expected = testRelation + .select($"a" + 1 as "a_plus_1", $"b") + .select($"a_plus_1" + $"a_plus_1", $"b" + 1 as "b_plus_1") Review Comment: Yeah, indeed this is tough. So shall we just force combining adjacent projects (when everything in them is deterministic) in a group of projects, if there is a parent project in the group with python UDFs? Let me come up with something... -- 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