Repository navigation
Add CachingReader binding (stacked on #9) - #10
Merged
Merged
Conversation
cpsievert
marked this pull request as ready for review
October 12, 2026 19:54
cpsievert
added a commit
to posit-dev/querychat
that referenced
this pull request
Oct 12, 2026
_viz_ggsql.py lazily imports ggsql.CachingReader at first viz call; older releases would fail with ImportError at runtime. CachingReader first ships in ggsql 0.5.2 (posit-dev/ggsql-python#10).
cpsievert
added this pull request to stack #11
October 12, 2026 21:40
cpsievert
added a commit
that referenced
this pull request
Oct 12, 2026
Registered tables still live in the private cache, reads referencing them still route there, and derived SQL still runs on the cache backend — the flag only stops the memo being consulted or written. Addresses Copilot review on #10.
Wraps upstream ggsql::reader::CachingReader: an internal in-memory DuckDB cache backend, primary given as a duckdb:// connection string (built fresh internally) or any Python object with the reader bridge protocol. Config from GGSQL_CACHE_* env vars with keyword overrides. Package-level export included here rather than as a later task because the constructor tests reference ggsql.CachingReader directly.
Registered tables still live in the private cache, reads referencing them still route there, and derived SQL still runs on the cache backend — the flag only stops the memo being consulted or written. Addresses Copilot review on #10.
cpsievert
force-pushed
the
caching-reader
branch
from
October 12, 2026 21:57
16bd405 to
b649e8d
Compare
cpsievert
added a commit
that referenced
this pull request
Oct 12, 2026
cpsievert
added a commit
that referenced
this pull request
Oct 12, 2026
cpsievert
force-pushed
the
caching-reader
branch
from
October 12, 2026 22:21
a3a41ed to
2e9f6ab
Compare
cpsievert
added a commit
to posit-dev/querychat
that referenced
this pull request
Oct 13, 2026
_viz_ggsql.py lazily imports ggsql.CachingReader at first viz call; older releases would fail with ImportError at runtime. CachingReader first ships in ggsql 0.5.2 (posit-dev/ggsql-python#10).
cpsievert
added a commit
to posit-dev/querychat
that referenced
this pull request
Oct 13, 2026
_viz_ggsql.py lazily imports ggsql.CachingReader at first viz call; older releases would fail with ImportError at runtime. CachingReader first ships in ggsql 0.5.2 (posit-dev/ggsql-python#10).
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
Exposes upstream ggsql 0.5.2's
CachingReaderto Python asggsql.CachingReader. Source reads hit the primary reader (memoized with TTL + LRU byte budget); all ggsql-generated derived SQL (__ggsql_*tables) runs on a private in-memory DuckDB cache.duckdb://connection string (built fresh internally) or a bridged Python reader; passing an existingDuckDBReaderinstance errors with guidance.GGSQL_CACHE_DISABLED/GGSQL_CACHE_TTL/GGSQL_CACHE_MAX_BYTES, keyword args take precedence.execute(bridged primaries call back into Python — same stance asDuckDBReader).Why: querychat currently rejects ggsql queries with layer-level sources and re-runs identical base reads on every LLM tool call.
test_layer_level_source_through_bridgedemonstratesVISUALISE ... FROM <table>running end-to-end through a bridged primary — the capability querychat's_viz_ggsql.pynames as its long-term fix.Benchmark evidence (merge gate)
Benchmark: simulated LLM-style viz session — 9 tool calls sharing one identical base read over a 3M-row DataFrameSource (iterative chart refinement), 1 exact repeat, 1 multi-relation query. Old path = querychat's hand-rolled split (
_viz_ggsql.py@ querychat 40f328e4); new path = whole-query execution throughCachingReaderwrapping the querychat executor — see draft PR posit-dev/querychat#321 for the integration.Source reads during calls 1–9 (one shared base read): old = 9, new = 1. The multi-relation call adds 2 more on the new path (base + layer source); the old path rejects such queries outright.
Takeaways:
DRAW ... FROM <table>(multi-relation) queries now work end-to-end through the bridged executor.Environment: ggsql 0.5.2 (this branch), M-series arm64, Python 3.12. Two consecutive runs produced near-identical numbers. Repro:
.venv/bin/python _dev/ggsql-caching-benchmark/bench.pyon querychat branchggsql-caching-reader(posit-dev/querychat#321).Stacking
Stacked on #9 (
ggsql-0.5.2-upgrade); base retargets tomainafter #9 merges. Design spec and implementation plan live locally indocs/superpowers/(gitignored).Test plan
enabled=False+ env-var disable, layer-level source through bridged primary, cache-resident routing, top-levelexecutefast path, package exportcargo fmt --checkandcargo clippy -- -D warningsclean