Github user gatorsmile commented on the issue:
https://github.com/apache/spark/pull/21443
For the following query, we could see the performance regression
```SQL
SELECT sum(DISTINCT x), avg(DISTINCT x)
FROM (VALUES (1, 1), (2, 2), (2, 2)) t(x, y)
```
Before this PR:
```
== Optimized Logical Plan ==
Aggregate [sum(distinct cast(x#189 as bigint)) AS sum(DISTINCT x)#193L,
avg(distinct cast(x#189 as bigint)) AS avg(DISTINCT x)#194]
+- LocalRelation [x#189]
```
After this PR
```
== Optimized Logical Plan ==
Aggregate [sum(if ((gid#195 = 1)) CAST(`x` AS BIGINT)#196L else null) AS
sum(DISTINCT x)#193L, avg(if ((gid#195 = 1)) CAST(`x` AS BIGINT)#196L else
null) AS avg(DISTINCT x)#194]
+- Aggregate [CAST(`x` AS BIGINT)#196L, gid#195], [CAST(`x` AS
BIGINT)#196L, gid#195]
+- Expand [List(cast(x#189 as bigint), 1)], [CAST(`x` AS BIGINT)#196L,
gid#195]
+- LocalRelation [x#189]
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]