dremio 的InformationSchemaCatalog 服务一

InformationSchemaCatalog 服务实现了模仿information_schema的能力,让我们可以更好的在bi 工具以及其他系统使用

接口定义

/**
 * Facet of the catalog service that provides metadata with an information_schema like API.
 * <p>
 * The metadata provided may not satisfy the configured metadata policy requirement of various sources; the reads
 * are directly from the KVStore without an inline refresh of the metadata.
 */
interface InformationSchemaCatalog {
 
  /**
   * List catalogs that satisfy the given search query.
   *
   * @param searchQuery        search query, may be null
   * @return iterator of catalogs
   */
  Iterator<Catalog> listCatalogs(SearchQuery searchQuery);
 
  /**
   * List schemata that satisfy the given search query.
   *
   * @param searchQuery        search query, may be null
   * @return iterator of schemata
   */
  Iterator<Schema> listSchemata(SearchQuery searchQuery);
 
  /**
   * List tables (datasets) that satisfy the given search query.
   *
   * @param searchQuery        search query, may be null
   * @return iterator of tables
   */
  Iterator<Table> listTables(SearchQuery searchQuery);
 
  /**
   * List views that satisfy the given search query.
   *
   * @param searchQuery        search query, may be null
   * @return iterator of views
   */
  Iterator<View> listViews(SearchQuery searchQuery);
 
  /**
   * List columns of all datasets that satisfy the given search query.
   *
   * @param searchQuery        search query, may be null
   * @return iterator of columns
   */
  Iterator<TableSchema> listTableSchemata(SearchQuery searchQuery);
 
}

子类

 

 


从上图可以看出InformationSchemaCatalog 的直接实现是没有包含PrivilegeCatalog,catalog 的子类需要实现此接口,具体的实现InformationSchemaCatalogImpl
核心依赖NamespaceService(此服务比较重要,dremio 利用了key,value 存储解决数据状态管理)
比如数据表获取的

 
 @Override
  public Iterator<Table> listTables(SearchQuery searchQuery) {
    // 基于NamespaceService进行处理
    final Iterable<Map.Entry<NamespaceKey, NameSpaceContainer>> searchResults =
      userNamespace.find(getCondition(searchQuery));
 
    return StreamSupport.stream(searchResults.spliterator(), false)
      .filter(IS_NOT_INTERNAL)
      .filter(IS_DATASET)
      .map(input -> {
        final String sourceName = input.getKey().getRoot();
 
        final TableType tableType;
        if (input.getValue().getDataset().getType() == DatasetType.VIRTUAL_DATASET) {
          tableType = TableType.VIEW;
        } else if ("sys".equals(sourceName) || "INFORMATION_SCHEMA".equals(sourceName)) {
         // 包含了sys 以及INFORMATION_SCHEMA 的处理,sys 数据dremio 内部的,INFORMATION_SCHEMA 属于标准的INFORMATION_SCHEMA
          tableType = TableType.SYSTEM_TABLE;
        } else {
          tableType = TableType.TABLE;
        }
 
        return Table.newBuilder()
          .setCatalogName(DEFAULT_CATALOG_NAME)
          .setSchemaName(input.getKey().getParent().toUnescapedString())
          .setTableName(input.getKey().getName())
          .setTableType(tableType)
          .build();
      })
      .iterator();
  }

说明

InformationSchemaCatalog 的实现,完善了dremio 对于bi 以及jdbc 周边工具的集成,实现上不难,主要是利用了NamespaceService 服务

参考资料

sabot/kernel/src/main/java/com/dremio/exec/catalog/InformationSchemaCatalog.java
https://docs.dremio.com/software/sql-reference/information-schema/tables/

posted on   荣锋亮  阅读(34)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-07-17 errors 一个很不错的golang 异常处理包
2020-07-17 使用nginx limit_rate 解决用户下载限速
2020-07-17 EdgeDB 1.0 Alpha 4 发布了
2020-07-17 静态文件请求路径 rewrite nginx && openresty 实现
2019-07-17 zeebe 0.20.0 发布生产可用了!
2019-07-17 手工部署yugabyte的几点说明
2019-07-17 yugabyte docker-compose 运行试用

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示