asolimando commented on code in PR #2782:
URL: https://github.com/apache/calcite/pull/2782#discussion_r859904868


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlDatePartFunction.java:
##########
@@ -56,6 +58,11 @@ public SqlDatePartFunction(String name, TimeUnit timeUnit) {
 
   @Override public SqlNode rewriteCall(SqlValidator validator, SqlCall call) {
     final List<SqlNode> operands = call.getOperandList();
+
+    Preconditions.checkArgument(operands.size() == 1,
+        String.format("Invalid number of arguments to function '%s'."
+            + " Was expecting 1 arguments", getName()));

Review Comment:
   It's better to be consistent, you are right, in such a case let's use that 
exception directly (like 
[here](https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L1932-L1934)).
   
   This will also address the forbiddenapi issue, `String#format()` by default 
does not respect the LOCALE IIRC.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to