public List<SqlMoniker> getAllSchemaObjectNames(List<String> names) { List<SqlMoniker> result; switch (names.size()) { case 0: // looking for schema names result = new ArrayList<SqlMoniker>(); for (MockSchema schema : schemas.values()) { result.add(new SqlMonikerImpl(schema.name, SqlMonikerType.Schema)); } return result; case 1: // looking for table names in the given schema MockSchema schema = schemas.get(names.get(0)); if (schema == null) { return Collections.emptyList(); } result = new ArrayList<SqlMoniker>(); for (String tableName : schema.tableNames) { result.add(new SqlMonikerImpl(tableName, SqlMonikerType.Table)); } return result; default: return Collections.emptyList(); } }
protected RexNode register(RexNode expr) { final String key = expr.toString(); final RexNode previous = mapDigestToExpr.put(key, expr); if (!allowDups && (previous != null)) { throw new SubExprExistsException(expr); } return expr; }
public List<SqlMoniker> getAllSchemaObjectNames(List<String> names) { final OptiqSchema schema = getSchema(names); if (schema == null) { return ImmutableList.of(); } final List<SqlMoniker> result = new ArrayList<SqlMoniker>(); final Map<String, OptiqSchema> schemaMap = schema.getSubSchemaMap(); for (String subSchema : schemaMap.keySet()) { result.add(new SqlMonikerImpl(schema.path(subSchema), SqlMonikerType.SCHEMA)); } for (String table : schema.getTableNames()) { result.add(new SqlMonikerImpl(schema.path(table), SqlMonikerType.TABLE)); } final NavigableSet<String> functions = schema.getFunctionNames(); for (String function : functions) { // views are here as well result.add(new SqlMonikerImpl(schema.path(function), SqlMonikerType.FUNCTION)); } return result; }
protected RexNode lookup(RexNode expr) { return mapDigestToExpr.get(expr.toString()); }
protected void registerSchema(MockSchema schema) { schemas.put(schema.name, schema); }