aljazerzen / connector_arrow

Apache Arrow database client for many databases.
https://docs.rs/connector_arrow
MIT License
37 stars 1 forks source link

Future of this crate and ADBC #28

Open aljazerzen opened 4 months ago

aljazerzen commented 4 months ago

ADBC has recently updated their Rust API. It is quite similar to the ADBC C API, so it is would be possible to export a Rust ADBC driver as a C library to be used from any language using FFI.

The downside is that it is "low-level" and easy to misuse (i.e. by not setting SQL queries on a statement, by passing-in incorrectly formatted options, by not closing a statement but instead just dropping it). Such misuse would lead to run-time errors or undefined behavior.

This API is therefore "unsafe" and not suitable for general use in rust ecosystem. Instead, I suggest we create a high-level wrapper API that would be very hard or impossible to misuse but would use the "unsafe" API internally.

This way, it would also be possible to use non-Rust ADBC drivers from Rust via FFI.


Now, regarding this crate, I plan to:

(writing this, I realize we need a good name for the high-level ADBC API)

tripokey commented 2 months ago

This crate gives the application direct support for interacting with databases without having to manage separately installed drivers. Will this still be supported?

aljazerzen commented 2 months ago

separately installed drivers

What do you mean here?

With how I see now, rust applications would add dependency to:

tripokey commented 2 months ago

From https://arrow.apache.org/docs/format/ADBC.html#example-use-cases

If the application wishes to work with multiple databases, it would link against the ADBC driver manager, and specify the desired driver at runtime. The driver manager would pass on API calls to the correct driver, which handles the request.

My interpretation of the above text is that ADBC functions similar to ODBC where you are required to have ODBC drivers installed on your system for each database that you want to interact with (at least if you want to interact with multiple different database types).

Currently this crates does not require any external driver to be present and the application can interact with multiple different database types without the end user having to manage external ADBC drivers.

aljazerzen commented 2 months ago

Oh, yes - I believe that quote talks about applications using the C ADBC API, which does not allow specifying multiple drivers in application code, so they use the driver_manager as the workaround.

All of that would not be necessary when using Rust ADBC API, which is defining traits that can be implemented and imported multiple times in your code.

tripokey commented 2 months ago

Then my question is resolved :slightly_smiling_face:

Thanks for the quick replies :+1: