On April 20, 2026, Posit released the alpha of ggsql — an open-source extension that adds grammar-of-graphics visualization clauses directly to SQL. If you already work in DuckDB or SQLite and have spent years context-switching into R or Python just to chart query results, ggsql is the project worth watching. The alpha is genuinely usable for scatter plots, histograms, and trend lines today. Production use is a different story.
What ggsql Is and Why Posit Built It
The core idea is simple: rather than piping a query result into a plotting library, you write the visualization as part of the query itself. ggsql extends standard SQL with new clauses that map directly onto the grammar-of-graphics concepts that Hadley Wickham formalized in ggplot2.1
The project was announced by Wickham alongside three Posit engineers — Thomas Lin Pedersen, Teun Van den Brand, and George Stagg — making the ggplot2 lineage explicit rather than incidental.1
The architectural argument is efficiency: ggsql’s reader system translates visualization clauses into database-specific SQL dialects and sends only aggregated or computed statistics to the renderer, not raw rows.1 For large datasets, this means the heavy lifting stays in the database engine rather than being shipped across a process boundary.
Under the hood, the alpha backend runs on DuckDB and SQLite as query engines and renders output via Vega-Lite. The core is written primarily in Rust — 92.7% of the repo by language as of April 20, 2026.2
The Seven Clauses: A Practical Walkthrough
ggsql introduces seven new SQL clauses, each corresponding to a layer in the grammar-of-graphics model3:
- VISUALISE — maps table columns to visual properties (x, y, color, size)
- DRAW — adds mark layers:
point,line,histogram,boxplot,smooth - PLACE — adds literal annotation layers (reference lines, text)
- SCALE — handles binning and value mapping
- PROJECT — defines the coordinate system; translates position aesthetics onto the viewing plane (cartesian, polar, etc.)
- LABEL — sets titles and axis text
- FACET — creates multi-panel layouts
A minimal scatter plot with a smoother looks like this1:
VISUALIZE bill_len AS x, bill_dep AS y, species AS colorFROM ggsql:penguinsDRAW pointDRAW smoothNo Python runtime. No R session. The query runs, the chart renders.
The layered DRAW approach mirrors ggplot2’s + operator directly: you can stack multiple mark types on the same axes the same way you’d chain geom_point() + geom_smooth() in R.
Supported Environments
As of the alpha release on April 20, 2026, ggsql runs in five environments3:
| Environment | Install |
|---|---|
| Jupyter kernel | uv tool install ggsql-jupyter |
| CLI | uv tool install ggsql |
| VS Code | Extension (marketplace) |
| Positron | Extension |
| Quarto | Documents |
What Works Now vs. What’s Still Missing
The alpha is honest about its scope. According to the announcement1, the team explicitly names five gaps:
- Theming infrastructure — no custom fonts, color palettes, or layout control
- Interactivity — charts are static; no tooltips, brushing, or linked selections
- Language server support — no autocomplete or inline linting for ggsql clauses
- Spatial/geospatial data — no map projections or geometry types
- Production deployment workflows — no clear path for serving ggsql charts in production applications
The roadmap addresses all five, plus a planned replacement of Vega-Lite with a high-performance Rust-based rendering backend.1 That renderer swap matters: visual output fidelity will change between now and a stable release, which means charts you generate in the alpha may not look identical in a future version.
At the time of the alpha announcement, the GitHub repository showed 167 stars, 8 forks, and 41 open issues — consistent with day-one adoption from practitioners already filing bugs.2
How It Compares: ggplot2, plotnine, and Mosaic vgplot
| Tool | Language | Runtime | Target context | DuckDB backend |
|---|---|---|---|---|
| ggplot2 | R | R | R notebooks, Quarto | via duckdb R pkg |
| plotnine | Python | Python | Jupyter, scripts | via duckdb Python pkg |
| ggsql | SQL | None (CLI/ext) | SQL notebooks, Quarto | native |
| Mosaic vgplot | JavaScript | Node/browser | Observable, web | DuckDB-WASM |
The nearest architectural relative is Mosaic vgplot — a JavaScript library from UW Interactive Data Lab and CMU Data Interaction Group that also routes grammar-of-graphics mark queries through DuckDB.4 The key difference is deployment target: Mosaic vgplot is built for browser and Observable contexts; ggsql is built for SQL notebook and local development environments. They share a lineage (both use DuckDB as the query engine for aggregation) but serve different audiences.
Against ggplot2 and plotnine, ggsql’s advantage is context switching reduction — no language boundary to cross. Its current disadvantage is iteration speed: a concern raised by a commenter who worked on R tooling at Uber is that re-executing a full SQL query every time you adjust a visual parameter is slower than tools like ggplot2 or Altair that cache data in memory between tweaks.5 This is a real tradeoff during exploratory analysis, and the alpha has no answer for it yet.
The Production-Readiness Checklist: When to Wait
Use ggsql today if:
- You want scatter plots, histograms, or smoothed trend lines in a Quarto document or Jupyter notebook
- Your data already lives in DuckDB or SQLite
- You’re comfortable with alpha-level stability and breaking changes
Wait for a later release if:
- You need themed, branded charts (no theming in alpha1)
- Your workflow requires interactive charts (not available1)
- You’re building spatial visualizations (no geospatial support1)
- You need IDE autocomplete for the new clauses (no language server1)
- You’re deploying to production (no deployment workflow support1)
The Vega-Lite renderer being slated for replacement is an additional reason for caution in any pipeline that depends on visual consistency: the rendering layer will change before a stable release.1
FAQ
Is ggsql a fork of ggplot2 or DuckDB? Neither. ggsql is a new SQL language extension that borrows grammar-of-graphics concepts from ggplot2’s design philosophy. It runs on top of DuckDB or SQLite as its query engine without modifying either.12
What happens to my charts when the Vega-Lite renderer is replaced? The roadmap calls for a Rust-based rendering backend to replace Vega-Lite, but this is not in the alpha.1 Chart appearance may differ after the switch — treat alpha output as non-stable.
Can I use ggsql with any SQL database? As of April 20, 2026, only DuckDB and SQLite are supported as query engines. The modular reader architecture is designed to support additional dialects, but no others are available in the alpha.13