Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 165
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
Uh oh!
There was an error while loading. Please reload this page.
Prepare for DF52 release #1337
Changes from all commits
b80cdf5217514fa13ab945e09e1e9749c3c9a7244e0d7bb36bea73b1b01ddde1605ff3590da40d4ceedfFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| .. 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 function signatures | ||
| for the methods to get these ``PyCapsule`` objects now requires an additional | ||
| parameter, which is a Python object that can be used to extract the | ||
| ``FFI_LogicalExtensionCodec`` that is necessary. | ||
| A complete example can be found in the `FFI example <https://github.com/apache/datafusion-python/tree/main/examples/datafusion-ffi-example>`_. | ||
| Your methods need to be updated to take an additional parameter like in this | ||
| example. | ||
| .. code-block:: rust | ||
| #[pymethods] | ||
| impl MyCatalogProvider { | ||
| pub fn __datafusion_catalog_provider__<'py>( | ||
| &self, | ||
| py: Python<'py>, | ||
| session: Bound<PyAny>, | ||
| ) -> PyResult<Bound<'py, PyCapsule>> { | ||
| let name = cr"datafusion_catalog_provider".into(); | ||
| let provider = Arc::clone(&self.inner) as Arc<dyn CatalogProvider + Send>; | ||
| let codec = ffi_logical_codec_from_pycapsule(session)?; | ||
| let provider = FFI_CatalogProvider::new_with_ffi_codec(provider, None, codec); | ||
| PyCapsule::new(py, provider, Some(name)) | ||
| } | ||
| } | ||
| To extract the logical extension codec FFI object from the provided object 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__"; | ||
| let capsule = if obj.hasattr(attr_name)? { | ||
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. For my understanding in which case will else branch be triggered? MemberAuthor 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. If the user provides a pycapsule object directly instead of an object that contains a method to get the pycapsule. I think in practice the else statement will get rarely used for this particular case, but for things like udfs I could see users wanting to just provide the capsule directly. | ||
| obj.getattr(attr_name)?.call0()? | ||
| } else { | ||
| obj | ||
| }; | ||
| let capsule = capsule.downcast::<PyCapsule>()?; | ||
| validate_pycapsule(capsule, "datafusion_logical_extension_codec")?; | ||
| let codec = unsafe { capsule.reference::<FFI_LogicalExtensionCodec>() }; | ||
| Ok(codec.clone()) | ||
| } | ||
| 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 | ||
| use datafusion_catalog::MemTable; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great upgrade guide