create_mapped_exception in sqlspec/adapters/adbc/core.py (0.58.2) maps both SQLSTATE 57014 and the message patterns cancel/interrupt to QueryTimeoutError.
Calling connection.adbc_cancel() from another thread to cancel an in-flight DuckDB statement makes execute_script fail with INVALID_ARGUMENT: INTERRUPT Error, which then surfaces as:
sqlspec.exceptions.QueryTimeoutError: ADBC query timeout: INVALID_ARGUMENT: INTERRUPT Error
That's misleading for anyone reading logs or writing handlers—the statement was deliberately cancelled, not timed out—and callers implementing cooperative cancellation can only tell the two apart by string-matching the message.
Proposal: map interrupt/cancel (SQLSTATE 57014, message patterns cancel/interrupt) to a distinct exception, such as OperationCancelledError—ideally a QueryTimeoutError sibling rather than subclass, since retry policies for timeouts and user cancellations usually differ. Happy to PR if the direction sounds right.
Repro sketch: DuckDB AdbcConfig session running a long execute_script; a second thread calls driver.connection.adbc_cancel(); observe QueryTimeoutError.
create_mapped_exceptioninsqlspec/adapters/adbc/core.py(0.58.2) maps both SQLSTATE57014and the message patternscancel/interrupttoQueryTimeoutError.Calling
connection.adbc_cancel()from another thread to cancel an in-flight DuckDB statement makesexecute_scriptfail withINVALID_ARGUMENT: INTERRUPT Error, which then surfaces as:That's misleading for anyone reading logs or writing handlers—the statement was deliberately cancelled, not timed out—and callers implementing cooperative cancellation can only tell the two apart by string-matching the message.
Proposal: map interrupt/cancel (SQLSTATE
57014, message patternscancel/interrupt) to a distinct exception, such asOperationCancelledError—ideally aQueryTimeoutErrorsibling rather than subclass, since retry policies for timeouts and user cancellations usually differ. Happy to PR if the direction sounds right.Repro sketch: DuckDB
AdbcConfigsession running a longexecute_script; a second thread callsdriver.connection.adbc_cancel(); observeQueryTimeoutError.