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
FieldsModifier and TypeFieldDescriptionprotected final CalciteConnectionConfigprotected final SqlNameMatcherprotected final CalciteSchemaprotected final RelDataTypeFactoryFields inherited from interface org.apache.calcite.prepare.Prepare.CatalogReader
THREAD_LOCAL -
Constructor Summary
ConstructorsModifierConstructorDescriptionCalciteCatalogReader(CalciteSchema rootSchema, List<String> defaultSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) protectedCalciteCatalogReader(CalciteSchema rootSchema, SqlNameMatcher nameMatcher, List<List<String>> schemaPaths, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) -
Method Summary
Modifier and TypeMethodDescriptioncreateTypeFromProjection(RelDataType type, List<String> columnNameList) @Nullable RelDataTypeFieldfield(RelDataType rowType, String alias) getAllSchemaObjectNames(List<String> names) Given fully qualified schema name, returns schema object names as specified.Returns Config settings.@Nullable RelDataTypegetNamedType(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.PreparingTableFinds a table or schema with the given name, possibly qualified.@Nullable Prepare.PreparingTablegetTableForMember(List<String> names) Retrieves aRelOptTablebased upon a member access.Returns thetype factoryused to generate types for this schema.booleanvoidlookupOperatorOverloads(SqlIdentifier opName, @Nullable SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList, SqlNameMatcher nameMatcher) Retrieves a list of operators with a given name and syntax.booleanReturns an implementation ofSqlNameMatcherthat matches the case-sensitivity policy.static SqlOperatorTableoperatorTable(String... classNames) Creates an operator table that contains functions in the given class or classes.voidregisterRules(RelOptPlanner planner) Registers all the rules supported by this schema.<C> @Nullable CFinds 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, waitMethods 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.CatalogReaderReturns a catalog reader the same as this one but with a possibly different schema path.- Specified by:
withSchemaPathin interfacePrepare.CatalogReader
-
getTable
Description copied from interface:SqlValidatorCatalogReaderFinds 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:
getTablein interfacePrepare.CatalogReader- Specified by:
getTablein 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:SqlValidatorCatalogReaderReturns Config settings.- Specified by:
getConfigin interfaceSqlValidatorCatalogReader
-
getNamedType
Description copied from interface:SqlValidatorCatalogReaderFinds 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:
getNamedTypein interfaceSqlValidatorCatalogReader- Parameters:
typeName- Name of type- Returns:
- named type, or null if not found
-
getAllSchemaObjectNames
Description copied from interface:SqlValidatorCatalogReaderGiven 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:
getAllSchemaObjectNamesin 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:SqlValidatorCatalogReaderReturns the paths of all schemas to look in for tables.- Specified by:
getSchemaPathsin interfaceSqlValidatorCatalogReader- Returns:
- paths of current schema and root schema
-
getTableForMember
Description copied from interface:RelOptSchemaRetrieves aRelOptTablebased upon a member access.For example, the Saffron expression
salesSchema.empswould 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:
getTableForMemberin interfacePrepare.CatalogReader- Specified by:
getTableForMemberin interfaceRelOptSchema- Parameters:
names- Qualified name
-
field
- Specified by:
fieldin interfaceSqlValidatorCatalogReader
-
matches
- Specified by:
matchesin interfaceSqlValidatorCatalogReader
-
createTypeFromProjection
- Specified by:
createTypeFromProjectionin interfaceSqlValidatorCatalogReader
-
lookupOperatorOverloads
public void lookupOperatorOverloads(SqlIdentifier opName, @Nullable SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList, SqlNameMatcher nameMatcher) Description copied from interface:SqlOperatorTableRetrieves 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:
lookupOperatorOverloadsin 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:SqlOperatorTableRetrieves 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:
getOperatorListin interfaceSqlOperatorTable- Returns:
- list of SqlOperator objects
-
getRootSchema
Description copied from interface:SqlValidatorCatalogReaderReturns the root namespace for name resolution.- Specified by:
getRootSchemain interfaceSqlValidatorCatalogReader
-
getTypeFactory
Description copied from interface:RelOptSchemaReturns thetype factoryused to generate types for this schema.- Specified by:
getTypeFactoryin interfaceRelOptSchema
-
registerRules
Description copied from interface:RelOptSchemaRegisters all the rules supported by this schema. Only called byRelOptPlanner.registerSchema(org.apache.calcite.plan.RelOptSchema).- Specified by:
registerRulesin interfaceRelOptSchema
-
isCaseSensitive
public boolean isCaseSensitive()- Specified by:
isCaseSensitivein interfaceSqlValidatorCatalogReader
-
nameMatcher
Description copied from interface:SqlValidatorCatalogReaderReturns an implementation ofSqlNameMatcherthat matches the case-sensitivity policy.- Specified by:
nameMatcherin interfaceSqlValidatorCatalogReader
-
unwrap
Description copied from interface:WrapperFinds an instance of an interface implemented by this object, or returns null if this object does not support that interface.
-