ggsql
A experimental SQL extension for declarative data visualisation based on the Grammar of Graphics.
ggsql is a SQL extension that embeds data visualization directly in SQL queries using Grammar of Graphics syntax. It splits queries at the VISUALISE boundary, passing the SQL portion to a data source (like DuckDB) and compiling the visualization portion into specs that can be rendered through various backends (Vega-Lite, ggplot2, etc.).
The package provides a complete ecosystem for declarative visualization including a tree-sitter grammar with full AST validation, multiple interfaces (CLI tool, REST API, Jupyter kernel, VS Code extension with Positron integration), and Python bindings that output Altair charts. Its pluggable architecture supports different data readers (DuckDB, PostgreSQL, CSV) and visualization writers, allowing single queries to combine data transformation with visualization specifications for multiple geometric layers, scales, facets, and coordinate systems.




