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. |
static interface |
JdbcSchema.Foo
Do not use.
|
Schema.TableType| Modifier and Type | Field and Description |
|---|---|
SqlDialect |
dialect |
static ThreadLocal<JdbcSchema.Foo> |
THREAD_METADATA |
| Constructor and Description |
|---|
JdbcSchema(DataSource dataSource,
SqlDialect dialect,
JdbcConvention convention,
@Nullable String catalog,
@Nullable String schema)
Creates a JDBC schema.
|
| Modifier and Type | Method and Description |
|---|---|
static JdbcSchema |
create(SchemaPlus parentSchema,
String name,
DataSource dataSource,
SqlDialectFactory dialectFactory,
@Nullable String catalog,
@Nullable String schema) |
static JdbcSchema |
create(SchemaPlus parentSchema,
String name,
DataSource dataSource,
@Nullable String catalog,
@Nullable 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)
Deprecated.
Use
createDialect(SqlDialectFactory, DataSource) instead |
static SqlDialect |
createDialect(SqlDialectFactory dialectFactory,
DataSource dataSource)
Returns a suitable SQL dialect for the given data source.
|
static DataSource |
dataSource(String url,
@Nullable String driverClassName,
@Nullable String username,
@Nullable String password)
Creates a JDBC data source with the given specification.
|
DataSource |
getDataSource() |
org.apache.calcite.linq4j.tree.Expression |
getExpression(@Nullable 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.
|
@Nullable 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.
|
@Nullable 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.
|
@Nullable RelProtoDataType |
getType(String name)
Returns a type with a given name, or null if not found.
|
Set<String> |
getTypeNames()
Returns the names of the types in this schema.
|
protected Map<String,RelProtoDataType> |
getTypes() |
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). |
Schema |
snapshot(SchemaVersion version)
Returns the snapshot of this schema as of the specified time.
|
public final SqlDialect dialect
public static final ThreadLocal<JdbcSchema.Foo> THREAD_METADATA
public JdbcSchema(DataSource dataSource, SqlDialect dialect, JdbcConvention convention, @Nullable String catalog, @Nullable 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, @Nullable String catalog, @Nullable String schema)
public static JdbcSchema create(SchemaPlus parentSchema, String name, DataSource dataSource, SqlDialectFactory dialectFactory, @Nullable String catalog, @Nullable String schema)
public static JdbcSchema create(SchemaPlus parentSchema, String name, Map<String,Object> operand)
parentSchema - Parent schemaname - Nameoperand - Map of property/value pairs@Deprecated public static SqlDialect createDialect(DataSource dataSource)
createDialect(SqlDialectFactory, DataSource) insteaddataSource - The data sourcepublic static SqlDialect createDialect(SqlDialectFactory dialectFactory, DataSource dataSource)
public static DataSource dataSource(String url, @Nullable String driverClassName, @Nullable String username, @Nullable 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 Schema snapshot(SchemaVersion version)
Schemapublic DataSource getDataSource()
public org.apache.calcite.linq4j.tree.Expression getExpression(@Nullable 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 @Nullable Table getTable(String name)
Schemapublic Set<String> getTableNames()
SchemagetTableNames in interface Schemaprotected Map<String,RelProtoDataType> getTypes()
public @Nullable RelProtoDataType getType(String name)
Schemapublic Set<String> getTypeNames()
SchemagetTypeNames in interface Schemapublic @Nullable Schema getSubSchema(String name)
SchemagetSubSchema in interface Schemaname - Sub-schema namepublic Set<String> getSubSchemaNames()
SchemagetSubSchemaNames in interface SchemaCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.