-
Notifications
You must be signed in to change notification settings - Fork 35
feat(c/sedona-extension): Move FFI scalar kernel definitions to c/sedona-extension and write them in C #407
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR refactors the FFI scalar kernel implementation by moving it from Rust-based DataFusion wrappers to a C-based implementation in the new c/sedona-extension crate. This change enables full expression of scalar kernels in C without requiring Rust wrappers, supporting better integration with C extensions like GPU joiners and the s2geography library.
Key changes:
- Removed the
rust/sedona/src/ffi.rsmodule containing DataFusion-based FFI implementations - Created new
c/sedona-extensioncrate with C-compatible scalar kernel definitions - Implemented import/export wrappers for C scalar kernels in Rust
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/sedona/src/lib.rs | Removed reference to deleted ffi module |
| rust/sedona/src/ffi.rs | Deleted entire DataFusion-based FFI implementation (515 lines) |
| c/sedona-extension/src/sedona_extension.h | Added C header with Arrow C Data Interface definitions and scalar kernel structs |
| c/sedona-extension/src/scalar_kernel.rs | Implemented Rust wrappers to import/export C scalar kernels with comprehensive tests |
| c/sedona-extension/src/lib.rs | Created new crate entry point exposing extension and scalar_kernel modules |
| c/sedona-extension/src/extension.rs | Added Rust FFI representations of C scalar kernel structs with safety implementations |
| c/sedona-extension/Cargo.toml | Defined new crate with dependencies on arrow, datafusion, and sedona components |
| Cargo.toml | Added c/sedona-extension to workspace members |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
We haven't used the
ffiscalar kernels in thesedonacrate yet, which were based on the rust/DataFusion versions. To properly get geography working everywhere I'd like to avoid the Rust wrapper around s2geography, which means being able to fully express a scalar kernel in C. Luckily the existing C definition we'd been using is fairly close...this PR removes the previous FFI scalar kernel implementation in favour of a C one. Once this is merged I'll follow-up with a change to s2geography to actually use it (which will remove almost all of the wrapper cod there, too).This PR also implements exporting any of our implementations as C-callable implementations, which would let any of these functions be called from something like Java given some glue code on the other side.
This PR has an eye towards other types of C extensions like the C GPU joiner in #310, where we can simplify the development for both libgpuspatial and sedonadb by completely separating the builds.