Apache DataFusion CLI
$ datafusion-cli 基金会 低风险datafusion-cli 是 Apache DataFusion 官方命令行查询引擎。基于 Rust 与 Apache Arrow 构建,可通过 -c 对本地或 S3/GCS 上的 Parquet、CSV、Avro 与 NDJSON 文件执行向量化 SQL 查询,并支持 --format json / --format nd-json 输出。
brew install datafusion 在本地或针对 S3 Parquet 执行向量化 Arrow SQL 并输出 --format json,避免把数 MB 原始数据文件载入 Agent 内存。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持 -c 单次执行、-f SQL 脚本、--format json / nd-json / csv 与 --quiet 模式。
- Supports
-c,--format json, and--format nd-json
默认执行只读 SQL 查询;仅显式执行 COPY ... TO SQL 语句时写入文件。
- In-process read-only query execution unless
COPYis invoked
Rust 二进制可通过 Homebrew、cargo install datafusion-cli 与官方发布包在 macOS、Linux、Windows 安装。
- Distributed via
brew install datafusionandcargo
向量化 Arrow SQL 引擎高速处理 Parquet、CSV、JSON、Avro 与 S3/GCS 对象存储。
- Vectorized Arrow engine with S3/GCS and Parquet support
Apache 软件基金会顶级项目(apache/datafusion),Apache-2.0 协议且开发极为活跃。
- Official ASF
apache/datafusionrepository
datafusion.apache.org 提供完整的官方 CLI 用户指南与 SQL 参考。
- Official CLI docs at datafusion.apache.org
安全边界、鉴权与放权指南
本地文件无需凭据;访问对象存储 URI 时读取 AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_REGION 或 GOOGLE_APPLICATION_CREDENTIALS 环境变量。
Apache-2.0 开源 CLI,工具本身免费(查询远端 S3/GCS 会产生云请求与流量费用)。
# datafusion-cli Agent Rules - Always pass `-c "<sql>"` (or `-f <script.sql>`) and `--format json` / `--format nd-json`; bare `datafusion-cli` enters an interactive REPL. - Include `LIMIT` on `SELECT` queries and avoid `COPY ... TO` unless file export is requested.
Agent 高频安全命令配方
只读查询(安全推荐)
datafusion-cli --format json -c "SELECT * FROM 'events.parquet' LIMIT 20"
对 Parquet 执行带行数限制的 SQL 查询并以 JSON 输出,不进入交互式 REPL。
datafusion-cli --format nd-json -c "DESCRIBE 'events.parquet'"
以换行分隔 JSON 格式打印列名与 Arrow 数据类型。
核心优势
- + 基于 Rust/Arrow 的极速向量化 SQL 执行,覆盖 Parquet、Avro、CSV 与 JSON。
- + 原生
--format json与--format nd-json搭配-c十分顺手。 - + 开箱支持
s3://与gs://对象存储查询。
注意事项与踩坑点
- ! 未传
-c或-f直接运行datafusion-cli会进入交互式 SQL REPL。 - ! 在受限沙箱查询超大未分区数据集时建议配合
-m限制内存。