Skip to content

feat(viz): require ggsql >= 0.5.2 and update syntax prompt - #322

Merged
cpsievert merged 4 commits into
mainfrom
docs/ggsql-syntax-prompt-updates
Oct 13, 2026
Merged

cpsievert merged 4 commits into
mainfrom
docs/ggsql-syntax-prompt-updates

Conversation

@cpsievert

@cpsievert cpsievert commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two related changes:

  1. Require ggsql >= 0.5.2 in both packages, so the visualize tool only runs against a ggsql version that supports everything the system prompt documents (rather than failing at query-validation time).
  2. Update the shared ggsql-syntax.md system-prompt reference (identical copies in pkg-r/inst/prompts/ and pkg-py/src/querychat/prompts/) to match current ggsql syntax.

Version requirement

  • pyproject.toml: viz and dev extras now require ggsql>=0.5.2. (feat(pkg-py): route ggsql viz execution through ggsql.CachingReader #321 makes the same pyproject change for its own reasons — whichever lands second rebases over a trivial conflict there.)
  • R DESCRIPTION: ggsql (>= 0.5.2) in Suggests.
  • Runtime guards: Python has_viz_deps() and R check_viz_deps() now treat unsupported ggsql versions the same as a missing installation — warn once and continue without the visualize tool — with messages stating the 0.5.2 requirement.

Prompt fixes for stale/breaking content

  • The range layer's width setting is now hinge — the old SETTING width => null (lollipop example, range bullet) fails validation.
  • VISUALISE FROM takes exactly one bare source — aliases, joins, and comma-separated tables are parse errors; added an explicit warning.

New features documented: aggregate setting on identity-stat layers; position => 'jitter'; boxplot hinge/side settings; boxplot/violin/range may omit the categorical aesthetic; polar radar setting.

Rendering context: a standalone "Vega-Lite rendering" section at the end of the reference collects every writer-dependent caveat in one place — querychat draws all charts through ggsql's Vega-Lite writer (not the native SVG/PDF writers), label text renders literally (so avoid markdown), and the minor_breaks scale setting is ignored. If querychat's writer ever changes, that section is the single place to update.

Deliberately not documented: DRAW spatial and map projections, which require a spatial backend querychat execution contexts generally don't (yet) have.

Out of scope: prompt wording around layer-level FROM sources (DRAW ... MAPPING ... FROM <table>). That restriction is removed by #321, which carries the companion prompt change documenting them as supported — so this PR leaves note 3 untouched rather than restating a rule that's about to disappear.

Verification

Every new/changed prompt claim was verified by executing the corresponding query against ggsql 0.5.2, including negative checks: SETTING width => null on range errors and VISUALISE FROM tbl AS t is a parse error. Python prompt tests pass (test_viz_tools.py, test_base.py); the R-side prompt change is the identical markdown file, covered by CI. The existing R test for check_viz_deps() mocks rlang::is_installed(), so it covers the new version check unchanged; ruff check, pyright, and air format are clean on the touched files.

@cpsievert cpsievert changed the title docs(prompts): update ggsql syntax reference for ggsql 0.4-0.5 feat(viz): require ggsql >= 0.5.2 and update syntax prompt for 0.4-0.5 Oct 12, 2026
@cpsievert cpsievert changed the title feat(viz): require ggsql >= 0.5.2 and update syntax prompt for 0.4-0.5 feat(viz): require ggsql >= 0.5.2 and update syntax prompt Oct 12, 2026
cpsievert added a commit that referenced this pull request Oct 13, 2026
With viz execution routed through ggsql.CachingReader (this PR; R
equivalent landing in the same release), DRAW ... MAPPING ... FROM
<source> works end-to-end, so replace the note-3 layer_type workaround
with the layer-level FROM pattern: an example plotting raw points from
the final SELECT alongside a summary line from a CTE (verified
end-to-end through ggsql.CachingReader 0.5.2). Also notes that FROM
attaches to MAPPING — a bare 'DRAW line FROM t' is a parse error.

Ported from #322 (9d87d74), where this prompt change landed ahead of
the execution path that makes it true.
@cpsievert
cpsievert force-pushed the docs/ggsql-syntax-prompt-updates branch from 9d87d74 to bd2dcec Compare October 13, 2026 15:22
@cpsievert
cpsievert force-pushed the docs/ggsql-syntax-prompt-updates branch 4 times, most recently from 46ac717 to cd0a2d9 Compare October 13, 2026 15:43
cpsievert and others added 3 commits October 13, 2026 10:46
The shared ggsql-syntax.md system prompt predates ggsql 0.4.0:

- The range layer's `width` setting was renamed to `hinge` (0.4.0); the
  old `SETTING width => null` now fails validation, so update the range
  bullet and lollipop example.
- VISUALISE FROM now takes exactly one bare source (0.5.0); aliases,
  joins, and comma-separated tables are parse errors.
- Note 3 rewritten: layer-level FROM sources work where querychat runs
  through a ggsql caching reader; the single-final-relation pattern
  stays as the portable recommendation.
- Document new features: `aggregate` setting on identity-stat layers,
  jitter position, boxplot hinge/side settings, categorical-aesthetic
  omission for boxplot/violin/range, polar radar setting, rich-text
  label parsing (+ `parse => false`), and `minor_breaks`.

All claims verified by executing the queries against ggsql 0.5.2.
The system prompt now documents ggsql 0.5.x-only syntax (hinge, aggregate,
jitter, radar, rich-text labels, minor_breaks), so running the visualize
tool against an older ggsql would fail at query-validation time.

- pyproject.toml: viz and dev extras require ggsql>=0.5.2 (was >=0.3.2)
- R DESCRIPTION: ggsql (>= 0.5.2) in Suggests
- Runtime guards (Python has_viz_deps(), R check_viz_deps()) treat
  ggsql < 0.5.2 like a missing install: warn once and drop the
  visualize tool, with messages stating the 0.5.2 requirement
@cpsievert
cpsievert force-pushed the docs/ggsql-syntax-prompt-updates branch from cd0a2d9 to 30139c4 Compare October 13, 2026 15:46
@cpsievert
cpsievert marked this pull request as ready for review October 13, 2026 15:53
The Vega-Lite writer has no caption equivalent and silently drops it
(unlike the native SVG/PDF writers), so stop advertising caption in the
LABEL section and call it out in the Vega-Lite rendering section instead.
Direct source attributions to subtitle, which does render.
@cpsievert
cpsievert merged commit bc6e155 into main Oct 13, 2026
17 checks passed
@cpsievert
cpsievert deleted the docs/ggsql-syntax-prompt-updates branch October 13, 2026 16:35
cpsievert added a commit that referenced this pull request Oct 13, 2026
Port of the prompt update from #321's branch to main's revised
ggsql-syntax.md (which landed via #322 with the rejected-stance note 3).
Accurate once viz execution routes through the caching reader.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant