public class CalciteCatalogReader extends Object implements Prepare.CatalogReader
Prepare.CatalogReader
and also SqlOperatorTable based on tables and
functions defined schemas.| Modifier and Type | Field and Description |
|---|---|
protected CalciteConnectionConfig |
config |
protected SqlNameMatcher |
nameMatcher |
protected CalciteSchema |
rootSchema |
private List<List<String>> |
schemaPaths |
protected RelDataTypeFactory |
typeFactory |
THREAD_LOCAL| Modifier | Constructor and Description |
|---|---|
|
CalciteCatalogReader(CalciteSchema rootSchema,
List<String> defaultSchema,
RelDataTypeFactory typeFactory,
CalciteConnectionConfig config) |
protected |
CalciteCatalogReader(CalciteSchema rootSchema,
SqlNameMatcher nameMatcher,
List<List<String>> schemaPaths,
RelDataTypeFactory typeFactory,
CalciteConnectionConfig config) |
| Modifier and Type | Method and Description |
|---|---|
RelDataType |
createTypeFromProjection(RelDataType type,
List<String> columnNameList) |
RelDataTypeField |
field(RelDataType rowType,
String alias) |
List<SqlMoniker> |
getAllSchemaObjectNames(List<String> names)
Given fully qualified schema name, returns schema object names as
specified.
|
CalciteConnectionConfig |
getConfig()
Returns Config settings
|
private Collection<Function> |
getFunctionsFrom(List<String> names) |
RelDataType |
getNamedType(SqlIdentifier typeName)
Finds a user-defined type with the given name, possibly qualified.
|
List<SqlOperator> |
getOperatorList()
Retrieves a list of all functions and operators in this table.
|
CalciteSchema |
getRootSchema()
Returns the root namespace for name resolution.
|
List<List<String>> |
getSchemaPaths()
Returns the paths of all schemas to look in for tables.
|
Prepare.PreparingTable |
getTable(List<String> names)
Finds a table or schema with the given name, possibly qualified.
|
Prepare.PreparingTable |
getTableForMember(List<String> names)
Retrieves a
RelOptTable based upon a member access. |
RelDataTypeFactory |
getTypeFactory()
Returns the
type factory used to generate
types for this schema. |
private static SqlReturnTypeInference |
infer(AggregateFunction function) |
private static SqlReturnTypeInference |
infer(ScalarFunction function) |
boolean |
isCaseSensitive() |
void |
lookupOperatorOverloads(SqlIdentifier opName,
SqlFunctionCategory category,
SqlSyntax syntax,
List<SqlOperator> operatorList)
Retrieves a list of operators with a given name and syntax.
|
boolean |
matches(String string,
String name) |
private SqlMonikerImpl |
moniker(CalciteSchema schema,
String name,
SqlMonikerType type) |
SqlNameMatcher |
nameMatcher()
Returns an implementation of
SqlNameMatcher
that matches the case-sensitivity policy. |
static SqlOperatorTable |
operatorTable(String className)
Creates an operator table that contains functions in the given class.
|
void |
registerRules(RelOptPlanner planner)
Registers all of the rules supported by this schema.
|
private static SqlOperator |
toOp(RelDataTypeFactory typeFactory,
SqlIdentifier name,
Function function)
Converts a function to a
SqlOperator. |
private SqlOperator |
toOp(SqlIdentifier name,
Function function) |
private static List<RelDataType> |
toSql(RelDataTypeFactory typeFactory,
List<RelDataType> types) |
private static RelDataType |
toSql(RelDataTypeFactory typeFactory,
RelDataType type) |
<C> C |
unwrap(Class<C> aClass)
Finds an instance of an interface implemented by this object,
or returns null if this object does not support that interface.
|
CalciteCatalogReader |
withSchemaPath(List<String> schemaPath)
Returns a catalog reader the same as this one but with a possibly
different schema path.
|
protected final CalciteSchema rootSchema
protected final RelDataTypeFactory typeFactory
protected final SqlNameMatcher nameMatcher
protected final CalciteConnectionConfig config
public CalciteCatalogReader(CalciteSchema rootSchema, List<String> defaultSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config)
protected CalciteCatalogReader(CalciteSchema rootSchema, SqlNameMatcher nameMatcher, List<List<String>> schemaPaths, RelDataTypeFactory typeFactory, CalciteConnectionConfig config)
public CalciteCatalogReader withSchemaPath(List<String> schemaPath)
Prepare.CatalogReaderwithSchemaPath in interface Prepare.CatalogReaderpublic Prepare.PreparingTable getTable(List<String> names)
SqlValidatorCatalogReaderUses 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).
getTable in interface Prepare.CatalogReadergetTable in interface SqlValidatorCatalogReadernames - Name of table, may be qualified or fully-qualifiedpublic CalciteConnectionConfig getConfig()
SqlValidatorCatalogReadergetConfig in interface SqlValidatorCatalogReaderprivate Collection<Function> getFunctionsFrom(List<String> names)
public RelDataType getNamedType(SqlIdentifier typeName)
SqlValidatorCatalogReaderNOTE 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.
getNamedType in interface SqlValidatorCatalogReadertypeName - Name of typepublic List<SqlMoniker> getAllSchemaObjectNames(List<String> names)
SqlValidatorCatalogReadergetAllSchemaObjectNames in interface SqlValidatorCatalogReadernames - the array contains fully qualified schema name or empty
list for root schemaprivate SqlMonikerImpl moniker(CalciteSchema schema, String name, SqlMonikerType type)
public List<List<String>> getSchemaPaths()
SqlValidatorCatalogReadergetSchemaPaths in interface SqlValidatorCatalogReaderpublic Prepare.PreparingTable getTableForMember(List<String> names)
RelOptSchemaRelOptTable based upon a member access.
For example, the Saffron expression salesSchema.emps
would be resolved using a call to salesSchema.getTableForMember(new
String[]{"emps" }).
Note that name.length is only greater than 1 for queries originating from JDBC.
getTableForMember in interface RelOptSchemagetTableForMember in interface Prepare.CatalogReadernames - Qualified namepublic RelDataTypeField field(RelDataType rowType, String alias)
field in interface SqlValidatorCatalogReaderpublic boolean matches(String string, String name)
matches in interface SqlValidatorCatalogReaderpublic RelDataType createTypeFromProjection(RelDataType type, List<String> columnNameList)
createTypeFromProjection in interface SqlValidatorCatalogReaderpublic void lookupOperatorOverloads(SqlIdentifier opName, SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList)
SqlOperatorTablelookupOperatorOverloads in interface SqlOperatorTableopName - name of operatorcategory - function category to look up, or null for any matching
operatorsyntax - syntax type of operatoroperatorList - mutable list to which to append matchespublic static SqlOperatorTable operatorTable(String className)
private SqlOperator toOp(SqlIdentifier name, Function function)
private static SqlOperator toOp(RelDataTypeFactory typeFactory, SqlIdentifier name, Function function)
SqlOperator.
The typeFactory argument is technical debt; see [CALCITE-2082]
Remove RelDataTypeFactory argument from SqlUserDefinedAggFunction
constructor.
private static SqlReturnTypeInference infer(ScalarFunction function)
private static SqlReturnTypeInference infer(AggregateFunction function)
private static List<RelDataType> toSql(RelDataTypeFactory typeFactory, List<RelDataType> types)
private static RelDataType toSql(RelDataTypeFactory typeFactory, RelDataType type)
public List<SqlOperator> getOperatorList()
SqlOperatorTablegetOperatorList in interface SqlOperatorTablepublic CalciteSchema getRootSchema()
SqlValidatorCatalogReadergetRootSchema in interface SqlValidatorCatalogReaderpublic RelDataTypeFactory getTypeFactory()
RelOptSchematype factory used to generate
types for this schema.getTypeFactory in interface RelOptSchemapublic void registerRules(RelOptPlanner planner) throws Exception
RelOptSchemaRelOptPlanner.registerSchema(org.apache.calcite.plan.RelOptSchema).registerRules in interface RelOptSchemaExceptionpublic boolean isCaseSensitive()
isCaseSensitive in interface SqlValidatorCatalogReaderpublic SqlNameMatcher nameMatcher()
SqlValidatorCatalogReaderSqlNameMatcher
that matches the case-sensitivity policy.nameMatcher in interface SqlValidatorCatalogReaderCopyright © 2012–2018 The Apache Software Foundation. All rights reserved.