Skip to content

feat(python): Plug into DataFusion Python natively through a custom FFI query planner - #2588

Merged
milenkovicm merged 25 commits into
apache:mainfrom
milenkovicm:feat_python_query_planner
Oct 26, 2026
Merged

milenkovicm merged 25 commits into
apache:mainfrom
milenkovicm:feat_python_query_planner

Conversation

@milenkovicm

@milenkovicm milenkovicm commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

import ballista

from ballista import BallistaSessionContext

import datafusion
# BallistaSessionContext replaces SessionContext
# from datafusion import SessionContext
from datafusion import DataFrame

# replace datafusion SessionContext
# ctx = SessionContext()
# with BallistaSessionContext
ctx = BallistaSessionContext(address=f"df://localhost:50050")

# to run query distributed ob ballista
ctx.sql("SELECT 1 as r").show()

Closes #.
Part of #2618

Rationale for this change

  • update to datafusion python 55
  • use FFI query planner released with datafusion python 55, to make ballista integration just a tin wrapper on top of datfusion-puthon

What changes are included in this PR?

  • removed DistributedDataFrame and BallistaContext
  • removed redefining meta classes for redefinition of DistributedDataFrame and BallistaContext
  • removed methods which are tied to DistributedDataFrame and BallistaContext, i would argue they should not be there in the first place
  • use FFI datafusion python query planner

Are there any user-facing changes?

yes api changed, some methods and classes disappeared, as python integration was experimental users should have expected

this PR builds on @timsaucer's PR #2252

Follow up

  • support for distributed python UDFs

@milenkovicm
milenkovicm marked this pull request as draft October 12, 2026 18:18
@milenkovicm
milenkovicm force-pushed the feat_python_query_planner branch 4 times, most recently from e57d4d3 to 32b0078 Compare October 12, 2026 19:42
@milenkovicm

Copy link
Copy Markdown
Contributor Author

hey @timsaucer this is follow up on your #2252 after datafusion python 55 released,

uv run --no-project pytest

FAILED python/tests/test_context.py::test_write_csv - Exception: DataFusion error: FFI error: This feature is not implemented: FFI does not support decode_file_format
FAILED python/tests/test_context.py::test_write_parquet - Exception: DataFusion error: FFI error: This feature is not implemented: FFI does not support decode_file_format
FAILED python/tests/test_context.py::test_write_json - Exception: DataFusion error: FFI error: This feature is not implemented: FFI does not support decode_file_format

I have removed good part of ballista specific code, happy day scenario works, it connects to ballista and runs the query, but write_ methods are failing, and i'm not sure if there is something else needed.

any ideas what could be done ?

cc @andygrove another pair of eyes would help (thanks)

@milenkovicm
milenkovicm force-pushed the feat_python_query_planner branch from 32b0078 to d568260 Compare October 12, 2026 19:46
@milenkovicm

Copy link
Copy Markdown
Contributor Author

there is comment apache/datafusion-python#1679 (comment) but it makes no sense to me, perhaps @timsaucer may have better idea what claude wants to say :D

Comment thread ballista/core/src/serde/mod.rs Resolved
@milenkovicm milenkovicm changed the title feat: update to datafusion 55 and remove distributed dataframe feat: use datafusion python FFI for integration with ballista Oct 14, 2026
@milenkovicm milenkovicm changed the title feat: use datafusion python FFI for integration with ballista feat: use datafusion python FFI for integration (native datafusion python support) Oct 14, 2026
@milenkovicm
milenkovicm marked this pull request as ready for review October 14, 2026 18:59

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pushing this through @milenkovicm, and @timsaucer for the groundwork in #2252! Moving to a real DataFusion SessionContext is a big improvement. Every DataFrame method now runs on the cluster, where before only the few the metaclass wrapped did.

I built this branch and main locally and ran a few probes against setup_test_cluster(). I left comments on a config regression, EXPLAIN ANALYZE and some API cleanup. I'm requesting changes mainly for the config issue, since it makes queries fail that work on main today.

Since this removes DistributedDataFrame, turns BallistaSessionContext into a function and changes what config does, could we also add the api-change label and a Python client section to docs/source/upgrading/56.0.0.md?

Comment thread python/python/ballista/extension.py Resolved
Comment thread python/src/query_planner.rs Resolved
Comment thread ballista/core/src/serde/mod.rs Resolved
Comment thread python/src/config.rs Resolved
Comment thread python/python/ballista/__init__.py Resolved
Comment thread python/python/ballista/jupyter.py Resolved
@milenkovicm
milenkovicm marked this pull request as draft October 16, 2026 13:43
@milenkovicm

Copy link
Copy Markdown
Contributor Author

thanks @andygrove comments make sense, will follow up over the weekend, converting to PR draft until then

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 17, 2026
@milenkovicm
milenkovicm force-pushed the feat_python_query_planner branch from 3f8c511 to b1ad4ea Compare October 17, 2026 12:05
@milenkovicm
milenkovicm force-pushed the feat_python_query_planner branch from 4e32cd5 to bdb3ce5 Compare October 26, 2026 11:08
@milenkovicm

Copy link
Copy Markdown
Contributor Author

thanks @andygrove!
will merge this on green CI

@milenkovicm
milenkovicm merged commit b89a4e4 into apache:main Oct 26, 2026
37 checks passed
andygrove added a commit to andygrove/datafusion-ballista that referenced this pull request Oct 31, 2026
The workspace is pinned to a DataFusion commit on main, and the Python
crate took the Ballista crates by path, so its build pulled that DataFusion
in next to the DataFusion 55 that datafusion-python needs, and
python/Cargo.lock fell out of date with the manifests.

The published 55.0.0 crates cannot stand in: the Python client uses core
changes made after that release (apache#2588). Take the Ballista crates from
72d6807, the last commit on main before the pin, and keep the path
dependencies commented for when the workspace is back on a released
DataFusion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants