Jackie-Jiang commented on code in PR #13573:
URL: https://github.com/apache/pinot/pull/13573#discussion_r1681591275


##########
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:
   It's a little bit tricky though because the matches could be done via the 
type inference. We can probably add some usage info within each 
`PinotScalarFunction` which can be lookup up in the `FunctionRegistry`. Added a 
TODO to follow up



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

Reply via email to