You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/03/22 17:26:43 UTC
[GitHub] [spark] sigmod commented on pull request #32298: [SPARK-34079][SQL] Merge non-correlated scalar subqueries
sigmod commented on pull request #32298:
URL: https://github.com/apache/spark/pull/32298#issuecomment-1075406139
One high level comment.
Does it make sense to implement the rewrite in the following way?
```
SELECT
(SELECT avg(a) FROM t GROUP BY b),
(SELECT sum(b) FROM t GROUP BY b)
FROM T
```
=>
```
WITH cte AS (SELECT avg(a) a, sum(b) b FROM t GROUP BY b)
SELECT (SELECT a FROM cte), (SELECT b FROM cte)
FROM T
```
Since we already have [WithCTE](https://github.com/apache/spark/blob/efe43306fcab18f076f755c81c0406ebc1a5fee9/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala#L703-L710) and [CTERelationRef](https://github.com/apache/spark/blob/efe43306fcab18f076f755c81c0406ebc1a5fee9/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala#L678-L686), the rewrite looks similar to what you want to achieve, while do not need to add yet-another Logical/Exec node?
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org