Bindings to ggsql — Grammar of Graphics based visualizations in SQL
Maintainer(s):
thomasp85
Compatibility Matrix
This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 |
|---|---|---|---|---|---|
| Linux AMD64 | |||||
| Linux ARM64 | |||||
| macOS AMD64 | |||||
| macOS ARM64 | |||||
| Windows AMD64 | |||||
| Windows ARM64 | |||||
| WebAssembly |
Installing and Loading
INSTALL ggsql FROM community;
LOAD ggsql;
Example
SELECT 1 AS x, 2 AS y VISUALISE x, y DRAW point;
About ggsql
ggsql extends DuckDB's SQL with the visual query language defined by ggsql
(https://ggsql.org) to allow direct visualization from DuckDB. Results are
served from an in-process HTTP server and opened in the default browser.
The session setting ggsql_output switches to returning a URL, the raw
vega-lite spec, or a self-contained HTML document instead.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| ggsql | scalar | Executes a ggsql query (SQL plus VISUALISE/DRAW clauses) and returns the plot in the format selected by the ggsql_output setting (browser URL, vega-lite spec, HTML, or SVG). | NULL | [ggsql('SELECT range AS x, range*range AS y FROM range(10) VISUALISE x, y DRAW line')] |
| ggsql_run | table | Executes a ggsql query and returns the plot as a one-row table; used for binary output modes ('pdf', 'hep') where the result column is typed as BLOB. | NULL | [SELECT plot FROM ggsql_run('SELECT range AS x FROM range(10) VISUALISE x DRAW line')] |
| ggsql_save | scalar | Renders a ggsql query straight to a file; the writer is inferred from the file extension (.svg, .pdf, .hep, .html, .json) and the output path is returned. | NULL | [ggsql_save('SELECT range AS x FROM range(10) VISUALISE x DRAW line', 'plot.svg')] |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
| name | description | input_type | scope | aliases |
|---|---|---|---|---|
| ggsql_output | Output mode for ggsql queries. 'silent' (default) opens the browser and emits no rows; 'url' opens the browser and returns the plot URL; 'spec' returns the vega-lite JSON; 'html' returns a self-contained HTML document; 'svg' returns SVG text; 'pdf' and 'hep' return binary payloads (BLOB from ggsql_run). | VARCHAR | GLOBAL | [] |
| ggsql_writer_options | Options for ggsql's writers, as semicolon-separated key=value pairs, e.g. 'width=800;height=600'. Applies to the 'svg', 'pdf', 'hep', 'html' modes and the browser display; must be empty for 'spec'. Shared keys: width, height, units, dpi, background. | VARCHAR | GLOBAL | [] |