Skip to content

feat: allow custom error codes on exported FFI_ArrowArrayStream#10300

Closed
fornwall wants to merge 1 commit into
apache:mainfrom
fornwall:ffi-stream-custom-error-code
Closed

feat: allow custom error codes on exported FFI_ArrowArrayStream#10300
fornwall wants to merge 1 commit into
apache:mainfrom
fornwall:ffi-stream-custom-error-code

Conversation

@fornwall

@fornwall fornwall commented Jul 7, 2026

Copy link
Copy Markdown

Disclaimer: Most of this PR description and code was AI generated. I have reviewed the code and think it makes sense. Let me know if I should dig into any detail or do modifications.

FFI_ArrowArrayStream::new maps every stream error to one of ENOSYS/ENOMEM/EIO/EINVAL based solely on the ArrowError variant.

Producers whose errors carry richer semantics than the variant can express have no way to surface them: an ADBC driver wrapping its error in ArrowError::ExternalError always lands in the EINVAL catch-all, even though the ADBC specification expects ECANCELED from get_next after a cancelled query. Such producers currently have to vendor the entire unsafe export scaffolding just to change one function.

Add FFI_ArrowArrayStream::new_with_error_code, which takes the error-code mapping as a closure; new keeps the existing variant-based mapping as its default. A mapping that returns 0 for an error is coerced to EINVAL, since 0 would signal success and lead the consumer to read the uninitialized out-parameter.

FFI_ArrowArrayStream::new maps every stream error to one of
ENOSYS/ENOMEM/EIO/EINVAL based solely on the ArrowError variant.
Producers whose errors carry richer semantics than the variant can
express have no way to surface them: an ADBC driver wrapping its error
in ArrowError::ExternalError always lands in the EINVAL catch-all, even
though the ADBC specification expects ECANCELED from get_next after a
cancelled query. Such producers currently have to vendor the entire
unsafe export scaffolding just to change one function.

Add FFI_ArrowArrayStream::new_with_error_code, which takes the
error-code mapping as a closure; new keeps the existing variant-based
mapping as its default. A mapping that returns 0 for an error is
coerced to EINVAL, since 0 would signal success and lead the consumer
to read the uninitialized out-parameter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DZxDaarQAUqUh9rQq3UmSz
@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jul 7, 2026
@fornwall fornwall changed the title feat: allow custom error codes on exported FFI_ArrowArrayStream feat: allow custom error codes on exported FFI_ArrowArrayStream Jul 7, 2026
@fornwall

fornwall commented Jul 8, 2026

Copy link
Copy Markdown
Author

This doesn't seem that useful/necessary, at least for the ADBC use case - see apache/arrow-adbc#4475.

@fornwall fornwall closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant