feat(cli): vortex sql — interactive Calcite-backed SQL shell#161
Open
dfa1 wants to merge 2 commits into
Open
Conversation
Adds `sql FILE.vortex [MORE...]`, an interactive SQL REPL over Vortex files using the calcite module. Split-pane TUI: a multiline editor on top and a scrollable result grid below. - Editor follows psql convention: Enter inserts a newline, a query runs only when the buffer ends with `;`. Tab toggles focus editor<->grid; Up/Down at the editor edge recall previous queries; Esc clears; Ctrl-D quits. - QueryHistory persists the last 100 queries to ~/.vortex/sql_history, newline-escaped and consecutive-dup collapsed. - ResultGrid snapshots a ResultSet (capped at 10k rows) for the grid. - Reuses the existing Terminal/Ansi/Key TUI stack; adds Key.Backspace (KeyDecoder maps 0x7F/0x08) for line editing. Queries execute synchronously on the render thread — VortexTable opens its own reader per scan, so no separate I/O thread is needed for arena confinement. Note: vortex-calcite (calcite-core + transitives) now shades into the cli uber-jar, growing its size. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Review fixes for the SQL shell, plus a keybinding cleanup: - QueryHistory.persist() no longer throws on a failed write (read-only home, full disk). It is best-effort, mirroring the swallow in load(), so a write failure can never abort the running shell. - The editor drops non-printable control bytes (Ctrl-A, Ctrl-U, …) instead of inserting them as invisible literal SQL text. - Esc is now the universal quit key in every TUI (SQL shell, grid, inspector). The grid and inspector already quit on Esc; the SQL shell now does too, and all three advertise it in their status hints. Tab still toggles the SQL panes; Ctrl-D still quits. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Adds
vortex sql FILE.vortex [MORE...]— an interactive SQL shell over Vortex files, backed by thecalcitemodule. Each file is registered as a table named after its filename stem (ohlc.vortex→vtx.ohlc).Split-pane TUI: multiline editor on top, scrollable result grid below.
UX
Enterinserts a newline; the query runs only when the buffer ends with;. Gives multiline for free (Shift+Enter is not detectable in a raw terminal).Tabtoggles editor ↔ result grid; in the grid, arrows /PgUp/PgDnscroll.Up/Downat the editor's top/bottom edge recall the last 100 queries, persisted to~/.vortex/sql_history(newline-escaped, consecutive-dup collapsed).Escclears the buffer,Ctrl-Dquits.Design
VortexTableopens its own reader per scan, so no separate I/O thread is needed for arena confinement. UI showsrunning…then repaints.Terminal/Ansi/KeyTUI stack. AddsKey.Backspace(KeyDecodermaps0x7F/0x08) for line editing.ResultGridsnapshots aResultSet(capped at 10k rows; truncation flagged in the status bar).Tests
All green (cli suite 199 pass, incl. checkstyle):
VortexSqlTuiTest(6) — scriptedFakeTerminalover a real in-memory Calcite connection + Vortex fixture: run-on-;, backspace correction, multiline newline, history recall,Tabfocus, invalid-SQL error handling.QueryHistoryTest(7),SqlCommandTest(4),KeyDecoderTest+backspace,KeyTestexhaustive switch.Note
vortex-calcite(calcite-core + transitives: avatica, guava, …) now shades into the cli uber-jar, growing its size meaningfully. Flagged in the pom comment.🤖 Generated with Claude Code