Repository navigation
Open console query results in Positron's Data Explorer - #595
samclark2015 wants to merge 1 commit into
Conversation
|
Most of the logic of this PR is implemented in the Jupyter kernel and I'm not super fond of that if it can be avoided at all. For the kernel to contain a module so closely tied to positron feels like a code smell. Can you take another round at this with the goal of keeping it as confined as possible to the VS code extension? Also, we plan to spin out the VS Code extension to its own repo that you can have more control over once this is in (just an FYI :-) ) |
|
Sweet! Thanks for this feedback. I churned on it with the 🤖 and came up with this proposal, which moves Positron-specific code into the extension. Kernel additions are minimal and client-agnostic. Let me know how this sounds, and I'll spin up a revision. Proposal: the kernel offers a general results API, and the extension serves the Data ExplorerKernel: a general results API, with no Positron logic.
Extension: everything specific to Positron's Data Explorer.
Why this shape
Tradeoffs
ScopeBoth directives go. The extension calls |
|
I think this is a better shape in general. If possible, it would be nice to reuse the cache mechanism already in place in ggsql, however, care should be taken to not enforce a cached reader on the user (because that change the dialect for them). So, the cache reader should only be used for the results API |
Console query results get a link that opens them in Positron's Data Explorer. The kernel keeps each result in a dedicated in-memory DuckDB results cache (sharing `CacheTables` with `CachingReader`, with pinning so open results are not evicted; the user's reader is never wrapped) and exposes a frontend-agnostic results API over `call_method`. The VS Code extension registers the Data Explorer RPC handler, adds the console link, and pages, sorts, filters and profiles results through that API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
307d520 to
6711156
Compare
Addresses posit-dev/positron#16137 ("ggsql: View result of SQL query in data explorer"). No Positron changes are needed.
What it does
x-ggsql-view:<session>/<key>. Positron offers clicked links to the console session'sopenResource, which the extension adds by wrapping the session (ggsql-vscode/src/resultLinks.ts), the same way R handlesx-r-help:links. The extension then runs-- @view-result <key>silently, and the kernel opens apositron.dataExplorercomm, which Positron shows as a tab.ggsql-jupyter/src/results.rs). The explorer therefore always uses one SQL dialect, a remote query isn't re-run for every page, and nothing appears in the user's database. The number kept is capped by--max-results(default 16), but a result with an explorer open is never evicted.open_editoron the UI comm with the explorer's editor URI, which is what the Variables pane does for a variable that's already open.-- @view[: title]directive: opens a query's result in the Data Explorer as soon as it runs, and still shows the table in the console. A silent execution opens only the tab, so a script can trigger it. Outside Positron it shows the table with a note.VISUALISEqueries are rejected.ggsql.consoleRowssetting. The extension passes it to the kernel as theGGSQL_CONSOLE_ROWSenvironment variable rather than as--console-rows, because an older kernel found on the machine would refuse to start on an unknown flag. Notebooks still show up to 100 rows.Not in this PR
format_options, Positron's number-formatting settings.Testing
cargo test -p ggsql-jupyter: 104 unit tests pass.ggsql-jupyter/tests: 43 integration tests pass. They cover the link,-- @viewand-- @view-result, focusing an open explorer, filter/sort/Convert to Code over the comm, JSON-RPC errors, and theGGSQL_CONSOLE_ROWSrow count.ggsql-vscode: 78 extension tests pass, including link parsing and theconsoleRowssetting.-- @view: title;ggsql.consoleRows = 3.Demo
ggsql-data-explorer.mp4
🤖 Generated with Claude Code