Skip to content

port over changes from posit-dev/ggsql#178#1

Open
thomasp85 wants to merge 2 commits intomainfrom
python-exception-protocol
Open

port over changes from posit-dev/ggsql#178#1
thomasp85 wants to merge 2 commits intomainfrom
python-exception-protocol

Conversation

@thomasp85
Copy link
Copy Markdown
Collaborator

@thomasp85 thomasp85 commented Apr 22, 2026

From posit-dev/ggsql#178

Summary

  • Add typed exception classes (ParseError, ValidationError, ReaderError, WriterError) subclassing ValueError for backwards compatibility
  • Add Reader protocol class defining the contract for custom readers (execute_sql, register)
  • Fix PyReaderBridge to pass replace as a keyword argument, so custom readers with register(name, df, *, replace=False) signatures work correctly

Rust changes

  • create_exception! macros for 4 exception types + ggsql_err_to_py() mapper
  • All .map_err(...) sites updated from generic PyValueError to typed exceptions
  • PyReaderBridge.register() uses call_method with kwargs instead of call_method1

From posit-dev/ggsql#179

Summary

  • Add type stubs (.pyi) for the native _ggsql extension module, enabling IDE autocompletion and type checking
  • Add data= dict parameter on execute() for registering temporary DataFrames that are automatically cleaned up after execution (even on error)
  • Improve type stub specificity and data cleanup safety

Rust changes

  • data: Option<&Bound<'_, PyDict>> parameter on PyDuckDBReader.execute() and free execute()
  • register_data_dict() / register_data_on_reader() helpers with table_exists() probe to avoid unregistering pre-existing tables
  • Removed try_native_readers! macro (incompatible with cleanup-before-return pattern)

@thomasp85
Copy link
Copy Markdown
Collaborator Author

thomasp85 commented Apr 22, 2026

@cpsievert this is my attempt at moving the posit-dev/ggsql#178 and posit-dev/ggsql#179 pr over. They were still marked as draft which I'm not sure is due to forgetting to update them or if you were planning on more work

@cpsievert
Copy link
Copy Markdown

Hmm, how come the description is also describing posit-dev/ggsql#143?

@thomasp85
Copy link
Copy Markdown
Collaborator Author

it was obviously at the end of the day when I opened this 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants