当前位置: 首页>>代码示例>>Java>>正文


Java SchemaPlus.getSubSchemaNames方法代码示例

本文整理汇总了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.
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:13,代码来源:QueryContext.java

示例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);
        }
      }
    }
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:38,代码来源:RecordGenerator.java

示例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;
        }

      }
    }
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:62,代码来源:InfoSchemaRecordGenerator.java


注:本文中的org.apache.calcite.schema.SchemaPlus.getSubSchemaNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。