You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2018/06/01 18:46:14 UTC

[GitHub] spark issue #21443: [SPARK-24369][SQL] Correct handling for multiple distinc...

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: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org