/** * Returns SQL function call string of the format {@code functionName(argument1, argument2, argument3, ...)} */ default String getSqlFunctionCallString(FunctionCall functionCall) { return functionCall.getFunctionName() + "(" + IntStream.range(0, functionCall.getParameters().size()) .mapToObj(idx -> getFunctionCallArgumentString(functionCall.getParameters().get(idx), functionCall.getInferredParameterTypes().get(idx))) .collect(Collectors.joining(", ")) + ")"; }
/** * Returns SQL function call string of the format {@code functionName(argument1, argument2, argument3, ...)} */ default String getSqlFunctionCallString(FunctionCall functionCall) { return functionCall.getFunctionName() + "(" + IntStream.range(0, functionCall.getParameters().size()) .mapToObj(idx -> getFunctionCallArgumentString(functionCall.getParameters().get(idx), functionCall.getInferredParameterTypes().get(idx))) .collect(Collectors.joining(", ")) + ")"; }
private Pair<TestType, Object> resolveFunctionCall(FunctionCall call) { GenericStdUDFWrapper wrapper = _functionNameToWrapperMap.get(call.getFunctionName()); if (wrapper == null) { throw new RuntimeException("Could not find UDF with name " + call.getFunctionName()); } List<TestType> resolvedParameterTypes = new ArrayList<>(); List<Object> resolvedParameters = new ArrayList<>(); // If any of the parameters has a function call, resolve the type and value of the nested function call first IntStream.range(0, call.getInferredParameterTypes().size()).forEach(idx -> { Pair<TestType, Object> result = resolveParameter(call.getParameters().get(idx), call.getInferredParameterTypes().get(idx)); resolvedParameterTypes.add(result.getLeft()); resolvedParameters.add(result.getRight()); }); TestType outputType = wrapper.initialize(resolvedParameterTypes.toArray(new TestType[0])); Object result = wrapper.evaluate(resolvedParameters.toArray(new Object[0])); return Pair.of(outputType, result); }