feat(rust/ffi): support ADBC 1.1.0 rich errors from exported streams#4475
feat(rust/ffi): support ADBC 1.1.0 rich errors from exported streams#4475fornwall wants to merge 1 commit into
Conversation
ECANCELED through exported streams for cancelled operations
|
I'm not sure I want to do this; if I were to do this, it would be to implement the 1.1.0 API functions around rich errors from ArrayStreams, and not just this on its own. |
d91e7b2 to
e20fa42
Compare
ECANCELED through exported streams for cancelled operationsThe driver exporter exported result readers via arrow-rs's FFI_ArrowArrayStream::new, which reduces every mid-stream failure to an errno plus a message string: rich adbc_core errors surfaced through ArrowError::ExternalError landed in the catch-all EINVAL, and the ADBC 1.1.0 ErrorFromArrayStream slot in the driver table was left as a TODO. Replace the export machinery (adapted from arrow-rs's ffi_stream.rs) with one that stashes the full adbc_core::error::Error found in the error's source chain (or synthesized from the ArrowError variant): - get_next/get_schema return the errno for the error's ADBC status via a port of the canonical InternalAdbcStatusCodeToErrno table, so e.g. cancelled operations report ECANCELED as the validation suite expects. - ErrorFromArrayStream is now implemented, handing consumers the stream-owned FFI_AdbcError (message, SQLSTATE, vendor code, details) together with its status code, and NULL for foreign streams. Own streams are recognized via a registry of live private-data addresses, since Rust does not guarantee the function-pointer identity the C/C++ drivers rely on (Miri fails such comparisons). Tested by unit tests, a new end-to-end test driving the exported C driver table against a failing dummy-driver stream, and a clean run of the adbc_ffi suite under Miri. Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
e20fa42 to
3ec70f5
Compare
@lidavidm Thanks! I've updated the PR to implement that now, instead of the limited initial scope. |
|
AI generated description for the gain for python clients: The Python DBAPI layer wraps every result set ( The result today: every mid-stream failure from a Rust driver reaches Python as With this PR the driver advertises |
|
Sorry - this is something that I'd want to spend actual time on |
Disclaimer: This PR description and code was AI generated. I have reviewed the code myself. Let me know if I should dig into any details or make modifications.
The driver exporter exported result readers via arrow-rs's
FFI_ArrowArrayStream::new, which reduces every mid-stream failure to anerrnoplus a message string: rich adbc_core errors surfaced throughArrowError::ExternalErrorlanded in the catch-allEINVAL, and the ADBC 1.1.0ErrorFromArrayStreamslot in the driver table was left as a TODO.Replace the export machinery (adapted from arrow-rs's
ffi_stream.rs) with one that stashes the fulladbc_core::error::Errorfound in the error's source chain (or synthesized from theArrowErrorvariant):get_next/get_schemareturn the errno for the error's ADBC status via a port of the canonicalInternalAdbcStatusCodeToErrnotable, so e.g. cancelled operations reportECANCELEDas the validation suite expects.ErrorFromArrayStreamis now implemented, handing consumers the stream-ownedFFI_AdbcError(message, SQLSTATE, vendor code, details) together with its status code, andNULLfor foreign streams. Own streams are recognized via a registry of live private-data addresses, since Rust does not guarantee the function-pointer identity the C/C++ drivers rely on (Miri fails such comparisons).Tested by unit tests, a new end-to-end test driving the exported C driver table against a failing dummy-driver stream, and a clean run of the
adbc_ffisuite under Miri.