ggsql: A grammar of graphics for SQL

April 20, 2026
A laptop screen showing programming code and debugging tools, ideal for tech topics.
Photo by Daniil Komov on Pexels

What happened

Posit has announced the alpha release of ggsql, a new take on the grammar of graphics that embeds visualization descriptions directly into SQL queries. The project’s announcement — authored by Thomas Lin Pedersen, Teun Van den Brand, George Stagg and Hadley Wickham — shows a compact SQL-native syntax (VISUALIZE, DRAW, PLACE, SETTING) for composing layered plots. It has been reported that ggsql is already usable in Quarto, Jupyter notebooks, Positron and VS Code, among other environments.

What it does

Think ggplot, but written in SQL. Mappings, layers and scales are expressed as SQL clauses: you VISUALIZE columns as x/y/color, DRAW point or smooth layers, PLACE annotations, and tweak settings inline. The examples range from a penguins scatterplot to a TidyTuesday-style histogram of astronaut ages — simple stuff, but modular. Why does this matter? Because it lets people who live in SQL—analysts, data engineers, anyone running queries against warehouses—author visualizations without switching languages or tooling. Less context switching. Fewer copy-paste horrors. Win.

Why it matters (and what to watch)

This is exciting partly because it marries two familiar worlds: the grammar-of-graphics philosophy popularized by ggplot2 and the ubiquity of SQL in production workflows. That could improve reproducibility and make exploratory viz part of the query lifecycle rather than an afterthought. Caveat: it’s an alpha release — expect rough edges and API churn. If you love tidy graphics and live in a SQL-first stack, ggsql is worth poking. Who doesn’t love fewer steps between data and insight?

Sources: posit.co, Hacker News