-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Export C API #1113
Comments
Pretty cool, let us know if you need any help with it. |
I'm not sure tokio and async functions can be easily modeled. |
i think we would need to do pull the same trick we have with our python binding. |
there are several libraries made in ruby similar to py03 in python |
Closes apache#1113 This exports minimum C API to write the following Rust code in C: use datafusion::prelude::*; #[tokio::main] async fn main() -> datafusion::error::Result<()> { // register the table let mut ctx = ExecutionContext::new(); // create a plan to run a SQL query let df = ctx.sql("SELECT 1").await?; // execute and print results df.show().await?; Ok(()) } See datafusion/c/examples/sql.c for C version. You can build and run datafusion/c/examples/sql.c by the following command lines: cargo build cc -o target/debug/sql datafusion/c/examples/sql.c -Idatafusion/c/include -Ltarget/debug -Wl,--rpath=target/debug -ldatafusion_c target/debug/sql This implementation doesn't export Future like datafusion-python. Async functions are block_on()-ed in exported API. But I think that we can export Future in follow-up tasks. Follow-up tasks: * Add support for testing by "cargo test" * Add support for building and running examples by "cargo ..." * Add support for installing datafusion.h
Closes apache#1113 This exports minimum C API to write the following Rust code in C: use datafusion::prelude::*; #[tokio::main] async fn main() -> datafusion::error::Result<()> { // register the table let mut ctx = ExecutionContext::new(); // create a plan to run a SQL query let df = ctx.sql("SELECT 1").await?; // execute and print results df.show().await?; Ok(()) } See datafusion/c/examples/sql.c for C version. You can build and run datafusion/c/examples/sql.c by the following command lines: $ cargo build $ cc -o target/debug/sql datafusion/c/examples/sql.c -Idatafusion/c/include -Ltarget/debug -Wl,--rpath=target/debug -ldatafusion_c $ target/debug/sql +----------+ | Int64(1) | +----------+ | 1 | +----------+ This implementation doesn't export Future like datafusion-python. Async functions are block_on()-ed in exported API. But I think that we can export Future in follow-up tasks. Follow-up tasks: * Add support for testing by "cargo test" * Add support for building and running examples by "cargo ..." * Add support for installing datafusion.h
Closes apache#1113 This exports minimum C API to write the following Rust code in C: use datafusion::prelude::*; #[tokio::main] async fn main() -> datafusion::error::Result<()> { // register the table let mut ctx = ExecutionContext::new(); // create a plan to run a SQL query let df = ctx.sql("SELECT 1").await?; // execute and print results df.show().await?; Ok(()) } See datafusion/c/examples/sql.c for C version. You can build and run datafusion/c/examples/sql.c by the following command lines: $ cargo build $ cc -o target/debug/sql datafusion/c/examples/sql.c -Idatafusion/c/include -Ltarget/debug -Wl,--rpath=target/debug -ldatafusion_c $ target/debug/sql +----------+ | Int64(1) | +----------+ | 1 | +----------+ This implementation doesn't export Future like datafusion-python. Async functions are block_on()-ed in exported API. But I think that we can export Future in follow-up tasks. Follow-up tasks: * Add support for testing by "cargo test" * Add support for building and running examples by "cargo ..." * Add support for installing datafusion.h
I've implemented minimum C API as the first step: #2622 |
There is an excellent comment about "C API as a way to enable embedding across many languages" from @loic-sharma here #2622 (comment) ❤️ |
I close this because we work on this at https://github.com/datafusion-contrib/datafusion-c . |
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
We (me and @kou ) would like to export the C API to allow other language bindings (#1108, #1114).
Describe the solution you'd like
We will use the FFI that allow exposing a C API (https://doc.rust-lang.org/nomicon/ffi.html#calling-rust-code-from-c).
Describe alternatives you've considered
None, since not all languages have direct bindings/FFI to Rust
The text was updated successfully, but these errors were encountered: