Repository navigation
feat: add execute_sql_cached binding to CachingReader - #14
Merged
Merged
Conversation
Exposes the Rust CachingReader's compute surface (execute_sql_cached, present since ggsql 0.5.2) to Python. Setup statements that ggsql's derived SQL depends on must run on the private cache connection where that SQL executes — e.g. INSTALL/LOAD of DuckDB extensions such as spatial. Routing them through execute_sql sends them to the primary instead, where locked-down connections reject them and they take no effect on the cache. This is needed by querychat's opt-in "maps" capability to prewarm the DuckDB spatial extension on the compute surface (posit-dev/querychat#323).
cpsievert
added a commit
to posit-dev/querychat
that referenced
this pull request
Oct 14, 2026
prewarm_spatial routed INSTALL/LOAD spatial through execute(), which targets the user's primary data source. Those connections are typically locked down (filesystem access disabled), so the install failed and the "maps" capability was silently disabled — and even where it succeeded it would take no effect on the connection that matters. Spatial SQL actually executes on the CachingReader's private in-memory cache connection (the compute surface), so install/load the extension there via the new ggsql.CachingReader.execute_sql_cached binding (posit-dev/ggsql-python#14) and keep the smoke query on execute(), where it exercises the full spatial path: extension load, builtin ggsql:world registration, spatial layer execution. Without a ggsql build that has execute_sql_cached, prewarm fails with a warning and maps stay unavailable, so this degrades gracefully.
cpsievert
marked this pull request as ready for review
October 14, 2026 15:37
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
Adds an
execute_sql_cached(sql)binding toPyCachingReader, exposing the RustCachingReader's compute surface (available since ggsql 0.5.2) to Python.Why:
CachingReaderruns all ggsql-generated derived SQL on a private in-memory DuckDB "cache" connection, while base reads go to the primary data source. Any per-connection setup that derived SQL depends on must therefore happen on the cache connection — most immediatelyINSTALL spatial; LOAD spatial, which the spatial geom requires. Routing such statements throughexecute_sqlsends them to the primary instead, where locked-down connections (e.g. querychat's filesystem-disabled data sources) reject them, and where they take no effect on the cache even when they succeed.This unblocks querychat's opt-in
"maps"capability, which prewarms the DuckDB spatial extension on the compute surface at app startup (posit-dev/querychat#323). Keeping this as a generic "run SQL on the cache" escape hatch (rather than a spatial-specific method) mirrors the existing Rust API and leaves policy — what to install, when, and how to handle failure — with the caller.No new dependency requirements:
execute_sql_cachedhas been part of the ggsql crate since 0.5.2, so this builds against the currently pinned version.Verification
New tests in
TestCachingReaderassert thatexecute_sql_cachedexecutes without touching the primary (primary.calls == 0) and that errors propagate asValueError. Full suite: 141 passed locally against crates.io ggsql 0.5.2.