feat(rust/ffi): implement ErrorFromArrayStream on the driver exporter - #4
Closed
fornwall wants to merge 1 commit into
Closed
feat(rust/ffi): implement ErrorFromArrayStream on the driver exporter#4fornwall wants to merge 1 commit into
fornwall wants to merge 1 commit into
Conversation
The exported driver left the ADBC 1.1.0 `ErrorFromArrayStream` slot as `None`, so when a result stream failed mid-iteration everything a Rust driver attached to its `adbc_core::error::Error` (status, vendor code, structured details) was reduced to an errno plus a message string for any foreign driver manager. Wrap every exported reader in a stream whose private data retains the last `adbc_core::error::Error` seen during iteration (recovered from the `ArrowError::ExternalError` source chain), and implement the slot to materialize an `FFI_AdbcError` from it, reusing the existing `TryFrom<Error>` / `ErrorPrivateData` machinery. The returned error is kept alive by the stream and released with it, per the ADBC contract. This is the natural complement to apache#4475/#10300: those fix the error *code* (errno mapping); this recovers the error *object*. The dummy driver gains a failing-stream trigger (`STREAM_ERROR_QUERY`) and a test drives the exported C driver directly to assert the full error -- message, status, vendor code, sqlstate and structured details -- is recovered via `ErrorFromArrayStream` after the stream fails. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The exported driver left the ADBC 1.1.0
ErrorFromArrayStreamslot asNone(
rust/ffi/src/driver_exporter.rs, previously aTODO). That slot is themechanism a consumer uses to recover the full
AdbcError— status, vendorcode, structured details — when a result stream fails mid-iteration. Without
it, everything a Rust driver attaches to its
adbc_core::error::Errorduringstreaming is reduced to an errno + message string for any foreign driver
manager (the error is wrapped in
ArrowError::ExternalError, and arrow-rs'sFFI_ArrowArrayStreamonly carries theDisplaystring across FFI).How
LastErrorReader) so that whenever iterationyields an
ArrowError::ExternalErrorcarrying anadbc_core::error::Error,the full error is stashed in a shared slot.
ExportedArrayStreamPrivateData, whichdelegates schema/array export to an inner arrow-produced stream and keeps the
last-error slot reachable.
ErrorFromArrayStreamto materialize anFFI_AdbcErrorfrom theretained
Error(reusing the existingTryFrom<Error>/ErrorPrivateDatamachinery) and write the ADBC status. The returned error is owned by the
stream and released with it, matching the ADBC contract that the pointer is
valid until the next call or stream release.
Testing
test_error_from_array_streamdrives the exported C driver directly(the Rust driver manager imports streams via arrow's
ArrowArrayStreamReader,which has no notion of this ADBC-specific entry point) and asserts message,
status, vendor code, sqlstate and structured details all survive.
STREAM_ERROR_QUERYtrigger to produce amid-stream failure.
stream+error lifecycle. Full
adbc_dummysuite andcargo build --workspacepass.
Relationship to apache#4475 / apache/arrow-rs#10300
This is the natural complement to apache#4475:
that PR fixes the error code (mapping
Status::Cancelled→ECANCELEDinstead of the arrow-rs catch-all
EINVAL); this PR recovers the errorobject. Both extract the
adbc_core::error::Errorfrom theArrowError::ExternalErrorsource chain, so if apache#4475 lands first (introducingits custom
exported_stream.rs), these should be reconciled: the last-errorretention here would fold into that custom stream's private data rather than
layering a second wrapper on top of
FFI_ArrowArrayStream::new.🤖 Generated with Claude Code