use of org.apache.calcite.sql.type.AssignableOperandTypeChecker in project calcite by apache.
the class SqlValidatorImpl method handleUnresolvedFunction.
public CalciteException handleUnresolvedFunction(SqlCall call, SqlFunction unresolvedFunction, List<RelDataType> argTypes, List<String> argNames) {
// For builtins, we can give a better error message
final List<SqlOperator> overloads = new ArrayList<>();
opTab.lookupOperatorOverloads(unresolvedFunction.getNameAsId(), null, SqlSyntax.FUNCTION, overloads);
if (overloads.size() == 1) {
SqlFunction fun = (SqlFunction) overloads.get(0);
if ((fun.getSqlIdentifier() == null) && (fun.getSyntax() != SqlSyntax.FUNCTION_ID)) {
final int expectedArgCount = fun.getOperandCountRange().getMin();
throw newValidationError(call, RESOURCE.invalidArgCount(call.getOperator().getName(), expectedArgCount));
}
}
AssignableOperandTypeChecker typeChecking = new AssignableOperandTypeChecker(argTypes, argNames);
String signature = typeChecking.getAllowedSignatures(unresolvedFunction, unresolvedFunction.getName());
throw newValidationError(call, RESOURCE.validatorUnknownFunction(signature));
}
use of org.apache.calcite.sql.type.AssignableOperandTypeChecker in project flink by apache.
the class SqlValidatorImpl method handleUnresolvedFunction.
public CalciteException handleUnresolvedFunction(SqlCall call, SqlFunction unresolvedFunction, List<RelDataType> argTypes, List<String> argNames) {
// For builtins, we can give a better error message
final List<SqlOperator> overloads = new ArrayList<>();
opTab.lookupOperatorOverloads(unresolvedFunction.getNameAsId(), null, SqlSyntax.FUNCTION, overloads, catalogReader.nameMatcher());
if (overloads.size() == 1) {
SqlFunction fun = (SqlFunction) overloads.get(0);
if ((fun.getSqlIdentifier() == null) && (fun.getSyntax() != SqlSyntax.FUNCTION_ID)) {
final int expectedArgCount = fun.getOperandCountRange().getMin();
throw newValidationError(call, RESOURCE.invalidArgCount(call.getOperator().getName(), expectedArgCount));
}
}
AssignableOperandTypeChecker typeChecking = new AssignableOperandTypeChecker(argTypes, argNames);
String signature = typeChecking.getAllowedSignatures(unresolvedFunction, unresolvedFunction.getName());
throw newValidationError(call, RESOURCE.validatorUnknownFunction(signature));
}
Aggregations