public interface Schema
A schema can also contain sub-schemas, to any level of nesting. Most providers have a limited number of levels; for example, most JDBC databases have either one level ("schemas") or two levels ("database" and "catalog").
There may be multiple overloaded functions with the same name but
different numbers or types of parameters.
For this reason, getFunctions(java.lang.String) returns a list of all
members with the same name. Calcite will call
Schemas.resolve(org.apache.calcite.rel.type.RelDataTypeFactory, String, java.util.Collection, java.util.List)
to choose the appropriate one.
The most common and important type of member is the one with no arguments and a result type that is a collection of records. This is called a relation. It is equivalent to a table in a relational database.
For example, the query
select * from sales.emps
is valid if "sales" is a registered
schema and "emps" is a member with zero parameters and a result type
of Collection(Record(int: "empno", String: "name")).
A schema may be nested within another schema; see
getSubSchema(String).
| Modifier and Type | Interface and Description |
|---|---|
static class |
Schema.TableType
Table type.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contentsHaveChangedSince(long lastCheck,
long now)
Returns whether the contents of this schema have changed since a given
time.
|
Expression |
getExpression(SchemaPlus parentSchema,
String name)
Returns the expression by which this schema can be referenced in generated
code.
|
Set<String> |
getFunctionNames()
Returns the names of the functions in this schema.
|
Collection<Function> |
getFunctions(String name)
Returns a list of functions in this schema with the given name, or
an empty list if there is no such function.
|
Schema |
getSubSchema(String name)
Returns a sub-schema with a given name, or null.
|
Set<String> |
getSubSchemaNames()
Returns the names of this schema's child schemas.
|
Table |
getTable(String name)
Returns a table with a given name, or null if not found.
|
Set<String> |
getTableNames()
Returns the names of the tables in this schema.
|
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 as
getTable(String). |
Table getTable(String name)
name - Table nameSet<String> getTableNames()
Collection<Function> getFunctions(String name)
name - Name of functionSet<String> getFunctionNames()
Schema getSubSchema(String name)
name - Sub-schema nameSet<String> getSubSchemaNames()
Expression getExpression(SchemaPlus parentSchema, String name)
parentSchema - Parent schemaname - Name of this schemaboolean isMutable()
getTable(String).
Even if this method returns true, the maps are not modified. Calcite stores the defined objects in a wrapper object.
boolean contentsHaveChangedSince(long lastCheck,
long now)
System.currentTimeMillis(). If this method returns true, and
caching is enabled, Calcite will re-build caches.
The default implementation in
AbstractSchema always returns
false.
To control whether Calcite caches the contents of a schema, use the "cache" JSON attribute. The default value is "true".
lastCheck - The last time that Calcite called this method, or
Long.MIN_VALUE if this is the first callnow - The current time in millis, as returned by
System.currentTimeMillis()lastCheckMillis.Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.