feat(sql): add qn sql for SQL Explorer queries and schema (DX-5876)#47
Merged
Conversation
Wraps the new quicknode-sdk 0.5 `sql` sub-client as two verbs: - `qn sql query` runs a read-only query against a cluster. The SQL is passed inline, via `--file <path>`, or from stdin with `--file -` (mutually exclusive, exactly one required). Rows render to stdout (headers from the response `meta`, scalars unquoted, null as `—`, nested values as compact JSON); query stats print to stderr as a note with a truncation hint when the 1000-row cap is hit. Does not auto-retry: a query consumes credits, so a retried query re-bills. - `qn sql schema <CLUSTER_ID>` prints each table as a block (engine, row count, partition/sorting keys, and a COLUMN/TYPE sub-table). Retries like other reads. Bumps quicknode-sdk to 0.5 and routes the SQL base path under the `--base-url` override so integration tests hit the mock, not production. Updates the README and the embedded agent context catalog.
ErikTech
approved these changes
Jun 25, 2026
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.
Adds
qn sql, wrapping the new quicknode-sdk 0.5 SQL Explorer sub-client. Closes DX-5876.Two verbs:
qn sql queryruns a read-only query against a cluster.qn sql schema <CLUSTER_ID>shows a cluster's table schema.qn sql queryThe SQL can be passed inline, from a file (
--file <path>), or from stdin (--file -) — mutually exclusive, exactly one required. Rows go to stdout; query stats print to stderr as a note, with a truncation hint when the 1000-row-per-request cap is hit. The query does not auto-retry (it consumes credits, so a retried query would re-bill).Rendering: headers come from the response
meta(so an empty result set still prints its columns); scalars render unquoted,nullrenders as—, and nested arrays/objects fall back to compact JSON. Structured formats keep the full response:qn sql schemaPrints each table as a block: engine, row count, partition/sorting keys, then a
COLUMN/TYPEsub-table. Retries like other reads.Implementation notes
quicknode-sdk0.4 → 0.5./sql/rest/v1/) under the--base-urloverride incontext.rsso integration tests hit the mock, not production — same pattern as the other sub-clients.src/commands/sql/{mod.rs, render.rs}; wired throughcli.rsandcommands/mod.rs.agent contextcatalog (and notes the query no-retry behavior).Tests
tests/sql.rs: 8 integration tests — camelCaseclusterIdwire body,--fileread, missing-file / arg-group / inline+file conflict (exit 1), API error (exit 2), schema happy path and 404.tests/table_snapshots.rs: 2 subprocess snapshots covering visible table output (unquoted scalars +null→—; nested schema blocks including an empty-metadata view).cargo test,cargo clippy --all-targets -D warnings,cargo fmt --check, andcargo build --releaseall pass.