dongjoon-hyun edited a comment on issue #27233: [SPARK-29701][SQL] Correct 
behaviours of group analytical queries when empty input given
URL: https://github.com/apache/spark/pull/27233#issuecomment-577487224
 
 
   @tgravescs . Yes, it does. However, this is correctly a **SQL correctness** 
issue.
   
   Technically, among them, `PostgreSQL` is the only one implementing it 
according to the SQL standard. `SQL:1999` defines `()` as the `grand total` and 
the query is translated into the following roughly.
   
   ```sql
   ... (other clause)
   UNION ALL
   SELECT CAST(NULL AS DTPC1) AS CNPC1, CAST(NULL AS DTPC2) AS CNPC2, ...  # 
`grand total`
   FROM ...
   ```
   
   The test case in this PR description has been used in PostgreSQL community 
from the beginning of its `Support GROUPING SETS, CUBE and ROLLUP` commit (May 
15, 2015)
   - 
https://github.com/postgres/postgres/commit/f3d3118532175541a9a96ed78881a3b04a057128#diff-3472ecc50256022c66e79b1aad4075d2R78
   
   As another DBMS, `Presto` supports this like `PostgreSQL`.
   ```
   presto:default> create table gstest_empty (a integer, b integer, v integer);
   CREATE TABLE
   presto:default> select a, b, sum(v), count(*) from gstest_empty group by 
grouping sets ((a,b),());
     a   |  b   | _col2 | _col3
   ------+------+-------+-------
    NULL | NULL |  NULL |     0
   (1 row)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to