public abstract class CalciteSchema extends Object
Wrapper around user-defined schema used internally.
| Modifier and Type | Class and Description |
|---|---|
static class |
CalciteSchema.Entry
Entry in a schema, such as a table or sub-schema.
|
static class |
CalciteSchema.FunctionEntry
Membership of a function in a schema.
|
static class |
CalciteSchema.FunctionEntryImpl
Implementation of
CalciteSchema.FunctionEntry
where all properties are held in fields. |
static class |
CalciteSchema.LatticeEntry
Membership of a lattice in a schema.
|
static class |
CalciteSchema.LatticeEntryImpl
Implementation of
CalciteSchema.LatticeEntry
where all properties are held in fields. |
static class |
CalciteSchema.TableEntry
Membership of a table in a schema.
|
static class |
CalciteSchema.TableEntryImpl
Implementation of
CalciteSchema.TableEntry
where all properties are held in fields. |
static class |
CalciteSchema.TypeEntry
Membership of a type in a schema.
|
static class |
CalciteSchema.TypeEntryImpl
Implementation of
CalciteSchema.TypeEntry
where all properties are held in fields. |
| Modifier and Type | Field and Description |
|---|---|
protected NameMultimap<CalciteSchema.FunctionEntry> |
functionMap |
protected NameSet |
functionNames |
protected NameMap<CalciteSchema.LatticeEntry> |
latticeMap |
String |
name |
protected NameMap<CalciteSchema.FunctionEntry> |
nullaryFunctionMap |
Schema |
schema |
protected NameMap<CalciteSchema> |
subSchemaMap |
protected NameMap<CalciteSchema.TableEntry> |
tableMap
Tables explicitly defined in this schema.
|
protected NameMap<CalciteSchema.TypeEntry> |
typeMap |
| Modifier | Constructor and Description |
|---|---|
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) |
| Modifier and Type | Method and Description |
|---|---|
CalciteSchema.TypeEntry |
add(String name,
RelProtoDataType type)
Defines a type within this schema.
|
abstract CalciteSchema |
add(String name,
Schema schema)
Adds a child schema of this schema.
|
CalciteSchema.TableEntry |
add(String tableName,
Table table)
Defines a table within this schema.
|
CalciteSchema.TableEntry |
add(String tableName,
Table table,
com.google.common.collect.ImmutableList<String> sqls)
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) |
CalciteSchema |
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 NameMap
|
protected static Iterable<String> |
find(NavigableSet<String> set,
String name)
Deprecated.
use NameSet
|
static CalciteSchema |
from(SchemaPlus plus) |
NavigableSet<String> |
getFunctionNames()
Returns the list of function names in this schema, both implicit and
explicit, never null.
|
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 underlying
Schema object, not explicitly
by a call to add(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 underlying
Schema object, not explicitly
by a call to add(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 underlying
Schema object,
not explicitly by a call to add(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 underlying
Schema object, not explicitly
by a call to add(String, RelProtoDataType)), or null. |
NavigableMap<String,CalciteSchema.LatticeEntry> |
getLatticeMap()
Returns a collection of lattices.
|
String |
getName() |
List<? extends List<String>> |
getPath()
Returns the default path resolving functions from this schema.
|
@Nullable CalciteSchema |
getSubSchema(String schemaName,
boolean caseSensitive) |
NavigableMap<String,CalciteSchema> |
getSubSchemaMap()
Returns a collection of sub-schemas, both explicit (defined using
add(String, org.apache.calcite.schema.Schema)) and implicit
(defined using Schema.getSubSchemaNames()
and Schema.getSubSchema(String)). |
@Nullable CalciteSchema.TableEntry |
getTable(String tableName,
boolean caseSensitive)
Returns a table with the given name.
|
@Nullable CalciteSchema.TableEntry |
getTableBasedOnNullaryFunction(String tableName,
boolean caseSensitive)
Returns a tables derived from explicit and implicit functions
that take zero parameters.
|
@Nullable CalciteSchema.TableEntry |
getTableBySql(String sql)
Returns a table that materializes the given SQL statement.
|
NavigableSet<String> |
getTableNames()
Returns the set of all table names.
|
NavigableMap<String,Table> |
getTablesBasedOnNullaryFunctions()
Returns tables derived from explicit and implicit functions
that take zero parameters.
|
@Nullable CalciteSchema.TypeEntry |
getType(String name,
boolean caseSensitive)
Returns a type, explicit and implicit, with a given
name.
|
NavigableSet<String> |
getTypeNames()
Returns the set of all types names.
|
protected abstract boolean |
isCacheEnabled() |
boolean |
isRoot()
Returns whether this is a root schema.
|
List<String> |
path(@Nullable String name)
Returns the path of an object in this schema.
|
SchemaPlus |
plus() |
boolean |
removeFunction(String name) |
boolean |
removeSubSchema(String name) |
boolean |
removeTable(String name) |
boolean |
removeType(String name) |
CalciteSchema |
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.
|
public final Schema schema
public final String name
protected final NameMap<CalciteSchema.TableEntry> tableMap
schema.protected final NameMultimap<CalciteSchema.FunctionEntry> functionMap
protected final NameMap<CalciteSchema.TypeEntry> typeMap
protected final NameMap<CalciteSchema.LatticeEntry> latticeMap
protected final NameSet functionNames
protected final NameMap<CalciteSchema.FunctionEntry> nullaryFunctionMap
protected final NameMap<CalciteSchema> subSchemaMap
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)
protected abstract @Nullable CalciteSchema getImplicitSubSchema(String schemaName, boolean caseSensitive)
Schema object, not explicitly
by a call to add(String, Schema)), or null.protected abstract @Nullable CalciteSchema.TableEntry getImplicitTable(String tableName, boolean caseSensitive)
Schema object, not explicitly
by a call to add(String, Table)), or null.protected abstract @Nullable CalciteSchema.TypeEntry getImplicitType(String name, boolean caseSensitive)
Schema object, not explicitly
by a call to add(String, RelProtoDataType)), or null.protected abstract @Nullable CalciteSchema.TableEntry getImplicitTableBasedOnNullaryFunction(String tableName, boolean caseSensitive)
Schema object,
not explicitly by a call to add(String, Function)), or null.protected abstract void addImplicitSubSchemaToBuilder(com.google.common.collect.ImmutableSortedMap.Builder<String,CalciteSchema> builder)
protected abstract void addImplicitTableToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<String> builder)
protected abstract void addImplicitFunctionsToBuilder(com.google.common.collect.ImmutableList.Builder<Function> builder, String name, boolean caseSensitive)
protected abstract void addImplicitFuncNamesToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<String> builder)
protected abstract void addImplicitTypeNamesToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<String> builder)
protected abstract void addImplicitTablesBasedOnNullaryFunctionsToBuilder(com.google.common.collect.ImmutableSortedMap.Builder<String,Table> builder)
protected abstract CalciteSchema snapshot(@Nullable CalciteSchema parent, SchemaVersion version)
protected abstract boolean isCacheEnabled()
public abstract void setCache(boolean cache)
protected CalciteSchema.TableEntryImpl tableEntry(String name, Table table)
protected CalciteSchema.TypeEntryImpl typeEntry(String name, RelProtoDataType relProtoDataType)
public CalciteSchema.TableEntry add(String tableName, Table table)
public CalciteSchema.TableEntry add(String tableName, Table table, com.google.common.collect.ImmutableList<String> sqls)
public CalciteSchema.TypeEntry add(String name, RelProtoDataType type)
public CalciteSchema root()
public boolean isRoot()
public final @Nullable CalciteSchema getSubSchema(String schemaName, boolean caseSensitive)
public abstract CalciteSchema add(String name, Schema schema)
public final @Nullable CalciteSchema.TableEntry getTableBySql(String sql)
public final @Nullable CalciteSchema.TableEntry getTable(String tableName, boolean caseSensitive)
public String getName()
public SchemaPlus plus()
public static CalciteSchema from(SchemaPlus plus)
public List<? extends List<String>> getPath()
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).
public final NavigableMap<String,CalciteSchema> getSubSchemaMap()
add(String, org.apache.calcite.schema.Schema)) and implicit
(defined using Schema.getSubSchemaNames()
and Schema.getSubSchema(String)).public NavigableMap<String,CalciteSchema.LatticeEntry> getLatticeMap()
All are explicit (defined using add(String, Lattice)).
public final NavigableSet<String> getTableNames()
public final NavigableSet<String> getTypeNames()
public final @Nullable CalciteSchema.TypeEntry getType(String name, boolean caseSensitive)
public final Collection<Function> getFunctions(String name, boolean caseSensitive)
public final NavigableSet<String> getFunctionNames()
public final NavigableMap<String,Table> getTablesBasedOnNullaryFunctions()
public final @Nullable CalciteSchema.TableEntry getTableBasedOnNullaryFunction(String tableName, boolean caseSensitive)
public CalciteSchema createSnapshot(SchemaVersion version)
Schema.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.
version - The current schema version@Deprecated protected static <V> NavigableMap<String,V> find(NavigableMap<String,V> map, String s)
@Deprecated protected static Iterable<String> find(NavigableSet<String> set, String name)
public static CalciteSchema createRootSchema(boolean addMetadataSchema)
When addMetadataSchema argument is true adds a "metadata"
schema containing definitions of tables, columns etc. to root schema.
By default, creates a CachingCalciteSchema.
public static CalciteSchema createRootSchema(boolean addMetadataSchema, boolean cache)
addMetadataSchema - Whether to add a "metadata" schema containing
definitions of tables, columns etc.cache - If true create CachingCalciteSchema;
if false create SimpleCalciteSchemapublic static CalciteSchema createRootSchema(boolean addMetadataSchema, boolean cache, String name)
addMetadataSchema - Whether to add a "metadata" schema containing
definitions of tables, columns etc.cache - If true create CachingCalciteSchema;
if false create SimpleCalciteSchemaname - Schema namepublic static CalciteSchema createRootSchema(boolean addMetadataSchema, boolean cache, String name, Schema schema)
public boolean removeSubSchema(String name)
public boolean removeTable(String name)
public boolean removeFunction(String name)
public boolean removeType(String name)
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.