dremio 文件系统支持view创建&一些问题

实际上如果了解apache drill 会知道drill 是支持在本地活着分布式创建view,实际上dremio 也是可以支持的,但是
此玩法不太符合官方的设计思想,给禁用了

FileSystemPlugin check 处理

  • 参考代码
public boolean createOrUpdateView(NamespaceKey tableSchemaPath,
                                    SchemaConfig schemaConfig,
                                    View view,
                                    ViewOptions viewOptions) throws IOException {
  // 哪怕配置了LEGACY_STORE_VIEWS_ENABLED
  // 添加legacy.dremio.store.views.enabled 又会触发dremio 配置的一个check 处理
//  而且web 页面直接对于文件系统的view 存储进行了过滤,对于支持创建的只能使用系统用户$dremio$
    if (!Boolean.getBoolean(DremioConfig.LEGACY_STORE_VIEWS_ENABLED)) {
      throw UserException.parseError()
        .message("Unable to create or update view. Filesystem views are not supported.")
        .build(logger);
    } else if (!getMutability().hasMutationCapability(MutationType.VIEW, schemaConfig.isSystemUser())) {
      throw UserException.parseError()
        .message("Unable to create or update view. Schema [%s] is immutable for this user.", tableSchemaPath.getParent())
        .build(logger);
    }
 
    Path viewPath = getViewPath(tableSchemaPath.getPathComponents());
    FileSystem fs = createFS(schemaConfig.getUserName());
    boolean replaced = fs.exists(viewPath);
    final Set<PosixFilePermission> viewPerms =
            MorePosixFilePermissions.fromOctalMode(schemaConfig.getOption(ExecConstants.NEW_VIEW_DEFAULT_PERMS_KEY).getStringVal());
    try (OutputStream stream = FileSystemUtils.create(fs, viewPath, viewPerms)) {
      lpPersistance.getMapper().writeValue(stream, view);
    }
    return replaced;
  }

dremio 配置check配置

  • 参考代码
 private void check(){
    // 会基于inner 配置进行reference 的check 确保不会配置多余的配置
    final Config inner = getInnerConfig();
    final Config ref = reference.resolve();
 
    // make sure types are right
    inner.checkValid(ref);
 
    // make sure we don't have any extra paths. these are typically typos.
    List<String> invalidPaths = new ArrayList<>();
    for(Entry<String, ConfigValue> entry : inner.entrySet()){
      if (DEPRECATED_PATHS.contains(entry.getKey())) {
        logger.warn("Property [{}] is deprecated. Please remove it from the conf file [dremio.conf].", entry.getKey());
        continue;
      }
      if(!ref.hasPath(entry.getKey())){
        invalidPaths.add(entry.getKey());
      }
    }
 
    if(!invalidPaths.isEmpty()){
      StringBuilder sb = new StringBuilder();
      sb.append("Failure reading configuration file. The following properties were invalid:\n");
      for(String s : invalidPaths){
        sb.append("\t");
        sb.append(s);
        sb.append("\n");
      }
 
      throw new RuntimeException(sb.toString());
    }
  }
  • dremio 配置的参考配置文件

位置在common/legacy/src/main/resources/dremio-reference.conf
一个include 是比较重要的,此处我们可以配置额外的信息, 这样可以确保参考配置比较多,规避check 问题

include classpath("dremio-reference-ext.conf")
 
paths: {
 
  # the local path for dremio to store data.
  local: "/tmp/dremio",
  common/legacy/src/main/resources/dremio-reference.conf

解决方法,就是添加一个dremio-reference-ext.conf文件到dremio 的conf 运行目录下,里边包含了legacy.dremio.store.views.enabled
但是因为dremio FileSystemPlugin 对于配置的处理就是有bug,而且没有直接引入DremioConfig的实例,目前是不能直接快速的
通过配置解决的,通过options 配置是实际上是一个不错的选择

说明

目前dremio 对于分布式文件系统是不支持直接进行view 的创建了,更加标准的做法是通过space 或者支持多版本的nessie catalog 服务
如果还是希望支持,就需要自己修改文件系统插件的代码了

参考资料

https://drill.apache.org/docs/create-view/
sabot/kernel/src/main/java/com/dremio/exec/store/dfs/FileSystemPlugin.java

posted on 2024-03-05 08:01  荣锋亮  阅读(10)  评论(0编辑  收藏  举报

导航