GitHub user cloud-fan opened a pull request:

    https://github.com/apache/spark/pull/22696

    [SPARK-25708][SQL] HAVING without GROUP BY means global aggregate

    ## What changes were proposed in this pull request?
    
    According to the SQL standard, when a query contains `HAVING`, it indicates 
an aggregate operator. For more details please refer to 
https://blog.jooq.org/2014/12/04/do-you-really-understand-sqls-group-by-and-having-clauses/
    
    However, in Spark SQL parser, we treat HAVING as a normal filter when there 
is no GROUP BY, which breaks SQL semantic and lead to wrong result. This PR 
fixes the parser.
    
    ## How was this patch tested?
    
    new test

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cloud-fan/spark having

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/22696.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #22696
    
----
commit f33400d118c120db54e7155f2b03459177b10194
Author: Wenchen Fan <wenchen@...>
Date:   2018-10-11T11:48:30Z

    HAVING without GROUP BY means global aggregate

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to