choplin opened a new issue, #4984: URL: https://github.com/apache/arrow-adbc/issues/4984
The Rust driver manager should preserve rich ADBC errors reported while consuming an imported `ArrowArrayStream`. ## Current behavior Methods such as `Statement::execute` return: ```rust Result<Box<dyn RecordBatchReader + Send + 'static>> ``` The returned reader imports and consumes an `ArrowArrayStream`. If the driver reports an error while the stream is being consumed, Arrow's `ArrowArrayStreamReader` exposes only an Arrow-level error derived from the stream's errno and `get_last_error`. Consequently, the Rust caller cannot access the ADBC error available through `AdbcDriver::ErrorFromArrayStream`, including: - ADBC status code - SQLSTATE - vendor code - structured error details This affects errors that occur after statement execution has returned successfully, while calling `RecordBatchReader::next`. ## Reproduction scenario 1. Load an ADBC 1.1 driver through the Rust `adbc_driver_manager`. 2. Execute an operation that returns an `ArrowArrayStream`. 3. Have the driver return a nonzero error from `get_next` and expose the corresponding rich error through `ErrorFromArrayStream`. 4. Call `next` on the returned `RecordBatchReader`. The caller receives an `ArrowError::CDataInterface` containing only the stream error message. There is no way to retrieve the associated ADBC status code, SQLSTATE, vendor code, or structured details through the returned reader. ## Expected behavior When an imported `ArrowArrayStream` reports an error, the Rust driver manager should call the originating driver's `ErrorFromArrayStream`, when supported, and expose the resulting rich ADBC error to the caller. If the driver does not support `ErrorFromArrayStream` or returns `NULL`, the existing Arrow stream error should remain available as a fallback. The specific Rust API and implementation are open for discussion. The implementation will likely need an ADBC-aware reader or equivalent object that retains access to the originating driver for the lifetime of the imported stream. ## Existing implementations ### C driver manager The C driver manager wraps streams returned by a managed driver in an `ErrorArrayStream`. The wrapper retains the originating `AdbcDriver` and delegates the Arrow stream callbacks to the original stream. When `AdbcErrorFromArrayStream` is called for the wrapper, the driver manager forwards the call to: ```c private_driver->ErrorFromArrayStream(original_stream, status) ``` This preserves the relationship between an imported stream and the driver that can interpret its rich errors. ### Python driver manager Python exposes result streams through `AdbcRecordBatchReader`. When reading a batch raises an Arrow stream error, the reader calls `AdbcErrorFromArrayStream` for the underlying stream. If a rich error is returned, Python converts it into the appropriate DB-API exception and preserves the ADBC status code, SQLSTATE, vendor code, and structured details. For example, a cancellation can be exposed as an `OperationalError` with `status_code=CANCELLED`, rather than only as a generic `pyarrow` exception. This support was introduced as part of the ADBC 1.1.0 implementation in apache/arrow-adbc#971. That change added `AdbcRecordBatchReader` and `_AdbcErrorHelper`, which retain a copy of the underlying C stream and call `AdbcErrorFromArrayStream` when PyArrow reports an error while importing or consuming the stream. ### C# driver importer The C# implementation proposed in apache/arrow-adbc#4983 uses an `ImportedArrayStream` that retains a reference to the imported driver. When reading the stream fails, it calls the driver's `ErrorFromArrayStream` and throws an `AdbcException` containing the rich error information. It falls back to the previous message-only exception when the driver does not support the ADBC 1.1 API or returns `NULL`. This is the same lifetime requirement that the Rust implementation likely needs to address: the imported stream must retain access to the driver until stream consumption and cleanup are complete. ## Environment - `adbc_driver_manager`: 0.25.0 - `arrow-array`: 59.3.1 - ADBC API revision: 1.1.0 ## References - ADBC 1.1 `AdbcErrorFromArrayStream` specification: https://arrow.apache.org/adbc/main/cpp/api/group__adbc-error-handling.html - Python driver manager implementation: https://github.com/apache/arrow-adbc/pull/971 - C# implementation: https://github.com/apache/arrow-adbc/pull/4983 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
