datafusion
Build and run queries against data
What it is and what it does
DataFusion is a Python library that wraps Apache Arrow's in-memory query engine, allowing you to execute SQL queries and DataFrame operations against structured data files (Parquet, CSV, JSON) without loading everything into memory at once. It includes a query optimizer that rewrites logical plans for efficiency and supports user-defined Python functions (UDFs and UDAFs) embedded in SQL queries. The library is designed as a foundation for building data systems in Python—projects like Dask SQL and distributed engines (Ballista, Ray) use its Python bindings for SQL parsing and query planning.
You work with DataFusion by creating a SessionContext, registering data sources (files or in-memory DataFrames), and then executing queries either as SQL strings or using a DataFrame API. Results can be collected as PyArrow batches, converted to Pandas DataFrames, or serialized in Substrait format. The package depends on cloudpickle, pyarrow, and typing-extensions, and is actively maintained with prebuilt wheels for common platforms.
Use it for:
- Query large Parquet files with SQL without loading the entire dataset into memory
- Build a SQL interface over CSV or JSON data sources for exploratory analysis
- Register Python UDFs in SQL queries to apply custom logic during query execution
- Convert query results to Pandas DataFrames for visualization or further analysis
- Serialize and deserialize query plans in Substrait format for cross-system compatibility
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
DataFusion is a Python binding to Apache Arrow's in-memory query engine, enabling SQL and DataFrame-based queries against CSV, Parquet, and JSON data with built-in query optimization.
Yes. DataFusion is actively maintained, has no known vulnerabilities, and offers a practical way to execute optimized SQL queries against structured data files in Python. Install it if you need SQL query capabilities over Parquet/CSV/JSON without building a custom query engine or loading entire datasets into memory. The medium install friction is offset by prebuilt wheels and straightforward setup.
Install
datafusion on PyPI
pip
pip install datafusionuv
uv add datafusionpoetry
poetry add datafusionInstalling datafusion
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for macOS (x86_64, arm64), Linux (x86_64, aarch64), and Windows (amd64) across Python 3.10–3.14. Active maintenance with recent releases.
License in practice
Licensed under Apache License 2.0 (permissive). Safe for commercial and proprietary use with standard attribution requirements.
Quickstart
pip install datafusion
from datafusion import SessionContext
ctx = SessionContext()
ctx.register_parquet('taxi', 'data.parquet')
df = ctx.sql('SELECT * FROM taxi WHERE passenger_count > 1')
results = df.collect()
Requires Python 3.10 or later. Parquet/CSV/JSON files must be accessible at query time.
Verify before relying
- Performance characteristics and typical query latency compared to alternatives
- Memory overhead and scalability limits for large datasets
- Completeness of SQL dialect support and known limitations
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 3 — cloudpickle, pyarrow, typing-extensions |
| Maintenance | actively maintained — 46 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,474,966/month — #2,295 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: datafusion-54.0.0-cp310-abi3-macosx_10_12_x86_64.whl; datafusion-54.0.0-cp310-abi3-macosx_11_0_arm64.whl; datafusion-54.0.0-cp310-abi3-manylinux_2_28_aarch64.whl; datafusion-54.0.0-cp310-abi3-manylinux_2_28_x86_64.whl; datafusion-54.0.0-cp310-abi3-win_amd64.whl; datafusion-54.0.0-cp314-cp314t-macosx_10_12_x86_64.whl; datafusion-54.0.0-cp314-cp314t-macosx_11_0_arm64.whl; datafusion-54.0.0-cp314-cp314t-manylinux_2_28_aarch64.whl; datafusion-54.0.0-cp314-cp314t-manylinux_2_28_x86_64.whl; datafusion-54.0.0-cp314-cp314t-win_amd64.whl
Keywords: dataframe, datafusion, query-engine, rust
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
datafusion-query-builderBuilds DataFusion SQL queries programmatically…
permissive · top 15,000 on PyPI
pyarrowpyarrow provides Python bindings to Apache…
permissive · top 100 on PyPI
vortex-dataVortex-data provides Python bindings to work…
permissive · top 15,000 on PyPI
ibis-frameworkIbis is a portable Python dataframe library…
permissive · top 5,000 on PyPI
substraitProvides a Python interface to construct,…
permissive · top 15,000 on PyPI
apache-airflow-providers-common-sqlProvides common SQL operators, hooks, and…
permissive · top 1,000 on PyPI
duckdbDuckDB is an in-process SQL database engine…
permissive · top 1,000 on PyPI
pandasqlpandasql lets you query pandas DataFrames using…
unclear · top 5,000 on PyPI
polarsPolars is a DataFrame query engine written in…
permissive · top 1,000 on PyPI
fastparquetfastparquet reads and writes Apache Parquet…
permissive · top 5,000 on PyPI