weidong3630 commented 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 is not always the 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: [email protected] With regards, Apache Git Services
