private static boolean matches( RelDataTypeFactory typeFactory, TableFunction member, List<RelDataType> argumentTypes) { List<Parameter> parameters = member.getParameters(); if (parameters.size() != argumentTypes.size()) { return false; } for (int i = 0; i < argumentTypes.size(); i++) { RelDataType argumentType = argumentTypes.get(i); Parameter parameter = parameters.get(i); if (!canConvert(argumentType, parameter.getType(typeFactory))) { return false; } } return true; }
public static OptiqSchema.TableFunctionEntry resolve( RelDataTypeFactory typeFactory, String name, Collection<OptiqSchema.TableFunctionEntry> tableFunctions, List<RelDataType> argumentTypes) { final List<OptiqSchema.TableFunctionEntry> matches = new ArrayList<OptiqSchema.TableFunctionEntry>(); for (OptiqSchema.TableFunctionEntry member : tableFunctions) { if (matches(typeFactory, member.getTableFunction(), argumentTypes)) { matches.add(member); } } switch (matches.size()) { case 0: return null; case 1: return matches.get(0); default: throw new RuntimeException( "More than one match for " + name + " with arguments " + argumentTypes); } }