Package org.apache.calcite.adapter.jdbc
Class JdbcSchema
java.lang.Object
org.apache.calcite.adapter.jdbc.JdbcSchema
Implementation of
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Schema factory that creates aJdbcSchema
.static interface
Do not use.Nested classes/interfaces inherited from interface org.apache.calcite.schema.Schema
Schema.TableType
-
Field Summary
Modifier and TypeFieldDescriptionfinal SqlDialect
static final ThreadLocal<@Nullable JdbcSchema.Foo>
-
Constructor Summary
ConstructorDescriptionJdbcSchema
(DataSource dataSource, SqlDialect dialect, JdbcConvention convention, @Nullable String catalog, @Nullable String schema) Creates a JDBC schema. -
Method Summary
Modifier and TypeMethodDescriptionstatic JdbcSchema
Creates a JdbcSchema, taking credentials from a map.static JdbcSchema
create
(SchemaPlus parentSchema, String name, DataSource dataSource, @Nullable String catalog, @Nullable String schema) static JdbcSchema
create
(SchemaPlus parentSchema, String name, DataSource dataSource, SqlDialectFactory dialectFactory, @Nullable String catalog, @Nullable String schema) static SqlDialect
createDialect
(DataSource dataSource) Deprecated.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.getExpression
(@Nullable SchemaPlus parentSchema, String name) Returns the expression by which this schema can be referenced in generated code.Returns the names of the functions in this schema.final 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.Returns the names of this schema's child schemas.@Nullable Table
Returns a table with a given name, or null if not found.Returns the names of the tables in this schema.@Nullable RelProtoDataType
Returns a type with a given name, or null if not found.Returns the names of the types in this schema.protected Map<String,
RelProtoDataType> getTypes()
boolean
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)
.snapshot
(SchemaVersion version) Returns the snapshot of this schema as of the specified time.<T> @Nullable T
Finds an instance of an interface implemented by this object, or returns null if this object does not support that interface.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.schema.Wrapper
maybeUnwrap, unwrapOrThrow
-
Field Details
-
dialect
-
THREAD_METADATA
-
-
Constructor Details
-
JdbcSchema
public JdbcSchema(DataSource dataSource, SqlDialect dialect, JdbcConvention convention, @Nullable String catalog, @Nullable String schema) Creates a JDBC schema.- Parameters:
dataSource
- Data sourcedialect
- SQL dialectconvention
- Calling conventioncatalog
- Catalog name, or nullschema
- Schema name pattern
-
-
Method Details
-
create
public static JdbcSchema create(SchemaPlus parentSchema, String name, DataSource dataSource, @Nullable String catalog, @Nullable String schema) -
create
public static JdbcSchema create(SchemaPlus parentSchema, String name, DataSource dataSource, SqlDialectFactory dialectFactory, @Nullable String catalog, @Nullable String schema) -
create
Creates a JdbcSchema, taking credentials from a map.- Parameters:
parentSchema
- Parent schemaname
- Nameoperand
- Map of property/value pairs- Returns:
- A JdbcSchema
-
createDialect
Deprecated.UsecreateDialect(SqlDialectFactory, DataSource)
insteadReturns a suitable SQL dialect for the given data source.- Parameters:
dataSource
- The data source
-
createDialect
Returns a suitable SQL dialect for the given data source. -
dataSource
public static DataSource dataSource(String url, @Nullable String driverClassName, @Nullable String username, @Nullable String password) Creates a JDBC data source with the given specification. -
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.
-
snapshot
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. -
getDataSource
-
getExpression
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
-
getFunctions
-
getFunctions
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
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
-
getTable
Description copied from interface:Schema
Returns a table with a given name, or null if not found. -
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
-
getTypes
-
getType
Description copied from interface:Schema
Returns a type with a given name, or null if not found. -
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
-
getSubSchema
Description copied from interface:Schema
Returns a sub-schema with a given name, or null.- Specified by:
getSubSchema
in interfaceSchema
- Parameters:
name
- Sub-schema name- Returns:
- Sub-schema with a given name, or null
-
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
-
unwrap
Description copied from interface:Wrapper
Finds an instance of an interface implemented by this object, or returns null if this object does not support that interface.
-
createDialect(SqlDialectFactory, DataSource)
instead