Class CalciteSchema
- Direct Known Subclasses:
CalciteRootSchema
Wrapper around user-defined schema used internally.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Entry in a schema, such as a table or sub-schema.static class
Membership of a function in a schema.static class
Implementation ofCalciteSchema.FunctionEntry
where all properties are held in fields.static class
Membership of a lattice in a schema.static class
Implementation ofCalciteSchema.LatticeEntry
where all properties are held in fields.static class
Membership of a table in a schema.static class
Implementation ofCalciteSchema.TableEntry
where all properties are held in fields.static class
Membership of a type in a schema.static class
Implementation ofCalciteSchema.TypeEntry
where all properties are held in fields. -
Field Summary
Modifier and TypeFieldDescriptionprotected final NameMultimap<CalciteSchema.FunctionEntry>
protected final NameSet
protected final NameMap<CalciteSchema.LatticeEntry>
final String
protected final NameMap<CalciteSchema.FunctionEntry>
final Schema
protected final NameMap<CalciteSchema>
protected final NameMap<CalciteSchema.TableEntry>
Tables explicitly defined in this schema.protected final NameMap<CalciteSchema.TypeEntry>
-
Constructor Summary
ModifierConstructorDescriptionprotected
CalciteSchema
(@Nullable CalciteSchema parent, Schema schema, String name, @Nullable NameMap<CalciteSchema> subSchemaMap, @Nullable NameMap<CalciteSchema.TableEntry> tableMap, @Nullable NameMap<CalciteSchema.LatticeEntry> latticeMap, @Nullable NameMap<CalciteSchema.TypeEntry> typeMap, @Nullable NameMultimap<CalciteSchema.FunctionEntry> functionMap, @Nullable NameSet functionNames, @Nullable NameMap<CalciteSchema.FunctionEntry> nullaryFunctionMap, @Nullable List<? extends List<String>> path) -
Method Summary
Modifier and TypeMethodDescriptionadd
(String name, RelProtoDataType type) Defines a type within this schema.abstract CalciteSchema
Adds a child schema of this schema.Defines a table within this schema.Defines a table within this schema.protected abstract void
addImplicitFuncNamesToBuilder
(com.google.common.collect.ImmutableSortedSet.Builder<String> builder) Adds implicit function names to a builder.protected abstract void
addImplicitFunctionsToBuilder
(com.google.common.collect.ImmutableList.Builder<Function> builder, String name, boolean caseSensitive) Adds implicit functions to a builder.protected abstract void
addImplicitSubSchemaToBuilder
(com.google.common.collect.ImmutableSortedMap.Builder<String, CalciteSchema> builder) Adds implicit sub-schemas to a builder.protected abstract void
addImplicitTablesBasedOnNullaryFunctionsToBuilder
(com.google.common.collect.ImmutableSortedMap.Builder<String, Table> builder) Adds implicit table functions to a builder.protected abstract void
addImplicitTableToBuilder
(com.google.common.collect.ImmutableSortedSet.Builder<String> builder) Adds implicit tables to a builder.protected abstract void
addImplicitTypeNamesToBuilder
(com.google.common.collect.ImmutableSortedSet.Builder<String> builder) Adds implicit type names to a builder.static CalciteSchema
createRootSchema
(boolean addMetadataSchema) Creates a root schema.static CalciteSchema
createRootSchema
(boolean addMetadataSchema, boolean cache) Creates a root schema.static CalciteSchema
createRootSchema
(boolean addMetadataSchema, boolean cache, String name) Creates a root schema.static CalciteSchema
createRootSchema
(boolean addMetadataSchema, boolean cache, String name, Schema schema) createSnapshot
(SchemaVersion version) Creates a snapshot of this CalciteSchema as of the specified time.protected static <V> NavigableMap<String,
V> find
(NavigableMap<String, V> map, String s) Deprecated.use NameMapfind
(NavigableSet<String> set, String name) Deprecated.use NameSetstatic CalciteSchema
from
(SchemaPlus plus) final NavigableSet<String>
Returns the list of function names in this schema, both implicit and explicit, never null.final Collection<Function>
getFunctions
(String name, boolean caseSensitive) Returns a collection of all functions, explicit and implicit, with a given name.protected abstract @Nullable CalciteSchema
getImplicitSubSchema
(String schemaName, boolean caseSensitive) Returns a sub-schema with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toadd(String, Schema)
), or null.protected abstract @Nullable CalciteSchema.TableEntry
getImplicitTable
(String tableName, boolean caseSensitive) Returns a table with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toadd(String, Table)
), or null.protected abstract @Nullable CalciteSchema.TableEntry
getImplicitTableBasedOnNullaryFunction
(String tableName, boolean caseSensitive) Returns table function with a given name and zero arguments that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toadd(String, Function)
), or null.protected abstract @Nullable CalciteSchema.TypeEntry
getImplicitType
(String name, boolean caseSensitive) Returns a type with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toadd(String, RelProtoDataType)
), or null.Returns a collection of lattices.getName()
getPath()
Returns the default path resolving functions from this schema.final @Nullable CalciteSchema
getSubSchema
(String schemaName, boolean caseSensitive) final NavigableMap<String,
CalciteSchema> Returns a collection of sub-schemas, both explicit (defined usingadd(String, org.apache.calcite.schema.Schema)
) and implicit (defined usingSchema.getSubSchemaNames()
andSchema.getSubSchema(String)
).final @Nullable CalciteSchema.TableEntry
Returns a table with the given name.final @Nullable CalciteSchema.TableEntry
getTableBasedOnNullaryFunction
(String tableName, boolean caseSensitive) Returns a tables derived from explicit and implicit functions that take zero parameters.final @Nullable CalciteSchema.TableEntry
getTableBySql
(String sql) Returns a table that materializes the given SQL statement.final NavigableSet<String>
Returns the set of all table names.final NavigableMap<String,
Table> Returns tables derived from explicit and implicit functions that take zero parameters.final @Nullable CalciteSchema.TypeEntry
Returns a type, explicit and implicit, with a given name.final NavigableSet<String>
Returns the set of all types names.protected abstract boolean
boolean
isRoot()
Returns whether this is a root schema.Returns the path of an object in this schema.plus()
boolean
removeFunction
(String name) boolean
removeSubSchema
(String name) boolean
removeTable
(String name) boolean
removeType
(String name) root()
abstract void
setCache
(boolean cache) protected abstract CalciteSchema
snapshot
(@Nullable CalciteSchema parent, SchemaVersion version) Returns a snapshot representation of this CalciteSchema.protected CalciteSchema.TableEntryImpl
tableEntry
(String name, Table table) Creates a TableEntryImpl with no SQLs.protected CalciteSchema.TypeEntryImpl
typeEntry
(String name, RelProtoDataType relProtoDataType) Creates a TableEntryImpl with no SQLs.
-
Field Details
-
schema
-
name
-
tableMap
Tables explicitly defined in this schema. Does not include tables inschema
. -
functionMap
-
typeMap
-
latticeMap
-
functionNames
-
nullaryFunctionMap
-
subSchemaMap
-
-
Constructor Details
-
CalciteSchema
protected CalciteSchema(@Nullable CalciteSchema parent, Schema schema, String name, @Nullable NameMap<CalciteSchema> subSchemaMap, @Nullable NameMap<CalciteSchema.TableEntry> tableMap, @Nullable NameMap<CalciteSchema.LatticeEntry> latticeMap, @Nullable NameMap<CalciteSchema.TypeEntry> typeMap, @Nullable NameMultimap<CalciteSchema.FunctionEntry> functionMap, @Nullable NameSet functionNames, @Nullable NameMap<CalciteSchema.FunctionEntry> nullaryFunctionMap, @Nullable List<? extends List<String>> path)
-
-
Method Details
-
getImplicitSubSchema
protected abstract @Nullable CalciteSchema getImplicitSubSchema(String schemaName, boolean caseSensitive) Returns a sub-schema with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toadd(String, Schema)
), or null. -
getImplicitTable
protected abstract @Nullable CalciteSchema.TableEntry getImplicitTable(String tableName, boolean caseSensitive) Returns a table with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toadd(String, Table)
), or null. -
getImplicitType
protected abstract @Nullable CalciteSchema.TypeEntry getImplicitType(String name, boolean caseSensitive) Returns a type with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toadd(String, RelProtoDataType)
), or null. -
getImplicitTableBasedOnNullaryFunction
protected abstract @Nullable CalciteSchema.TableEntry getImplicitTableBasedOnNullaryFunction(String tableName, boolean caseSensitive) Returns table function with a given name and zero arguments that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toadd(String, Function)
), or null. -
addImplicitSubSchemaToBuilder
protected abstract void addImplicitSubSchemaToBuilder(com.google.common.collect.ImmutableSortedMap.Builder<String, CalciteSchema> builder) Adds implicit sub-schemas to a builder. -
addImplicitTableToBuilder
protected abstract void addImplicitTableToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<String> builder) Adds implicit tables to a builder. -
addImplicitFunctionsToBuilder
protected abstract void addImplicitFunctionsToBuilder(com.google.common.collect.ImmutableList.Builder<Function> builder, String name, boolean caseSensitive) Adds implicit functions to a builder. -
addImplicitFuncNamesToBuilder
protected abstract void addImplicitFuncNamesToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<String> builder) Adds implicit function names to a builder. -
addImplicitTypeNamesToBuilder
protected abstract void addImplicitTypeNamesToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<String> builder) Adds implicit type names to a builder. -
addImplicitTablesBasedOnNullaryFunctionsToBuilder
protected abstract void addImplicitTablesBasedOnNullaryFunctionsToBuilder(com.google.common.collect.ImmutableSortedMap.Builder<String, Table> builder) Adds implicit table functions to a builder. -
snapshot
Returns a snapshot representation of this CalciteSchema. -
isCacheEnabled
protected abstract boolean isCacheEnabled() -
setCache
public abstract void setCache(boolean cache) -
tableEntry
Creates a TableEntryImpl with no SQLs. -
typeEntry
Creates a TableEntryImpl with no SQLs. -
add
Defines a table within this schema. -
add
public CalciteSchema.TableEntry add(String tableName, Table table, com.google.common.collect.ImmutableList<String> sqls) Defines a table within this schema. -
add
Defines a type within this schema. -
root
-
isRoot
public boolean isRoot()Returns whether this is a root schema. -
path
Returns the path of an object in this schema. -
getSubSchema
-
add
Adds a child schema of this schema. -
getTableBySql
Returns a table that materializes the given SQL statement. -
getTable
Returns a table with the given name. Does not look for views. -
getName
-
plus
-
from
-
getPath
Returns the default path resolving functions from this schema.The path consists is a list of lists of strings. Each list of strings represents the path of a schema from the root schema. For example, [[], [foo], [foo, bar, baz]] represents three schemas: the root schema "/" (level 0), "/foo" (level 1) and "/foo/bar/baz" (level 3).
- Returns:
- Path of this schema; never null, may be empty
-
getSubSchemaMap
Returns a collection of sub-schemas, both explicit (defined usingadd(String, org.apache.calcite.schema.Schema)
) and implicit (defined usingSchema.getSubSchemaNames()
andSchema.getSubSchema(String)
). -
getLatticeMap
Returns a collection of lattices.All are explicit (defined using
add(String, Lattice)
). -
getTableNames
Returns the set of all table names. Includes implicit and explicit tables and functions with zero parameters. -
getTypeNames
Returns the set of all types names. -
getType
Returns a type, explicit and implicit, with a given name. Never null. -
getFunctions
Returns a collection of all functions, explicit and implicit, with a given name. Never null. -
getFunctionNames
Returns the list of function names in this schema, both implicit and explicit, never null. -
getTablesBasedOnNullaryFunctions
Returns tables derived from explicit and implicit functions that take zero parameters. -
getTableBasedOnNullaryFunction
public final @Nullable CalciteSchema.TableEntry getTableBasedOnNullaryFunction(String tableName, boolean caseSensitive) Returns a tables derived from explicit and implicit functions that take zero parameters. -
createSnapshot
Creates a snapshot of this CalciteSchema as of the specified time. All explicit objects in this CalciteSchema will be copied into the snapshot CalciteSchema, while the contents of the snapshot of the underlying schema should not change as specified inSchema.snapshot(SchemaVersion)
. Snapshots of explicit sub schemas will be created and copied recursively.Currently, to accommodate the requirement of creating tables on the fly for materializations, the snapshot will still use the same table map and lattice map as in the original CalciteSchema instead of making copies.
- Parameters:
version
- The current schema version- Returns:
- the schema snapshot.
-
createRootSchema
Creates a root schema.When
addMetadataSchema
argument is true adds a "metadata" schema containing definitions of tables, columns etc. to root schema. By default, creates aCachingCalciteSchema
. -
createRootSchema
Creates a root schema.- Parameters:
addMetadataSchema
- Whether to add a "metadata" schema containing definitions of tables, columns etc.cache
- If true createCachingCalciteSchema
; if false createSimpleCalciteSchema
-
createRootSchema
Creates a root schema.- Parameters:
addMetadataSchema
- Whether to add a "metadata" schema containing definitions of tables, columns etc.cache
- If true createCachingCalciteSchema
; if false createSimpleCalciteSchema
name
- Schema name
-
createRootSchema
public static CalciteSchema createRootSchema(boolean addMetadataSchema, boolean cache, String name, Schema schema) -
removeSubSchema
-
removeTable
-
removeFunction
-
removeType
-