dremio 24 版本一个隐藏的Vacuum功能

dremio 24 版本支持对于apache iceberg 的 Vacuum,只是这个功能官方文档没有说明,但是通过源码我们可以看处理

功能开启

需要通过配置支持项处理

 

 

使用

官方支持的命令还是比较全的,只是目前官方文档暂时还是没写
整体的能力(通过测试方法看到的)

 

 

 

 

 


参考使用

 

 

dremio 内部处理

主要是通过VacuumHandler(TableManagementDirectHandler 子类)
处理处理核心是实现了execute 方法,参加如下
可以看出是使用了catalog 的vacuumTable 方法

 
@Override
protected void execute(Catalog catalog,
                     SqlNode sqlNode,
                     NamespaceKey path,
                     DatasetConfig datasetConfig,
                     TableMutationOptions tableMutationOptions) throws Exception {
final SqlVacuum sqlVacuum = SqlNodeUtil.unwrap(sqlNode, SqlVacuum.class);
catalog.vacuumTable(path, datasetConfig, sqlVacuum.getVacuumOption(), tableMutationOptions);
}

catalog 实现的处理(属于存储插件的能力,当前主要是文件系统的)

@Override
public void vacuumTable(NamespaceKey tableSchemaPath,
                      DatasetConfig datasetConfig,
                      SchemaConfig schemaConfig,
                      VacuumOption vacuumOption,
                      TableMutationOptions tableMutationOptions) {
// 此处会使用IcebergNessieModel
IcebergModel icebergModel = getIcebergModel();
icebergModel.vacuumTable(
  icebergModel.getTableIdentifier(validateAndGetPath(tableSchemaPath, schemaConfig.getUserName()).toString()), vacuumOption);
}

命令处理

@Override
public void vacuumTable(IcebergTableIdentifier tableIdentifier, VacuumOption vacuumOption) {
IcebergCommand icebergCommand = getIcebergCommandWithMetricStat(tableIdentifier);
icebergCommand.expireSnapshots(
  vacuumOption.getOlderThanInMillis(),
  vacuumOption.getRetainLast());
}

实际命令处理参考IcebergBaseCommand

说明

通过测试发现目前实际上对于数据以及元数据暂时是不删除的(关于配置部分的官方对于iceberg 的表属性没有配置),而且官方对于数据表优化部分文档也说明了
此功能比较适合与新版本的表优化功能一起使用,可以更好的进行数据管理,可以实现比较强大的数据湖管理了,很不错的好功能

参考资料

sabot/kernel/src/main/java/com/dremio/exec/planner/sql/handlers/direct/VacuumHandler.java
sabot/kernel/src/main/java/com/dremio/exec/ExecConstants.java
sabot/kernel/src/main/java/com/dremio/exec/catalog/DatasetCatalog.java
sabot/kernel/src/main/java/com/dremio/exec/catalog/MutablePlugin.java
sabot/kernel/src/main/java/com/dremio/exec/store/dfs/FileSystemPlugin.java
sabot/kernel/src/main/java/com/dremio/exec/store/iceberg/IcebergModelCreator.java
sabot/kernel/src/main/java/com/dremio/exec/store/iceberg/nessie/IcebergNessieModel.java
sabot/kernel/src/main/java/com/dremio/exec/store/iceberg/model/IcebergCommand.java
sabot/kernel/src/main/java/com/dremio/exec/store/iceberg/model/IcebergBaseCommand.java
sabot/kernel/src/main/java/com/dremio/exec/planner/sql/handlers/direct/TableManagementDirectHandler.java
https://docs.dremio.com/software/sql-reference/sql-commands/apache-iceberg-tables/
https://iceberg.apache.org/docs/latest/maintenance/

posted on 2023-02-14 12:56  荣锋亮  阅读(43)  评论(0编辑  收藏  举报

导航