Skip to content
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

Future of this crate and ADBC #28

Open
aljazerzen opened this issue May 7, 2024 · 5 comments
Open

Future of this crate and ADBC #28

aljazerzen opened this issue May 7, 2024 · 5 comments

Comments

@aljazerzen
Copy link
Owner

aljazerzen commented May 7, 2024

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:

  • use connector_arrow::api as a base to define the high-level ADBC API,
  • convert the connectors in the crate to implement the "unsafe" ADBC API.

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

@tripokey
Copy link

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

@aljazerzen
Copy link
Owner Author

separately installed drivers

What do you mean here?

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

  • the high-level ADBC crate, which would also depend on the low-level ADBC API,
  • the connectors currently implemented in connector_arrow,
    ... which would then provide the high-level ADBC API using Rust postgres crate, for example. It would not require you to have the pq library installed on your machine (or any other non-cargo library).

@tripokey
Copy link

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
Copy link
Owner Author

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
Copy link

Then my question is resolved 🙂

Thanks for the quick replies 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants