Yuming Wang created SPARK-31421: ----------------------------------- Summary: transformAllExpressions can not transform expressions in ScalarSubquery Key: SPARK-31421 URL: https://issues.apache.org/jira/browse/SPARK-31421 Project: Spark Issue Type: Bug Components: SQL Affects Versions: 3.1.0 Reporter: Yuming Wang
Example: {code:scala} spark.sql("CREATE TABLE t1 (c1 bigint, c2 bigint)") val sqlStr = "SELECT COUNT(*) FROM t1 HAVING SUM(c1) > (SELECT AVG(c2) FROM t1)" println(normalizeExprIds(spark.sql(sqlStr).queryExecution.optimizedPlan).treeString) {code} The output: {noformat} Project [count(1)#0L] +- Filter (isnotnull(sum(c1#2L)#0L) AND (cast(sum(c1#2L)#0L as double) > scalar-subquery#0 [])) : +- Aggregate [avg(c2#3L) AS avg(c2)#6] : +- Project [c2#3L] : +- Relation[c1#2L,c2#3L] parquet +- Aggregate [count(1) AS count(1)#0L, sum(c1#0L) AS sum(c1#2L)#0L] +- Project [c1#0L] +- Relation[c1#0L,c2#0L] parquet {noformat} Another example query: https://github.com/apache/spark/blob/master/sql/core/src/test/resources/tpcds/q14b.sql -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org