You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/10/23 07:05:05 UTC

[GitHub] [calcite] weidong3630 edited a comment on issue #1422: [CALCITE-3300] Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

weidong3630 edited a comment on issue #1422: [CALCITE-3300] Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"
URL: https://github.com/apache/calcite/pull/1422#issuecomment-545300895
 
 
   @jinxing64 Like @julianhyde said,
   Calcite allows multiple arguments to COUNT. It counts a row if none of the arguments are NULL:
   > select count(x, y), count(x), count(y), count(*)
   > from (values (1, 2),
   >    (3, CAST(NULL AS INTEGER))) as t (x, y);
   +-----------------+-----------------+-----------------+-----------------+
   |     EXPR$0      |     EXPR$1      |     EXPR$2      |     EXPR$3      |
   +-----------------+-----------------+-----------------+-----------------+
   | 1               | 2               | 1               | 2               |
   +-----------------+-----------------+-----------------+-----------------+
   It is a natural generalization to make COUNT() identical to COUNT(*). So that's how Calcite represents COUNT(*) internally. 
   
   So the meaning of `count(*)` and counting first column are not always same because that the element of the first column may be null which will effect the result. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services