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


##########
core/src/main/java/org/apache/druid/math/expr/ApplyFunction.java:
##########
@@ -114,6 +150,14 @@ default boolean hasArrayOutput(LambdaExpr lambdaExpr)
   @Nullable
   ExpressionType getOutputType(Expr.InputBindingInspector inspector, 
LambdaExpr expr, List<Expr> args);
 
+  class ValidationException extends IllegalArgumentException

Review Comment:
   It's nice to have a specific exception for validation!
   Do you think it would be better to have a single 
`ExpressionValidationException` that is used across Druid (or across all Druid 
expressions), rather than having separate `Function.ValidationException` and 
`ApplyFunction.ValidationException`?



##########
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)

Review Comment:
   I am not sure if `validateArgumentCount` and `validateMinArgCount` should be 
a part of the interface `ApplyFunction`. They should probably just be static 
utility methods.
   
   It makes sense to have `validateArguments` in the interface because it is a 
part of the general behaviour of a function to check if a given set of args is 
valid for that function. But validating argument count is probably too 
specific. For example, if in the future, we decide to validate other things, 
say the type of each of the args, etc, we would have to add another 
`validateArgumentType` method.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to