You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/08/30 08:31:09 UTC

[GitHub] [druid] FrankChen021 commented on a diff in pull request #12995: more consistent expression error messages

FrankChen021 commented on code in PR #12995:
URL: https://github.com/apache/druid/pull/12995#discussion_r958175376


##########
core/src/main/java/org/apache/druid/math/expr/ApplyFunction.java:
##########
@@ -105,6 +103,44 @@ default boolean hasArrayOutput(LambdaExpr lambdaExpr)
    */
   void validateArguments(LambdaExpr lambdaExpr, List<Expr> args);
 
+  /**
+   * Check that the argument list is the expected size. The list of arguments should not include the
+   * {@link LambdaExpr} and so the error message will indicate that count + 1 arguments are required.
+   */
+  default void validateArgumentCount(LambdaExpr lambdaExpr, List<Expr> args, int count)
+  {
+    if (args.size() != count) {
+      throw new ValidationException(this, "needs %s arguments", count + 1);
+    }
+    if (args.size() != lambdaExpr.identifierCount()) {
+      throw new ValidationException(
+          this,
+          "lambda expression argument count of %s does not match count of %s arguments passed to it ",

Review Comment:
   Shouldn't `%s` be `%d`?



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org