# Apache DataFusion

**Apache DataFusion** 是一款用 Rust 编写的可扩展查询引擎，以 [Apache Arrow](https://www.edgepedia.org/zh/apache-arrow) 的内存列式格式作为其原生数据表示。它提供 SQL 与 DataFrame API，一个列式、流式、多线程、向量化的执行引擎，并内置对 CSV、Parquet、JSON 和 Avro 数据的读取支持；它的设计目标是嵌入其他数据系统之中，而非作为独立数据库使用。<sup>[1](https://datafusion.apache.org/user-guide/introduction.html?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[2](https://datafusion.apache.org/?C=S%3BO%3DA)</sup> DataFusion 由 Apache 软件基金会（Apache Software Foundation）治理，该基金会于 2024 年 4 月 16 日将其确立为顶级项目。<sup>[3](https://apache.org/foundation/board/minutes/DataFusion.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 它是什么 | 一款用 Rust 编写的可扩展查询引擎，以 Apache Arrow 作为内存格式，配有完整的查询规划器、列式流式执行和分区数据源<sup>[2](https://datafusion.apache.org/?C=S%3BO%3DA)</sup> |
| 接口 | SQL 与 DataFrame API；DataFusion Python 和 DataFusion Java 分别提供 Python 与 Java 接口<sup>[1](https://datafusion.apache.org/user-guide/introduction.html?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[2](https://datafusion.apache.org/?C=S%3BO%3DA)</sup> |
| 数据格式 | 内置支持 CSV、Parquet、JSON 和 Avro<sup>[1](https://datafusion.apache.org/user-guide/introduction.html?trk=article-ssr-frontend-pulse_little-text-block)</sup> |
| 项目状态 | 2024 年 4 月 16 日成为 ASF 顶级项目；截至 2026 年 6 月董事会报告，有 58 名提交者和 22 名 PMC 成员<sup>[3](https://apache.org/foundation/board/minutes/DataFusion.html)</sup> |
| 发布 | 55.2.0 版于 2026 年 10 月 7 日发布；多数用户通过 crates.io 上的 `datafusion` crate 安装<sup>[4](https://release-catalog.apache.org/datafusion/index.html)</sup><sup> • </sup><sup>[5](https://datafusion.apache.org/download)</sup> |
| 分发模式 | 面向构建数据库、dataframe 库、机器学习流水线和流式应用的开发者，供其嵌入使用，而非作为终端用户系统运行<sup>[1](https://datafusion.apache.org/user-guide/introduction.html?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[6](https://datafusion.apache.org/user-guide/faq.html?trk=article-ssr-frontend-pulse_little-text-block)</sup> |
| 关键子项目 | Ballista（分布式执行）、Comet（Apache Spark 加速器）、Python、Java 以及 sqlparser-rs<sup>[2](https://datafusion.apache.org/?C=S%3BO%3DA)</sup><sup> • </sup><sup>[3](https://apache.org/foundation/board/minutes/DataFusion.html)</sup> |

## 目标与设计理念

DataFusion 存在的意义就在于被复用。借助 Rust 与 Apache Arrow 的独特能力，它力图成为新兴的高速、以数据为中心的系统——包括数据库、dataframe 库、机器学习和流式应用——的首选查询引擎。<sup>[1](https://datafusion.apache.org/user-guide/introduction.html?trk=article-ssr-frontend-pulse_little-text-block)</sup> 项目列出了三条设计目标：开箱即用、配置最少；通过实现 trait 让所有行为都可定制；保持“架构上乏味”，遵循业界最佳实践，而不追逐未经检验的技术。<sup>[7](https://docs.rs/datafusion/latest/datafusion/?search=APPLY)</sup>

Apache Arrow 为内存数据定义了标准化的列式表示，使 Rust、Python 等不同语言的系统之间能够以零拷贝方式交换数据，并支持向量化的分析处理。<sup>[8](https://datafusion.apache.org/user-guide/arrow-introduction.html)</sup> DataFusion 中的查询以拉取式流水线运行，各算子从自己的输入请求一批批 `RecordBatch`。由于引擎以流式方式工作，结果可以在全部数据处理完毕之前就产生，内存占用始终受限，只有在必要时才溢写到磁盘，而跨多个 CPU 核心并行运行也是水到渠成。<sup>[8](https://datafusion.apache.org/user-guide/arrow-introduction.html)</sup>

## 历史

该项目最初是一个独立的 Rust 查询引擎，后来被捐赠给 Apache Arrow 项目。安迪·格罗夫（Andy Grove）于 2019 年 2 月 4 日发布的公告称其为 Arrow 的 Rust 实现的内存查询引擎，并且最近刚被重新实现为 Arrow 原生。<sup>[9](https://arrow.apache.org/blog/2019/02/04/datafusion-donation/)</sup> 当时它的 SQL 支持仅限于投影、选择以及带可选 `GROUP BY` 子句的简单聚合，并支持 CSV，还计划支持 Parquet。<sup>[9](https://arrow.apache.org/blog/2019/02/04/datafusion-donation/)</sup>

作为 Arrow 的子项目数年之后，DataFusion 于 2024 年 4 月 16 日成为独立的 Apache 顶级项目。2024 年 6 月的董事会报告提到，项目在新治理结构下的首个版本 38.0.0 已发布，并且正在推进逻辑规划提速，以及将 sqlparser-rs 这个 SQL 解析器 crate 纳入 DataFusion 的治理。<sup>[3](https://apache.org/foundation/board/minutes/DataFusion.html)</sup> 此后社区不断壮大：2024 年 6 月有 32 名提交者和 13 名 PMC 成员，到 2024 年 12 月增至 42 名和 14 名，到 2026 年 6 月则达到 58 名提交者和 22 名 PMC 成员。<sup>[3](https://apache.org/foundation/board/minutes/DataFusion.html)</sup>

## 架构与查询处理

DataFusion 采用模块化设计，单个 crate 可以在其他项目中复用。其架构在 SIGMOD 2024 的论文《Apache Arrow DataFusion：一个快速、可嵌入、模块化的分析型查询引擎》中有正式描述，作者包括 InfluxData 的安德鲁·兰姆（Andrew Lamb）和 Space and Time 的沈一杰（Yijie Shen）。<sup>[7](https://docs.rs/datafusion/latest/datafusion/?search=APPLY)</sup><sup> • </sup><sup>[10](https://andrew.nerdnetworks.org/pdf/SIGMOD-2024-lamb.pdf)</sup>

**查询规划与优化。** DataFusion 提供完整的查询规划器，以及一个独立的优化器 crate，其中包含大量 `OptimizerRule` 和 `PhysicalOptimizerRule`，用于重写逻辑计划与物理计划，使它们在计算结果不变的前提下执行得更快。<sup>[2](https://datafusion.apache.org/?C=S%3BO%3DA)</sup><sup> • </sup><sup>[11](https://datafusion.apache.org/library-user-guide/query-optimizer.html)</sup> 优化采用基于代价的模型，依赖表级和列级的统计信息来估算选择率；其中一个重要组件是边界分析，它对 `a > 2500 AND a <= 5000` 这类表达式做区间运算，从而为过滤、连接和投影建立选择率估计。<sup>[11](https://datafusion.apache.org/library-user-guide/query-optimizer.html)</sup>

**执行。** 执行引擎是列式、流式、多线程且向量化的，数据源可以分区。<sup>[2](https://datafusion.apache.org/?C=S%3BO%3DA)</sup> DataFusion 设计为在单个进程内运行，用线程实现并行查询执行。<sup>[6](https://datafusion.apache.org/user-guide/faq.html?trk=article-ssr-frontend-pulse_little-text-block)</sup>

**扩展点。** 用户几乎可以在所有环节定制 DataFusion，包括增加数据源、查询语言、函数和自定义算子。<sup>[2](https://datafusion.apache.org/?C=S%3BO%3DA)</sup> SIGMOD 论文描述了十余个主要扩展 API；例如，一个实现了 `TableProvider` trait 的系统既可以查询内存中的 Arrow 缓冲区，也可以通过 [Arrow Flight](https://www.edgepedia.org/zh/arrow-flight) 从远程服务器流式读取数据，或读取自定义文件格式，同时还能与引擎的表达式表示交互，以实现[谓词下推](https://www.edgepedia.org/zh/predicate-pushdown)。<sup>[10](https://andrew.nerdnetworks.org/pdf/SIGMOD-2024-lamb.pdf)</sup>

## 子项目与用户

若干子项目面向终端用户，并各自有独立文档：DataFusion Python 和 DataFusion Java 分别提供这两种语言的 SQL 与 DataFrame 接口；DataFusion Comet 是基于 DataFusion 的 [Apache Spark](https://www.edgepedia.org/zh/apache-spark) 加速器；DataFusion Ballista 则是一个分布式处理扩展，可让工作负载在多个节点上并行执行。<sup>[2](https://datafusion.apache.org/?C=S%3BO%3DA)</sup> Ballista 在查询执行期间使用 Arrow 内存格式，在磁盘上则使用 Arrow IPC 格式来存放 shuffle 文件以及在执行器之间交换数据。<sup>[12](https://datafusion.apache.org/ballista/contributors-guide/architecture.html)</sup> sqlparser-rs 这个 crate 于 2024 年被纳入项目的治理。<sup>[3](https://apache.org/foundation/board/minutes/DataFusion.html)</sup>

商业系统与开源系统都在这一引擎之上构建。2026 年，亚马逊的 OpenSearch 日志分析引擎采用了一种设计：每条查询先由 [Apache Calcite](https://www.edgepedia.org/zh/apache-calcite) 解析和优化，再把各个操作分派给最能高效执行它的引擎——列式数据上的分析工作交给 Apache DataFusion，搜索谓词交给 Lucene，两者在查询进行到中途时相互移交控制权。<sup>[13](https://www.itpro.com/business/data-and-insights/amazon-opensearch-update-targets-performance-boosts-and-lower-costs-and-at-no-extra-charge-for-users)</sup>

## 与其他系统的比较

项目的常见问题解答（FAQ）将 DataFusion 与同类系统作了如下区分：它面向开发者，而非终端用户或数据科学家；它设计为可嵌入，而非完整的基于文件的 SQL 系统；它由 Apache 软件基金会的流程治理，而非某一家公司或个人；它用 Rust 而非 C/C++ 实现。<sup>[6](https://datafusion.apache.org/user-guide/faq.html?trk=article-ssr-frontend-pulse_little-text-block)</sup> 据 FAQ 所述，例如 DuckDB 用 C/C++ 实现，主要由终端用户直接当作无服务器数据库和查询引擎使用，而不是作为构建此类系统的库；而 Facebook Velox 则充当执行引擎。<sup>[6](https://datafusion.apache.org/user-guide/faq.html?trk=article-ssr-frontend-pulse_little-text-block)</sup>

性能以公开基准测试来衡量。项目的基准测试仓库会针对 DataFusion 及其子项目运行源自业界标准 TPC-H 和 TPC-DS 套件的查询；由于官方 TPC 结果只能由 TPC 成员发布，这些属于衍生的“非 TPC”基准测试，记录的是单条查询的耗时。<sup>[14](https://apache.googlesource.com/datafusion-benchmarks/)</sup> SIGMOD 2024 论文通过与 DuckDB 的对比表明，开放标准和可扩展设计并不妨碍性能上的竞争力。<sup>[10](https://andrew.nerdnetworks.org/pdf/SIGMOD-2024-lamb.pdf)</sup> 在分布式工作负载方面，Ballista 公布的 TPC-H SF1000 运行总耗时为 502.43 秒，而在同一集群上，原生 Spark 4.1.3 为 898.17 秒，带 Comet 1.1.0-rc2 的 Spark 4.1.3 为 455.09 秒；作为参照还列入了 Trino 483 的 411.62 秒，但这并非同类可比。<sup>[15](https://datafusion.apache.org/ballista/contributors-guide/benchmarking/)</sup>

## References

1. [Introduction, Apache DataFusion documentation](https://datafusion.apache.org/user-guide/introduction.html?trk=article-ssr-frontend-pulse_little-text-block)
2. [Apache DataFusion documentation home](https://datafusion.apache.org/?C=S%3BO%3DA)
3. [Board history: DataFusion, Apache Software Foundation](https://apache.org/foundation/board/minutes/DataFusion.html)
4. [Apache DataFusion, Apache Release Catalog](https://release-catalog.apache.org/datafusion/index.html)
5. [Download, Apache DataFusion documentation](https://datafusion.apache.org/download)
6. [Frequently Asked Questions, Apache DataFusion documentation](https://datafusion.apache.org/user-guide/faq.html?trk=article-ssr-frontend-pulse_little-text-block)
7. [datafusion crate documentation, docs.rs](https://docs.rs/datafusion/latest/datafusion/?search=APPLY)
8. [Gentle Arrow Introduction, Apache DataFusion documentation](https://datafusion.apache.org/user-guide/arrow-introduction.html)
9. [DataFusion: A Rust-native Query Engine for Apache Arrow, Apache Arrow blog, 4 February 2019](https://arrow.apache.org/blog/2019/02/04/datafusion-donation/)
10. [Andrew Lamb et al., Apache Arrow DataFusion: a Fast, Embeddable, Modular Analytic Query Engine, SIGMOD 2024](https://andrew.nerdnetworks.org/pdf/SIGMOD-2024-lamb.pdf)
11. [Query Optimizer, Apache DataFusion documentation](https://datafusion.apache.org/library-user-guide/query-optimizer.html)
12. [Ballista Architecture, Apache DataFusion Ballista documentation](https://datafusion.apache.org/ballista/contributors-guide/architecture.html)
13. [Amazon OpenSearch update targets performance boosts and lower costs, ITPro, July 2026](https://www.itpro.com/business/data-and-insights/amazon-opensearch-update-targets-performance-boosts-and-lower-costs-and-at-no-extra-charge-for-users)
14. [Apache DataFusion Benchmarks](https://apache.googlesource.com/datafusion-benchmarks/)
15. [Benchmarking, Apache DataFusion Ballista documentation](https://datafusion.apache.org/ballista/contributors-guide/benchmarking/)

---
*Initially written Oct 26, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › SQL and query languages

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/apache-datafusion

English original: https://www.edgepedia.org/apache-datafusion
