Fix: wrap JDBC exceptions during fetch as DatabaseError (legacy #58)#83
Open
HenryNebula wants to merge 1 commit intodevfrom
Open
Fix: wrap JDBC exceptions during fetch as DatabaseError (legacy #58)#83HenryNebula wants to merge 1 commit intodevfrom
HenryNebula wants to merge 1 commit intodevfrom
Conversation
42049c0 to
103f96a
Compare
When a JDBC driver throws an exception during data retrieval (e.g., divide-by-zero in calculated columns), the raw Java exception now propagates through the Arrow JDBC library wrapped in JdbcConsumerException. Previously these were re-raised as raw Java exceptions to the Python caller. Changes: - Walk the cause chain in _handle_sql_exception_jpype() to detect SQLException even when wrapped by JdbcConsumerException - Wire _handle_sql_exception into fetch_next_batch() and read_rows_from_arrow_iterator() so fetch-time errors become proper Python DatabaseError instead of raw Java exceptions - Add mockExceptionOnFetch() to MockConnection for testing - Add mock tests for SQLException and RuntimeException during fetch - Add HSQLDB integration test for division-by-zero error handling Fixes #82 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
103f96a to
bedf004
Compare
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.
Summary
Fixes #82: JDBC driver exceptions during data retrieval (e.g., divide-by-zero in calculated columns) now properly raise Python
DatabaseErrorinstead of raw Java exceptions.Changes
_handle_sql_exception_jpype()to detectSQLExceptioneven when wrapped by Arrow'sJdbcConsumerException_handle_sql_exceptionintofetch_next_batch()andread_rows_from_arrow_iterator()so fetch-time errors become proper PythonDatabaseErrormockExceptionOnFetch()toMockConnectionfor testingTest plan
Closes #82
Generated with Claude Code