本文整理汇总了Java中org.apache.calcite.schema.SchemaPlus.getSubSchemaNames方法的典型用法代码示例。如果您正苦于以下问题:Java SchemaPlus.getSubSchemaNames方法的具体用法?Java SchemaPlus.getSubSchemaNames怎么用?Java SchemaPlus.getSubSchemaNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.schema.SchemaPlus
的用法示例。
在下文中一共展示了SchemaPlus.getSubSchemaNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSchemasToCloseList
import org.apache.calcite.schema.SchemaPlus; //导入方法依赖的package包/类
private void addSchemasToCloseList(final SchemaPlus tree, final List<AutoCloseable> toClose) {
for(String subSchemaName : tree.getSubSchemaNames()) {
addSchemasToCloseList(tree.getSubSchema(subSchemaName), toClose);
}
try {
AbstractSchema drillSchemaImpl = tree.unwrap(AbstractSchema.class);
toClose.add(drillSchemaImpl);
} catch (ClassCastException e) {
// Ignore as the SchemaPlus is not an implementation of Drill schema.
}
}
示例2: scanSchema
import org.apache.calcite.schema.SchemaPlus; //导入方法依赖的package包/类
/**
* Recursively scans the given schema, invoking the visitor as appropriate.
* @param schemaPath the path to the given schema, so far
* @param schema the given schema
*/
private void scanSchema(String schemaPath, SchemaPlus schema) {
// Recursively scan any subschema.
for (String name: schema.getSubSchemaNames()) {
scanSchema(schemaPath +
(schemaPath == "" ? "" : ".") + // If we have an empty schema path, then don't insert a leading dot.
name, schema.getSubSchema(name));
}
// Visit this schema and if requested ...
if (shouldVisitSchema(schemaPath, schema) && visitSchema(schemaPath, schema)) {
// ... do for each of the schema's tables.
for (String tableName: schema.getTableNames()) {
Table table = schema.getTable(tableName);
if (table == 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 use has access to query.
continue;
}
// Visit the table, and if requested ...
if (shouldVisitTable(schemaPath, tableName) && visitTable(schemaPath, tableName, table)) {
// ... do for each of the table's fields.
RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
for (RelDataTypeField field: tableRow.getFieldList()) {
visitField(schemaPath, tableName, field);
}
}
}
}
}
示例3: 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;
}
}
}
}
}