gortiz commented on code in PR #13573: URL: https://github.com/apache/pinot/pull/13573#discussion_r1680792812
########## pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/operands/FunctionOperand.java: ########## @@ -47,9 +48,32 @@ public FunctionOperand(RexExpression.FunctionCall functionCall, DataSchema dataS _resultType = functionCall.getDataType(); List<RexExpression> operands = functionCall.getFunctionOperands(); int numOperands = operands.size(); - FunctionInfo functionInfo = FunctionRegistry.getFunctionInfo(functionCall.getFunctionName(), numOperands); - Preconditions.checkState(functionInfo != null, "Cannot find function with name: %s", - functionCall.getFunctionName()); + ColumnDataType[] argumentTypes = new ColumnDataType[numOperands]; + for (int i = 0; i < numOperands; i++) { + RexExpression operand = operands.get(i); + ColumnDataType argumentType; + if (operand instanceof RexExpression.InputRef) { + argumentType = dataSchema.getColumnDataType(((RexExpression.InputRef) operand).getIndex()); + } else if (operand instanceof RexExpression.Literal) { + argumentType = ((RexExpression.Literal) operand).getDataType(); + } else { + assert operand instanceof RexExpression.FunctionCall; + argumentType = ((RexExpression.FunctionCall) operand).getDataType(); + } + argumentTypes[i] = argumentType; + } + String functionName = functionCall.getFunctionName(); + String canonicalName = FunctionRegistry.canonicalize(functionName); + FunctionInfo functionInfo = FunctionRegistry.lookupFunctionInfo(canonicalName, argumentTypes); + if (functionInfo == null) { + if (FunctionRegistry.contains(canonicalName)) { + throw new IllegalArgumentException( + String.format("Unsupported function: %s with argument types: %s", functionName, + Arrays.toString(argumentTypes))); + } else { + throw new IllegalArgumentException(String.format("Unsupported function: %s", functionName)); + } + } Review Comment: Ideally we should also include the variants that were not selected. We could do that by adding a method in `FunctionRegistry` that returns all FunctionInfo for a given name and then showing these options here. I don't think it has to be added in this PR, but it is something that will be useful to debug problems -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org