Package org.apache.calcite.prepare
Class RelOptTableImpl.MySchemaPlus
- java.lang.Object
-
- org.apache.calcite.prepare.RelOptTableImpl.MySchemaPlus
-
- All Implemented Interfaces:
Schema
,SchemaPlus
- Enclosing class:
- RelOptTableImpl
private static class RelOptTableImpl.MySchemaPlus extends java.lang.Object implements SchemaPlus
Implementation ofSchemaPlus
that wraps a regular schema and knows its name and parent.It is read-only, and functionality is limited in other ways, it but allows table expressions to be generated.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.calcite.schema.Schema
Schema.TableType
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
name
private SchemaPlus
parent
private Schema
schema
-
Constructor Summary
Constructors Constructor Description MySchemaPlus(SchemaPlus parent, java.lang.String name, Schema schema)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String name, Lattice lattice)
Adds a lattice to this schema.void
add(java.lang.String name, RelProtoDataType type)
Adds a type to this schema.void
add(java.lang.String name, Function function)
Adds a function to this schema.SchemaPlus
add(java.lang.String name, Schema schema)
Adds a schema as a sub-schema of this schema, and returns the wrapped object.void
add(java.lang.String name, Table table)
Adds a table to this schema.static RelOptTableImpl.MySchemaPlus
create(Path path)
Expression
getExpression(SchemaPlus parentSchema, java.lang.String name)
Returns the expression by which this schema can be referenced in generated code.java.util.Set<java.lang.String>
getFunctionNames()
Returns the names of the functions in this schema.java.util.Collection<Function>
getFunctions(java.lang.String name)
Returns a list of functions in this schema with the given name, or an empty list if there is no such function.java.lang.String
getName()
Returns the name of this schema.SchemaPlus
getParentSchema()
Returns the parent schema, or null if this schema has no parent.SchemaPlus
getSubSchema(java.lang.String name)
Returns a sub-schema with a given name, or null.java.util.Set<java.lang.String>
getSubSchemaNames()
Returns the names of this schema's child schemas.Table
getTable(java.lang.String name)
Returns a table with a given name, or null if not found.java.util.Set<java.lang.String>
getTableNames()
Returns the names of the tables in this schema.RelProtoDataType
getType(java.lang.String name)
Returns a type with a given name, or null if not found.java.util.Set<java.lang.String>
getTypeNames()
Returns the names of the types in this schema.boolean
isCacheEnabled()
boolean
isMutable()
Returns whether the user is allowed to create new tables, functions and sub-schemas in this schema, in addition to those returned automatically by methods such asSchema.getTable(String)
.void
setCacheEnabled(boolean cache)
void
setPath(com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<java.lang.String>> path)
Schema
snapshot(SchemaVersion version)
Returns the snapshot of this schema as of the specified time.<T> T
unwrap(java.lang.Class<T> clazz)
Returns an underlying object.
-
-
-
Field Detail
-
parent
private final SchemaPlus parent
-
name
private final java.lang.String name
-
schema
private final Schema schema
-
-
Constructor Detail
-
MySchemaPlus
MySchemaPlus(SchemaPlus parent, java.lang.String name, Schema schema)
-
-
Method Detail
-
create
public static RelOptTableImpl.MySchemaPlus create(Path path)
-
getParentSchema
public SchemaPlus getParentSchema()
Description copied from interface:SchemaPlus
Returns the parent schema, or null if this schema has no parent.- Specified by:
getParentSchema
in interfaceSchemaPlus
-
getName
public java.lang.String getName()
Description copied from interface:SchemaPlus
Returns the name of this schema.The name must not be null, and must be unique within its parent. The root schema is typically named "".
- Specified by:
getName
in interfaceSchemaPlus
-
getSubSchema
public SchemaPlus getSubSchema(java.lang.String name)
Description copied from interface:Schema
Returns a sub-schema with a given name, or null.- Specified by:
getSubSchema
in interfaceSchema
- Specified by:
getSubSchema
in interfaceSchemaPlus
- Parameters:
name
- Sub-schema name- Returns:
- Sub-schema with a given name, or null
-
add
public SchemaPlus add(java.lang.String name, Schema schema)
Description copied from interface:SchemaPlus
Adds a schema as a sub-schema of this schema, and returns the wrapped object.- Specified by:
add
in interfaceSchemaPlus
-
add
public void add(java.lang.String name, Table table)
Description copied from interface:SchemaPlus
Adds a table to this schema.- Specified by:
add
in interfaceSchemaPlus
-
add
public void add(java.lang.String name, Function function)
Description copied from interface:SchemaPlus
Adds a function to this schema.- Specified by:
add
in interfaceSchemaPlus
-
add
public void add(java.lang.String name, RelProtoDataType type)
Description copied from interface:SchemaPlus
Adds a type to this schema.- Specified by:
add
in interfaceSchemaPlus
-
add
public void add(java.lang.String name, Lattice lattice)
Description copied from interface:SchemaPlus
Adds a lattice to this schema.- Specified by:
add
in interfaceSchemaPlus
-
isMutable
public boolean isMutable()
Description copied from interface:Schema
Returns whether the user is allowed to create new tables, functions and sub-schemas in this schema, in addition to those returned automatically by methods such asSchema.getTable(String)
.Even if this method returns true, the maps are not modified. Calcite stores the defined objects in a wrapper object.
- Specified by:
isMutable
in interfaceSchema
- Specified by:
isMutable
in interfaceSchemaPlus
- Returns:
- Whether the user is allowed to create new tables, functions and sub-schemas in this schema
-
unwrap
public <T> T unwrap(java.lang.Class<T> clazz)
Description copied from interface:SchemaPlus
Returns an underlying object.- Specified by:
unwrap
in interfaceSchemaPlus
-
setPath
public void setPath(com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<java.lang.String>> path)
- Specified by:
setPath
in interfaceSchemaPlus
-
setCacheEnabled
public void setCacheEnabled(boolean cache)
- Specified by:
setCacheEnabled
in interfaceSchemaPlus
-
isCacheEnabled
public boolean isCacheEnabled()
- Specified by:
isCacheEnabled
in interfaceSchemaPlus
-
getTable
public Table getTable(java.lang.String name)
Description copied from interface:Schema
Returns a table with a given name, or null if not found.
-
getTableNames
public java.util.Set<java.lang.String> getTableNames()
Description copied from interface:Schema
Returns the names of the tables in this schema.- Specified by:
getTableNames
in interfaceSchema
- Returns:
- Names of the tables in this schema
-
getType
public RelProtoDataType getType(java.lang.String name)
Description copied from interface:Schema
Returns a type with a given name, or null if not found.
-
getTypeNames
public java.util.Set<java.lang.String> getTypeNames()
Description copied from interface:Schema
Returns the names of the types in this schema.- Specified by:
getTypeNames
in interfaceSchema
- Returns:
- Names of the tables in this schema
-
getFunctions
public java.util.Collection<Function> getFunctions(java.lang.String name)
Description copied from interface:Schema
Returns a list of functions in this schema with the given name, or an empty list if there is no such function.- Specified by:
getFunctions
in interfaceSchema
- Parameters:
name
- Name of function- Returns:
- List of functions with given name, or empty list
-
getFunctionNames
public java.util.Set<java.lang.String> getFunctionNames()
Description copied from interface:Schema
Returns the names of the functions in this schema.- Specified by:
getFunctionNames
in interfaceSchema
- Returns:
- Names of the functions in this schema
-
getSubSchemaNames
public java.util.Set<java.lang.String> getSubSchemaNames()
Description copied from interface:Schema
Returns the names of this schema's child schemas.- Specified by:
getSubSchemaNames
in interfaceSchema
- Returns:
- Names of this schema's child schemas
-
getExpression
public Expression getExpression(SchemaPlus parentSchema, java.lang.String name)
Description copied from interface:Schema
Returns the expression by which this schema can be referenced in generated code.- Specified by:
getExpression
in interfaceSchema
- Parameters:
parentSchema
- Parent schemaname
- Name of this schema- Returns:
- Expression by which this schema can be referenced in generated code
-
snapshot
public Schema snapshot(SchemaVersion version)
Description copied from interface:Schema
Returns the snapshot of this schema as of the specified time. The contents of the schema snapshot should not change over time.
-
-