-
Notifications
You must be signed in to change notification settings - Fork 150
Prepare for DF52 release #1337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Prepare for DF52 release #1337
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b80cdf5
Prepare for DF52 release
timsaucer 217514f
Update datafusion to point to release version
timsaucer a13ab94
round now respects decimal
timsaucer 5e09e1e
Update pathlib
timsaucer 9749c3c
Update documentation
timsaucer 9a7244e
Commit copilot suggestions
timsaucer 0d7bb36
Pass codec capsule to table providers
timsaucer bea73b1
Simplify codec passing around
timsaucer b01ddde
Update signatures for FFI passing of logical codec around
timsaucer 1605ff3
Update upgrade guide for new method signature
timsaucer 590da40
Add more unit tests to cover FFI providers
timsaucer d4ceedf
Missing run command
timsaucer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| .. Licensed to the Apache Software Foundation (ASF) under one | ||
| .. or more contributor license agreements. See the NOTICE file | ||
| .. distributed with this work for additional information | ||
| .. regarding copyright ownership. The ASF licenses this file | ||
| .. to you under the Apache License, Version 2.0 (the | ||
| .. "License"); you may not use this file except in compliance | ||
| .. with the License. You may obtain a copy of the License at | ||
|
|
||
| .. http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| .. Unless required by applicable law or agreed to in writing, | ||
| .. software distributed under the License is distributed on an | ||
| .. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| .. KIND, either express or implied. See the License for the | ||
| .. specific language governing permissions and limitations | ||
| .. under the License. | ||
|
|
||
| Upgrade Guides | ||
| ============== | ||
|
|
||
| DataFusion 52.0.0 | ||
| ----------------- | ||
|
|
||
| This version includes a major update to the :ref:`ffi` due to upgrades | ||
| to the `Foreign Function Interface <https://doc.rust-lang.org/nomicon/ffi.html>`_. | ||
| Users who contribute their own ``CatalogProvider``, ``SchemaProvider``, | ||
| ``TableProvider`` or ``TableFunction``` via FFI must now provide access to a | ||
| ``LogicalExtensionCodec`` and a ``TaskContextProvider``. The most convenient | ||
| way to provide these is from the ``datafusion-python`` ``SessionContext`` Python | ||
| object. The ``SessionContext`` now has a method to export a | ||
| ``FFI_LogicalExtensionCodec``, which can satisfy this new requirement. | ||
|
|
||
| A complete example can be found in the `FFI example <https://github.com/apache/datafusion-python/tree/main/examples/datafusion-ffi-example>`_. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great upgrade guide |
||
| The constructor for your provider needs to take an an input the ``SessionContext`` | ||
timsaucer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| python object. Instead of calling ``FFI_CatalogProvider::new`` you can use the | ||
| added method ``FFI_CatalogProvider::new_with_ffi_codec`` as follows: | ||
|
|
||
| .. code-block:: rust | ||
|
|
||
| #[pymethods] | ||
| impl MyCatalogProvider { | ||
| #[new] | ||
| pub fn new(session: &Bound<PyAny>) -> PyResult<Self> { | ||
| let logical_codec = ffi_logical_codec_from_pycapsule(session)?; | ||
| let inner = Arc::new(MemoryCatalogProvider::new()); | ||
|
|
||
| Ok(Self { | ||
| inner, | ||
| logical_codec, | ||
| }) | ||
| } | ||
|
|
||
| pub fn __datafusion_catalog_provider__<'py>( | ||
| &self, | ||
| py: Python<'py>, | ||
| ) -> PyResult<Bound<'py, PyCapsule>> { | ||
| let name = cr"datafusion_catalog_provider".into(); | ||
| let codec = self.logical_codec.clone(); | ||
| let catalog_provider = | ||
| FFI_CatalogProvider::new_with_ffi_codec(Arc::new(self.clone()), None, codec); | ||
|
|
||
| PyCapsule::new(py, catalog_provider, Some(name)) | ||
| } | ||
| } | ||
|
|
||
| To extract the logical extension codec FFI object from the ``SessionContext`` you | ||
| can implement a helper method such as: | ||
|
|
||
| .. code-block:: rust | ||
|
|
||
| pub(crate) fn ffi_logical_codec_from_pycapsule( | ||
| obj: &Bound<PyAny>, | ||
| ) -> PyResult<FFI_LogicalExtensionCodec> { | ||
| let attr_name = "__datafusion_logical_extension_codec__"; | ||
|
|
||
| if obj.hasattr(attr_name)? { | ||
| let capsule = obj.getattr(attr_name)?.call0()?; | ||
| let capsule = capsule.downcast::<PyCapsule>()?; | ||
| validate_pycapsule(capsule, "datafusion_logical_extension_codec")?; | ||
|
|
||
| let provider = unsafe { capsule.reference::<FFI_LogicalExtensionCodec>() }; | ||
|
|
||
| Ok(provider.clone()) | ||
| } else { | ||
| Err(PyValueError::new_err( | ||
| "Expected PyCapsule object for FFI_LogicalExtensionCodec, but attribute does not exist", | ||
| )) | ||
| } | ||
| } | ||
|
|
||
| The DataFusion FFI interface updates no longer depend directly on the | ||
| ``datafusion`` core crate. You can improve your build times and potentially | ||
| reduce your library binary size by removing this dependency and instead | ||
| using the specific datafusion project crates. | ||
|
|
||
| For example, instead of including expressions like: | ||
|
|
||
| .. code-block: rust | ||
|
|
||
| use datafusion::catalog::MemTable; | ||
|
|
||
| Instead you can now write: | ||
|
|
||
| .. code-block: rust | ||
timsaucer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
timsaucer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| use datafusion_catalog::MemTable; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.