本文整理汇总了Java中org.apache.calcite.schema.SchemaPlus.getSubSchema方法的典型用法代码示例。如果您正苦于以下问题:Java SchemaPlus.getSubSchema方法的具体用法?Java SchemaPlus.getSubSchema怎么用?Java SchemaPlus.getSubSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.schema.SchemaPlus
的用法示例。
在下文中一共展示了SchemaPlus.getSubSchema方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTable
import org.apache.calcite.schema.SchemaPlus; //导入方法依赖的package包/类
public Table getTable(SchemaPlus rootSchema){
List<FolderName> components = this.getFolderPath();
SchemaPlus schema = rootSchema.getSubSchema(this.getRoot().getName());
if(schema == null){
throw new IllegalStateException(String.format("Failure finding schema path %s in position 0 of path %s", getRoot().getName(), toPathString()));
}
int i = 1;
for(FolderName folder : components){
schema = schema.getSubSchema(folder.getName());
if(schema == null){
throw new IllegalStateException(String.format("Failure finding schema path %s in position %d of path %s", folder.getName(), i, toPathString()));
}
i++;
}
Table table = schema.getTable(getLeaf().getName());
if(table == null){
throw new IllegalStateException(String.format("Failure finding table in path %s. The schema exists but no table in that schema matches %s", toPathString(), getLeaf().getName()));
}
return table;
}
示例2: searchSchemaTree
import org.apache.calcite.schema.SchemaPlus; //导入方法依赖的package包/类
/** Utility method to search for schema path starting from the given <i>schema</i> reference */
private static SchemaPlus searchSchemaTree(SchemaPlus schema, final List<String> schemaPath) {
for (String schemaName : schemaPath) {
schema = schema.getSubSchema(schemaName);
if (schema == null) {
return null;
}
}
return schema;
}
示例3: searchSchemaTree
import org.apache.calcite.schema.SchemaPlus; //导入方法依赖的package包/类
/** Utility method to search for schema path starting from the given <i>schema</i> reference */
private static SchemaPlus searchSchemaTree(SchemaPlus schema, final List<String> schemaPath) {
for (String schemaName : schemaPath) {
SchemaPlus oldSchema = schema;
schema = schema.getSubSchema(schemaName);
if (schema == null) {
schema = oldSchema.getSubSchema(schemaName.toLowerCase());
if(schema == null){
return null;
}
}
}
return schema;
}
示例4: expandView
import org.apache.calcite.schema.SchemaPlus; //导入方法依赖的package包/类
@Override
public RelRoot expandView(
RelDataType rowType,
String queryString,
SchemaPlus rootSchema, // new root schema
List<String> schemaPath,
List<String> viewPath) {
final CalciteCatalogReader catalogReader = new CalciteCatalogReader(
CalciteSchema.from(rootSchema),
parent.getParserConfig().caseSensitive(),
schemaPath,
parent.getTypeFactory());
SchemaPlus schema = rootSchema;
for (final String path : schemaPath) {
SchemaPlus newSchema = schema.getSubSchema(path);
if (newSchema == null) {
// If the view context is not found, make the root schema as the default schema. If the view is referring to
// any tables not found according to rootSchema, a table not found exception is thrown. It is valid for a view
// context to become invalid at some point.
schema = rootSchema;
break;
}
schema = newSchema;
}
final SqlConverter parser = new SqlConverter(parent, schema, rootSchema, catalogReader);
final RelRoot expanded = expandView(queryString, parser);
parser.getObserver().planExpandView(expanded, schemaPath, parent.getNestingLevel(), queryString);
return expanded;
}
示例5: getNewConverter
import org.apache.calcite.schema.SchemaPlus; //导入方法依赖的package包/类
private SqlConverter getNewConverter(QueryContext context, SqlQuery query, AttemptObserver observerForSubstitution) {
SchemaPlus defaultSchema = context.getRootSchema();
final List<String> sqlContext = query.getContext();
if(sqlContext != null){
for(String schema : sqlContext){
defaultSchema = defaultSchema.getSubSchema(schema);
if(defaultSchema == null){
throw UserException.validationError()
.message("Unable to resolve schema path [%s]. Failure resolving [%s] portion of path.", sqlContext, schema)
.build(logger);
}
}
}
return new SqlConverter(
context.getPlannerSettings(),
defaultSchema,
context.getOperatorTable(),
context,
context.getMaterializationProvider(),
context.getFunctionRegistry(),
context.getSession(),
observerForSubstitution,
context.getStorage(),
context.getSubstitutionProviderFactory());
}
示例6: scanSchema
import org.apache.calcite.schema.SchemaPlus; //导入方法依赖的package包/类
/**
* Scan the schame tree, invoking the visitor as appropriate.
* @param rootSchema the given schema
*/
public void scanSchema(SchemaPlus rootSchema) {
if (!shouldVisitCatalog() || !visitCatalog()) {
return;
}
// Visit this schema and if requested ...
for (String subSchemaName: rootSchema.getSubSchemaNames()) {
final SchemaPlus firstLevelSchema = rootSchema.getSubSchema(subSchemaName);
if (shouldVisitSchema(subSchemaName, firstLevelSchema) && visitSchema(subSchemaName, firstLevelSchema)) {
final AbstractSchema schemaInstance;
try{
schemaInstance = (AbstractSchema) firstLevelSchema.unwrap(AbstractSchema.class).getDefaultSchema();
}catch(Exception ex){
logger.warn("Failure reading schema {}. Skipping inclusion in INFORMATION_SCHEMA.", subSchemaName, ex);
continue;
}
// ... do for each of the schema's tables.
for (String tableName : firstLevelSchema.getTableNames()) {
try {
final TableInfo tableInfo = schemaInstance.getTableInfo(tableName);
if (tableInfo == null) {
// Schema may return NULL for table if the query user doesn't have permissions to load the table. Ignore such
// tables as INFO SCHEMA is about showing tables which the user has access to query.
continue;
}
final Table table;
if (tableInfo.getTable() == null) {
table = schemaInstance.getTable(tableName);
} else {
table = tableInfo.getTable();
}
final TableType tableType = table.getJdbcTableType();
// Visit the table, and if requested ...
if (shouldVisitTable(subSchemaName, tableName, tableType) && visitTable(subSchemaName, tableName, tableInfo)) {
// ... do for each of the table's fields.
RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
for (RelDataTypeField field : tableRow.getFieldList()) {
if (shouldVisitColumn(subSchemaName, tableName, field.getName())) {
visitField(subSchemaName, tableName, field);
}
}
}
} catch (Exception e) {
Joiner joiner = Joiner.on('.');
String path = joiner.join(joiner.join(firstLevelSchema.getTableNames()), tableName);
logger.warn("Failure while trying to read schema for table {}. Skipping inclusion in INFORMATION_SCHEMA.", path, e);;
continue;
}
}
}
}
}