[ 
https://issues.apache.org/jira/browse/SPARK-31421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Filipe Oliveira resolved SPARK-31421.
-------------------------------------
    Resolution: Fixed

In Spark 4.3.0 normalize is working for ScalarSubquery

> 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
>            Priority: Major
>
> 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
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to