public class JdbcSchema extends Object implements Schema
Schema that is backed by a JDBC data source.
The tables in the JDBC data source appear to be tables in this schema; queries against this schema are executed against those tables, pushing down as much as possible of the query logic to SQL.
| Modifier and Type | Class and Description |
|---|---|
static class |
JdbcSchema.Factory
Schema factory that creates a
JdbcSchema. |
Schema.TableType| Modifier and Type | Field and Description |
|---|---|
SqlDialect |
dialect |
| Constructor and Description |
|---|
JdbcSchema(DataSource dataSource,
SqlDialect dialect,
JdbcConvention convention,
String catalog,
String schema)
Creates a JDBC schema.
|
| 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.
|
static JdbcSchema |
create(SchemaPlus parentSchema,
String name,
DataSource dataSource,
String catalog,
String schema) |
static JdbcSchema |
create(SchemaPlus parentSchema,
String name,
Map<String,Object> operand)
Creates a JdbcSchema, taking credentials from a map.
|
static SqlDialect |
createDialect(DataSource dataSource)
Returns a suitable SQL dialect for the given data source.
|
static DataSource |
dataSource(String url,
String driverClassName,
String username,
String password)
Creates a JDBC data source with the given specification.
|
DataSource |
getDataSource() |
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.
|
protected com.google.common.collect.Multimap<String,Function> |
getFunctions() |
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
Schema.getTable(String). |
public final SqlDialect dialect
public JdbcSchema(DataSource dataSource, SqlDialect dialect, JdbcConvention convention, String catalog, String schema)
dataSource - Data sourcedialect - SQL dialectconvention - Calling conventioncatalog - Catalog name, or nullschema - Schema name patternpublic static JdbcSchema create(SchemaPlus parentSchema, String name, DataSource dataSource, String catalog, String schema)
public static JdbcSchema create(SchemaPlus parentSchema, String name, Map<String,Object> operand)
parentSchema - Parent schemaname - Nameoperand - Map of property/value pairspublic static SqlDialect createDialect(DataSource dataSource)
public static DataSource dataSource(String url, String driverClassName, String username, String password)
public boolean isMutable()
SchemaSchema.getTable(String).
Even if this method returns true, the maps are not modified. Calcite stores the defined objects in a wrapper object.
public boolean contentsHaveChangedSince(long lastCheck,
long now)
SchemaSystem.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".
contentsHaveChangedSince in interface SchemalastCheck - 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.public DataSource getDataSource()
public Expression getExpression(SchemaPlus parentSchema, String name)
SchemagetExpression in interface SchemaparentSchema - Parent schemaname - Name of this schemapublic final Collection<Function> getFunctions(String name)
SchemagetFunctions in interface Schemaname - Name of functionpublic final Set<String> getFunctionNames()
SchemagetFunctionNames in interface Schemapublic Table getTable(String name)
Schemapublic Set<String> getTableNames()
SchemagetTableNames in interface Schemapublic Schema getSubSchema(String name)
SchemagetSubSchema in interface Schemaname - Sub-schema namepublic Set<String> getSubSchemaNames()
SchemagetSubSchemaNames in interface SchemaCopyright © 2012–2015 The Apache Software Foundation. All rights reserved.