| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
AI Disclosure: This code was written in part by an AI agent.:
AI Disclosure: This code was written in part by an AI agent.:
AI Disclosure: This code was written in part by an AI agent.:
| Ok(()) | ||
| } | ||
|
|
||
| pub fn with_query_planner(&self, planner: Bound<'_, PyAny>) -> PyDataFusionResult<Self> { |
There was a problem hiding this comment.
This API is the main reason for this PR. Here we allow changing out the default query planner with a user provided query planner.
Sorry, something went wrong.
| - name: Build FFI query planner test library | ||
| if: matrix.python-tag == 'abi3' | ||
| uses: PyO3/maturin-action@v1 | ||
| with: | ||
| target: x86_64-unknown-linux-gnu | ||
| manylinux: "2_28" | ||
| working-directory: examples/datafusion-ffi-query-planner-example | ||
| args: --out dist | ||
| rustup-components: rust-std |
There was a problem hiding this comment.
In order to prove that the 3 library approach works where we have different codecs and different execution plans provided, we are adding a second test library. This way we can make sure there is no accidental ability to reach into a foreign code block.
Sorry, something went wrong.
| struct RuntimeAwareQueryPlanner { | ||
| planner: FFI_QueryPlanner, | ||
| } |
There was a problem hiding this comment.
As the docstring says, the purpose of this is to make sure we attach the runtime handle when needed.
Sorry, something went wrong.
| pub fn __datafusion_query_planner__<'py>( | ||
| &self, | ||
| py: Python<'py>, | ||
| ) -> PyResult<Bound<'py, PyCapsule>> { |
There was a problem hiding this comment.
We need our session context to export it's own query planner because we have a use case where one query planner can depend on another. This is already supported by datafusion-distributed, so we want to be certain we support it here.
Sorry, something went wrong.
| #[derive(Clone, Debug)] | ||
| pub(crate) struct PlannerConfig { | ||
| pub max_rows: usize, | ||
| } |
There was a problem hiding this comment.
I'm adding this to the query planner example because it's a very common pattern that we will need custom configs for the query planner, so it is reasonable to need insurance that configs pass over the FFI boundary properly and to use as a demonstration to anyone who is providing such a library.
Sorry, something went wrong.
There was a problem hiding this comment.
this is needed for ballista, thanks Tim for example
Sorry, something went wrong.
The FFI test wheel artifact now bundles two projects, so upload-artifact preserves a `<project>/dist/` prefix instead of placing the wheels at the artifact root. The install step globbed `wheels/*.whl`, which no longer matched them, so the FFI wheels were silently skipped and the FFI unit tests failed with `ModuleNotFoundError: No module named 'datafusion_ffi_example'`. Install the recursive `find` results instead of re-globbing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Appears consistent with the rest of the FFI plumbing
Sorry, something went wrong.
| """ | ||
| self.ctx.add_physical_optimizer_rule(rule) | ||
|
|
||
| def with_query_planner( |
There was a problem hiding this comment.
Generally wonder if this builder pattern feels pythonic. Consistent with what's already here so no action requested. Didn't look at how many withs there are but
ctx = SessionContext(config, planner)feels a little more intuitive than
ctx = SessionContext().with_query_planner(planner)
Sorry, something went wrong.
There was a problem hiding this comment.
Good point! Also worth updating the skill to match this pattern
Sorry, something went wrong.
There was a problem hiding this comment.
thanks @timsaucer cant want to get this integrated
Sorry, something went wrong.
| } | ||
|
|
||
| #[pymethods] | ||
| impl PlannerConfig { |
There was a problem hiding this comment.
Nit, MyPlannerConfig to have names aligned,
Sorry, something went wrong.
| #[derive(Clone, Debug)] | ||
| pub(crate) struct PlannerConfig { | ||
| pub max_rows: usize, | ||
| } |
There was a problem hiding this comment.
this is needed for ballista, thanks Tim for example
Sorry, something went wrong.
| observations: Arc::clone(&self.observations), | ||
| }); | ||
| let runtime = get_tokio_runtime().handle().clone(); | ||
| let ctx_provider = Arc::new(SessionContext::new()) as Arc<dyn TaskContextProvider>; |
There was a problem hiding this comment.
is this session context be parameter of method call on the line 119 ? are those two different sessions ?
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Which issue does this PR close?
Related to #1612. This PR does not close it, but provides the FFI query planner plumbing that a datafusion-distributed integration can build on.
This is part 1 of 3 in the split of #1672. These are enabled as a github stack so you should be able to swab between the 3 PRs in github interface (above, next to the "Open" oval).
Rationale for this change
Extension libraries (for example distributed execution engines) need to supply their own QueryPlanner to a SessionContext without compiling against the datafusion-python crate. This PR exposes the query planner over the FFI boundary, following the same PyCapsule pattern used for table providers and catalogs.
What changes are included in this PR?
Are there any user-facing changes?
New public APIs: SessionContext.with_query_planner and SessionContext.__datafusion_query_planner__. A new example crate ships under examples/. No breaking changes to existing APIs.