Esempio n. 1
0
 public void lookupOperatorOverloads(
     final SqlIdentifier opName,
     SqlFunctionCategory category,
     SqlSyntax syntax,
     List<SqlOperator> operatorList) {
   if (syntax != SqlSyntax.FUNCTION) {
     return;
   }
   final Collection<Function> functions = getFunctionsFrom(opName.names);
   if (functions.isEmpty()) {
     return;
   }
   operatorList.addAll(
       Collections2.transform(
           functions,
           new com.google.common.base.Function<Function, SqlOperator>() {
             public SqlOperator apply(Function function) {
               return toOp(opName, function);
             }
           }));
 }
Esempio n. 2
0
 private Collection<Function> getFunctionsFrom(List<String> names) {
   final List<Function> functions2 = Lists.newArrayList();
   final List<? extends List<String>> schemaNameList;
   if (names.size() > 1) {
     // If name is qualified, ignore path.
     schemaNameList = ImmutableList.of(ImmutableList.<String>of());
   } else {
     OptiqSchema schema = getSchema(defaultSchema);
     if (schema == null) {
       schemaNameList = ImmutableList.of();
     } else {
       schemaNameList = schema.getPath();
     }
   }
   for (List<String> schemaNames : schemaNameList) {
     OptiqSchema schema = getSchema(Iterables.concat(schemaNames, Util.skipLast(names)));
     if (schema != null) {
       final String name = Util.last(names);
       functions2.addAll(schema.getFunctions(name, true));
     }
   }
   return functions2;
 }