julianhyde commented on a change in pull request #2210:
URL: https://github.com/apache/calcite/pull/2210#discussion_r503614710
##########
File path:
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java
##########
@@ -477,4 +477,16 @@ private SqlLibraryOperators() {
public static final SqlOperator INFIX_CAST =
new SqlCastOperator();
+ /** The "COUNTIF(expression) [OVER (...)]" function;
+ * Returns the count of TRUE values for expression. Returns 0 if there are
+ * zero input rows, or if expression evaluates to FALSE or NULL for all rows.
+ */
+ @LibraryOperator(libraries = {BIG_QUERY})
+ public static final SqlFunction COUNTIF =
+ new SqlFunction("COUNTIF", SqlKind.OTHER_FUNCTION,
+ ReturnTypes.BIGINT_NULLABLE,
+ null,
+ OperandTypes.BOOLEAN,
+ SqlFunctionCategory.SYSTEM);
+
Review comment:
I'm a bit surprised that you were able to get this to work as a
sub-class of SqlFunction. I'd have thought SqlAggFunction.
One useful test would be a validator test something like `select sum(sal),
countif(sal > 100) from emp group by deptno`. Will pass if `countif` is
correctly being registered as an agg function. Will fail if `countif` is a
regular function.
##########
File path: core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
##########
@@ -752,6 +752,7 @@ private JdbcToInternalLookupTable() {
return super.createCall(pos, operands);
}
});
+ map.put("COUNTIF", simple(SqlLibraryOperators.COUNTIF));
Review comment:
Probably don't need COUNTIF in `SqlJdbcFunctionCall`. This class is just
for the `{fn COUNTIF()}` syntax, which few people use.
----------------------------------------------------------------
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]