dawidwys commented on a change in pull request #8345: [FLINK-12402][table] Make validation error message for CallExpression more user friendly URL: https://github.com/apache/flink/pull/8345#discussion_r283206493
########## File path: flink-table/flink-table-planner/src/main/java/org/apache/flink/table/expressions/rules/ResolveCallByArgumentsRule.java ########## @@ -86,21 +86,31 @@ private Expression performTypeResolution(CallExpression call, List<TypeInformati private Expression validateArguments(CallExpression call, PlannerExpression plannerCall) { if (!plannerCall.valid()) { - final String errorMessage; - ValidationResult validationResult = plannerCall.validateInput(); - if (validationResult instanceof ValidationFailure) { - errorMessage = ((ValidationFailure) validationResult).message(); - } else { - errorMessage = String.format("Invalid arguments %s for function: %s", - call.getChildren(), - call.getFunctionDefinition().getName()); - } - throw new ValidationException(errorMessage); + throw new ValidationException(getValidationErrorMessage(plannerCall)); } - return call; } + /** + * Return the validation error message of this {@link PlannerExpression} or return the + * validation error message of it's children if it passes the validation. Return an empty + * string if all validation succeeded. + */ + private String getValidationErrorMessage(PlannerExpression plannerCall) { Review comment: One small comment, let's use the `Optional` to mark that method might not return results. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services