AI Briefing
KO

ggsql - A Grammar of Graphics for SQL

·2026.04.21 10:35

Key point

ggsql, which writes visualizations using SQL syntax, has been released as alpha.

Details

ggsql is a grammar of graphics implementation that ties SQL queries and graph construction into a single flow using VISUALIZE, DRAW, PLACE, SCALE, and LABEL clauses.

  • Before VISUALIZE is regular SQL, and after it is the visualization query.
  • DRAW adds layers like points, bars, histograms, and boxplots.
  • PLACE is a clause dedicated to annotations like rule lines and text.
  • SCALE converts categorical values into actual colors or scales.
  • LABEL controls titles, subtitles, axis labels, and legend labels.

In the examples, a scatter plot with a regression line is created using the penguins dataset, and for astronauts.parquet, a mean line and text annotation are added on top of a histogram of age distribution. SQL query results are passed directly as visualization input, and the necessary layers are aggregated into a single SQL query, which is explained as advantageous for large-scale data.

For the runtime, it aims to be a small executable that works without an R or Python runtime, and can be used in Quarto, Jupyter notebooks, Positron, and VS Code. It is currently in alpha-release, with plans to add a Rust-based writer, themes, interactivity, a language server, a formatter, spatial data support, and more going forward.

As background for its development, it cites support for SQL-centric users, the compatibility between SQL and grammar of graphics, integration with code-based reporting tools and AI analysis assistants, and the goal of applying the design experience of ggplot2 to a new foundation.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.