public CalciteSchema add(String name, Schema schema) { final CalciteSchema calciteSchema = new SimpleCalciteSchema(this, schema, name); subSchemaMap.put(name, calciteSchema); return calciteSchema; }
protected TableEntry getImplicitTable(String tableName, boolean caseSensitive) { // Check implicit tables. Table table = schema.getTable(tableName); if (table != null) { return tableEntry(tableName, table); } return null; }
protected TypeEntry getImplicitType(String name, boolean caseSensitive) { // Check implicit types. RelProtoDataType type = schema.getType(name); if (type != null) { return typeEntry(name, type); } return null; }
protected CalciteSchema snapshot(CalciteSchema parent, SchemaVersion version) { CalciteSchema snapshot = new SimpleCalciteSchema(parent, schema.snapshot(version), name, null, tableMap, latticeMap, typeMap, functionMap, functionNames, nullaryFunctionMap, getPath()); for (CalciteSchema subSchema : subSchemaMap.map().values()) { CalciteSchema subSchemaSnapshot = subSchema.snapshot(snapshot, version); snapshot.subSchemaMap.put(subSchema.name, subSchemaSnapshot); } return snapshot; }
@Override public SchemaPlus plus() { return super.plus(); }
protected CalciteSchema snapshot(CalciteSchema parent, SchemaVersion version) { CalciteSchema snapshot = new SimpleCalciteSchema(parent, schema.snapshot(version), name, null, tableMap, latticeMap, typeMap, functionMap, functionNames, nullaryFunctionMap, getPath()); for (CalciteSchema subSchema : subSchemaMap.map().values()) { CalciteSchema subSchemaSnapshot = subSchema.snapshot(snapshot, version); snapshot.subSchemaMap.put(subSchema.name, subSchemaSnapshot); } return snapshot; }
public CalciteSchema add(String name, Schema schema) { final CalciteSchema calciteSchema = new SimpleCalciteSchema(this, schema, name); subSchemaMap.put(name, calciteSchema); return calciteSchema; }
protected TableEntry getImplicitTable(String tableName, boolean caseSensitive) { // Check implicit tables. Table table = schema.getTable(tableName); if (table != null) { return tableEntry(tableName, table); } return null; }
protected TypeEntry getImplicitType(String name, boolean caseSensitive) { // Check implicit types. RelProtoDataType type = schema.getType(name); if (type != null) { return typeEntry(name, type); } return null; }
protected CalciteSchema getImplicitSubSchema(String schemaName, boolean caseSensitive) { // Check implicit schemas. Schema s = schema.getSubSchema(schemaName); if (s != null) { return new SimpleCalciteSchema(this, s, schemaName); } return null; }
protected TableEntry getImplicitTableBasedOnNullaryFunction(String tableName, boolean caseSensitive) { Collection<Function> functions = schema.getFunctions(tableName); if (functions != null) { for (Function function : functions) { if (function instanceof TableMacro && function.getParameters().isEmpty()) { final Table table = ((TableMacro) function).apply(ImmutableList.of()); return tableEntry(tableName, table); } } } return null; }
protected CalciteSchema getImplicitSubSchema(String schemaName, boolean caseSensitive) { // Check implicit schemas. Schema s = schema.getSubSchema(schemaName); if (s != null) { return new SimpleCalciteSchema(this, s, schemaName); } return null; }
protected TableEntry getImplicitTableBasedOnNullaryFunction(String tableName, boolean caseSensitive) { Collection<Function> functions = schema.getFunctions(tableName); if (functions != null) { for (Function function : functions) { if (function instanceof TableMacro && function.getParameters().isEmpty()) { final Table table = ((TableMacro) function).apply(ImmutableList.of()); return tableEntry(tableName, table); } } } return null; }
/** Creates a root schema. * * @param addMetadataSchema Whether to add a "metadata" schema containing * definitions of tables, columns etc. * @param cache If true create {@link CachingCalciteSchema}; * if false create {@link SimpleCalciteSchema} * @param name Schema name */ public static CalciteSchema createRootSchema(boolean addMetadataSchema, boolean cache, String name) { CalciteSchema rootSchema; final Schema schema = new CalciteConnectionImpl.RootSchema(); if (cache) { rootSchema = new CachingCalciteSchema(null, schema, name); } else { rootSchema = new SimpleCalciteSchema(null, schema, name); } if (addMetadataSchema) { rootSchema.add("metadata", MetadataSchema.INSTANCE); } return rootSchema; }
/** Creates a root schema. * * @param addMetadataSchema Whether to add a "metadata" schema containing * definitions of tables, columns etc. * @param cache If true create {@link CachingCalciteSchema}; * if false create {@link SimpleCalciteSchema} * @param name Schema name */ public static CalciteSchema createRootSchema(boolean addMetadataSchema, boolean cache, String name) { CalciteSchema rootSchema; final Schema schema = new CalciteConnectionImpl.RootSchema(); if (cache) { rootSchema = new CachingCalciteSchema(null, schema, name); } else { rootSchema = new SimpleCalciteSchema(null, schema, name); } if (addMetadataSchema) { rootSchema.add("metadata", MetadataSchema.INSTANCE); } return rootSchema; }
protected void addImplicitSubSchemaToBuilder( ImmutableSortedMap.Builder<String, CalciteSchema> builder) { ImmutableSortedMap<String, CalciteSchema> explicitSubSchemas = builder.build(); for (String schemaName : schema.getSubSchemaNames()) { if (explicitSubSchemas.containsKey(schemaName)) { // explicit subschema wins. continue; } Schema s = schema.getSubSchema(schemaName); if (s != null) { CalciteSchema calciteSchema = new SimpleCalciteSchema(this, s, schemaName); builder.put(schemaName, calciteSchema); } } }
protected void addImplicitSubSchemaToBuilder( ImmutableSortedMap.Builder<String, CalciteSchema> builder) { ImmutableSortedMap<String, CalciteSchema> explicitSubSchemas = builder.build(); for (String schemaName : schema.getSubSchemaNames()) { if (explicitSubSchemas.containsKey(schemaName)) { // explicit subschema wins. continue; } Schema s = schema.getSubSchema(schemaName); if (s != null) { CalciteSchema calciteSchema = new SimpleCalciteSchema(this, s, schemaName); builder.put(schemaName, calciteSchema); } } }