升级指南

DataFusion 47.0.0

师成师成· 更新于 2026-09-28· 阅读 7 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

升级指南

DataFusion 47.0.0

本节介绍 DataFusion 47.0.0 版本中的一些重大变更。

以下是一些升级 PR 示例,展示了从 DataFusion 46.0.0 升级时所需做的更改:

升级到 arrow-rs 和 arrow-parquet 55.0.0 以及 object_store 0.12.0

底层的 arrow 和 parquet 库中有若干 API 发生了变更,改用 u64 而非 usize,以便更好地支持 WASM(参见 devlive-community/knowforge#7371 和 [devlive-community/knowforge#6961])。

此外,ObjectStore::list 和 ObjectStore::list_with_offset 已改为返回 static 生命周期(参见 devlive-community/knowforge#6619)。

这需要偶尔将 usize 转换为 u64,同时还需要对 ObjectStore 的实现进行修改,例如

impl Objectstore {
    ...
    // The range is now a u64 instead of usize
    async fn get_range(&self, location: &Path, range: Range<u64>) -> ObjectStoreResult<Bytes> {
        self.inner.get_range(location, range).await
    }
    ...
    // the lifetime is now 'static instead of `_ (meaning the captured closure can't contain references)
    // (this also applies to list_with_offset)
    fn list(&self, prefix: Option<&Path>) -> BoxStream<'static, ObjectStoreResult<ObjectMeta>> {
        self.inner.list(prefix)
    }
}

ParquetObjectReader 已更新,不再需要提供对象大小(可以通过一次后缀请求获取)。详情请参阅 devlive-community/knowforge#7334。

DataFusion 46.0.0 中的模式:

let meta: ObjectMeta = ...;
let reader = ParquetObjectReader::new(store, meta);

DataFusion 47.0.0 中的模式:

let meta: ObjectMeta = ...;
let reader = ParquetObjectReader::new(store, location)
  .with_file_size(meta.size);

DisplayFormatType::TreeRender

DataFusion 现已支持 tree 风格的 EXPLAIN 计划。ExecutionPlan 的实现还必须提供 DisplayFormatType::TreeRender 格式的描述。该描述可以与现有的 DisplayFormatType::Default 相同。

移除已弃用的 API

本版本移除了若干 API。这些 API 要么此前已被弃用,要么难以正确使用,例如多个各不相同的 ScalarUDFImpl::invoke* API。更多详情参见 devlive-community/knowforge#15130、devlive-community/knowforge#15123 和 devlive-community/knowforge#15027。

FileScanConfig –> FileScanConfigBuilder

此前,FileScanConfig::build() 会直接创建 ExecutionPlan。在 DataFusion 47.0.0 中,这一做法已改为使用 FileScanConfigBuilder。详情参见 devlive-community/knowforge#15352。

DataFusion 46.0.0 中的写法:

let plan = FileScanConfig::new(url, schema, Arc::new(file_source))
  .with_statistics(stats)
  ...
  .build()

DataFusion 47.0.0 中的模式:

let config = FileScanConfigBuilder::new(url, Arc::new(file_source))
  .with_statistics(stats)
  ...
  .build();
let scan = DataSourceExec::from_data_source(config);

评论

登录后参与评论

正在加载评论…