mdayakar commented on code in PR #5084: URL: https://github.com/apache/hive/pull/5084#discussion_r1499390595
########## hplsql/src/main/java/org/apache/hive/hplsql/functions/InMemoryFunctionRegistry.java: ########## @@ -132,39 +133,84 @@ private boolean execProc(String name, HplsqlParser.Expr_func_paramsContext ctx) /** * Set parameters for user-defined function call */ - public static void setCallParameters(String procName, HplsqlParser.Expr_func_paramsContext actual, ArrayList<Var> actualValues, - HplsqlParser.Create_routine_paramsContext formal, - HashMap<String, Var> out, - Exec exec) { - if (actual == null || actual.func_param() == null || actualValues == null) { + public static void setCallParameters(String procName, HplsqlParser.Expr_func_paramsContext actual, + ArrayList<Var> actualValues, HplsqlParser.Create_routine_paramsContext formal, HashMap<String, Var> out, + Exec exec) { + // if it is a non-parameter function then just return. + if (actual == null && formal == null) { return; } - int actualCnt = actualValues.size(); - int formalCnt = formal.create_routine_param_item().size(); - if (formalCnt != actualCnt) { - throw new ArityException(actual.getParent(), procName, formalCnt, actualCnt); + int actualCnt = (actualValues == null) ? 0 : actualValues.size(); + int passedParamCnt = actualCnt; + List<HplsqlParser.Create_routine_param_itemContext> routineParamItem = formal.create_routine_param_item(); + int formalCnt = routineParamItem.size(); + ParserRuleContext ruleContext = (actual == null) ? null : actual.getParent(); Review Comment: Both `actualValues` and `actual` either will be null or non-null at the same time. Earlier if they are null they are just returning from `setCallParameters()` API but that was wrong as even procedure has params but user didn't pass anything it won't throw exception so that is corrected now. Also now we need to handle default parameters, if procedure has default params and user didn't pass any param then we should take default value for those params. If there is any mismatch between procedure actual params and passed params by considering default params we throw exception, while throwing exception earlier it was passed `actual.getParent()` to the exception constructor, earlier if actual is null then just returning from method so actual can not be null if flow comes to throwing exception but now we need to handle default params also so in this case actual can be null so just added null check. -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org