Class CalciteCatalogReader
- All Implemented Interfaces:
RelOptSchema
,Prepare.CatalogReader
,Wrapper
,SqlOperatorTable
,SqlValidatorCatalogReader
- Direct Known Subclasses:
MockCatalogReader
Prepare.CatalogReader
and also SqlOperatorTable
based on tables and
functions defined schemas.-
Field Summary
Modifier and TypeFieldDescriptionprotected final CalciteConnectionConfig
protected final SqlNameMatcher
protected final CalciteSchema
protected final RelDataTypeFactory
Fields inherited from interface org.apache.calcite.prepare.Prepare.CatalogReader
THREAD_LOCAL
-
Constructor Summary
ModifierConstructorDescriptionCalciteCatalogReader
(CalciteSchema rootSchema, List<String> defaultSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) protected
CalciteCatalogReader
(CalciteSchema rootSchema, SqlNameMatcher nameMatcher, List<List<String>> schemaPaths, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) -
Method Summary
Modifier and TypeMethodDescriptioncreateTypeFromProjection
(RelDataType type, List<String> columnNameList) @Nullable RelDataTypeField
field
(RelDataType rowType, String alias) getAllSchemaObjectNames
(List<String> names) Given fully qualified schema name, returns schema object names as specified.Returns Config settings.@Nullable RelDataType
getNamedType
(SqlIdentifier typeName) Finds a user-defined type with the given name, possibly qualified.Retrieves a list of all functions and operators in this table.Returns the root namespace for name resolution.Returns the paths of all schemas to look in for tables.@Nullable Prepare.PreparingTable
Finds a table or schema with the given name, possibly qualified.@Nullable Prepare.PreparingTable
getTableForMember
(List<String> names) Retrieves aRelOptTable
based upon a member access.Returns thetype factory
used to generate types for this schema.boolean
void
lookupOperatorOverloads
(SqlIdentifier opName, @Nullable SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList, SqlNameMatcher nameMatcher) Retrieves a list of operators with a given name and syntax.boolean
Returns an implementation ofSqlNameMatcher
that matches the case-sensitivity policy.static SqlOperatorTable
operatorTable
(String... classNames) Creates an operator table that contains functions in the given class or classes.void
registerRules
(RelOptPlanner planner) Registers all the rules supported by this schema.<C> @Nullable C
Finds an instance of an interface implemented by this object, or returns null if this object does not support that interface.withSchemaPath
(List<String> schemaPath) Returns a catalog reader the same as this one but with a possibly different schema path.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
-
rootSchema
-
typeFactory
-
nameMatcher
-
config
-
-
Constructor Details
-
CalciteCatalogReader
public CalciteCatalogReader(CalciteSchema rootSchema, List<String> defaultSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) -
CalciteCatalogReader
protected CalciteCatalogReader(CalciteSchema rootSchema, SqlNameMatcher nameMatcher, List<List<String>> schemaPaths, RelDataTypeFactory typeFactory, CalciteConnectionConfig config)
-
-
Method Details
-
withSchemaPath
Description copied from interface:Prepare.CatalogReader
Returns a catalog reader the same as this one but with a possibly different schema path.- Specified by:
withSchemaPath
in interfacePrepare.CatalogReader
-
getTable
Description copied from interface:SqlValidatorCatalogReader
Finds a table or schema with the given name, possibly qualified.Uses the case-sensitivity policy of the catalog reader.
If not found, returns null. If you want a more descriptive error message or to override the case-sensitivity of the match, use
SqlValidatorScope.resolveTable(java.util.List<java.lang.String>, org.apache.calcite.sql.validate.SqlNameMatcher, org.apache.calcite.sql.validate.SqlValidatorScope.Path, org.apache.calcite.sql.validate.SqlValidatorScope.Resolved)
.- Specified by:
getTable
in interfacePrepare.CatalogReader
- Specified by:
getTable
in interfaceSqlValidatorCatalogReader
- Parameters:
names
- Name of table, may be qualified or fully-qualified- Returns:
- Table with the given name, or null
-
getConfig
Description copied from interface:SqlValidatorCatalogReader
Returns Config settings.- Specified by:
getConfig
in interfaceSqlValidatorCatalogReader
-
getNamedType
Description copied from interface:SqlValidatorCatalogReader
Finds a user-defined type with the given name, possibly qualified.NOTE jvs 12-Feb-2005: the reason this method is defined here instead of on RelDataTypeFactory is that it has to take into account context-dependent information such as SQL schema path, whereas a type factory is context-independent.
- Specified by:
getNamedType
in interfaceSqlValidatorCatalogReader
- Parameters:
typeName
- Name of type- Returns:
- named type, or null if not found
-
getAllSchemaObjectNames
Description copied from interface:SqlValidatorCatalogReader
Given fully qualified schema name, returns schema object names as specified. They can be schema, table, function, view. When names array is empty, the contents of root schema should be returned.- Specified by:
getAllSchemaObjectNames
in interfaceSqlValidatorCatalogReader
- Parameters:
names
- the array contains fully qualified schema name or empty list for root schema- Returns:
- the list of all object (schema, table, function, view) names under the above criteria
-
getSchemaPaths
Description copied from interface:SqlValidatorCatalogReader
Returns the paths of all schemas to look in for tables.- Specified by:
getSchemaPaths
in interfaceSqlValidatorCatalogReader
- Returns:
- paths of current schema and root schema
-
getTableForMember
Description copied from interface:RelOptSchema
Retrieves aRelOptTable
based upon a member access.For example, the Saffron expression
salesSchema.emps
would be resolved using a call tosalesSchema.getTableForMember(new String[]{"emps" })
.Note that name.length is only greater than 1 for queries originating from JDBC.
- Specified by:
getTableForMember
in interfacePrepare.CatalogReader
- Specified by:
getTableForMember
in interfaceRelOptSchema
- Parameters:
names
- Qualified name
-
field
- Specified by:
field
in interfaceSqlValidatorCatalogReader
-
matches
- Specified by:
matches
in interfaceSqlValidatorCatalogReader
-
createTypeFromProjection
- Specified by:
createTypeFromProjection
in interfaceSqlValidatorCatalogReader
-
lookupOperatorOverloads
public void lookupOperatorOverloads(SqlIdentifier opName, @Nullable SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList, SqlNameMatcher nameMatcher) Description copied from interface:SqlOperatorTable
Retrieves a list of operators with a given name and syntax. For example, by passing SqlSyntax.Function, the returned list is narrowed to only matching SqlFunction objects.- Specified by:
lookupOperatorOverloads
in interfaceSqlOperatorTable
- Parameters:
opName
- name of operatorcategory
- function category to look up, or null for any matching operatorsyntax
- syntax type of operatoroperatorList
- mutable list to which to append matchesnameMatcher
- Name matcher
-
operatorTable
Creates an operator table that contains functions in the given class or classes. -
getOperatorList
Description copied from interface:SqlOperatorTable
Retrieves a list of all functions and operators in this table. Used for automated testing. Depending on the table type, may or may not be mutable.- Specified by:
getOperatorList
in interfaceSqlOperatorTable
- Returns:
- list of SqlOperator objects
-
getRootSchema
Description copied from interface:SqlValidatorCatalogReader
Returns the root namespace for name resolution.- Specified by:
getRootSchema
in interfaceSqlValidatorCatalogReader
-
getTypeFactory
Description copied from interface:RelOptSchema
Returns thetype factory
used to generate types for this schema.- Specified by:
getTypeFactory
in interfaceRelOptSchema
-
registerRules
Description copied from interface:RelOptSchema
Registers all the rules supported by this schema. Only called byRelOptPlanner.registerSchema(org.apache.calcite.plan.RelOptSchema)
.- Specified by:
registerRules
in interfaceRelOptSchema
-
isCaseSensitive
public boolean isCaseSensitive()- Specified by:
isCaseSensitive
in interfaceSqlValidatorCatalogReader
-
nameMatcher
Description copied from interface:SqlValidatorCatalogReader
Returns an implementation ofSqlNameMatcher
that matches the case-sensitivity policy.- Specified by:
nameMatcher
in interfaceSqlValidatorCatalogReader
-
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.
-