Today, we are super excited to announce the alpha-release of ggsql . As the name suggests, ggsql is an implementation of the grammar of graphics based on SQL syntax, bringing rich, structured visualization support to SQL. It is ready for use in Quarto, Jupyter notebooks, Positron and VS Code among others.
In this post we will go over some of the motivations that lead us to develop this tool, as well as give you ample examples of its use; so you can hopefully get as excited about it as we are.
Meet ggsql#
Before we discuss the why, let’s see what ggsql is all about with some examples.
The first plot#
To get our feet wet, lets start with the hello-world of visualizations: A scatterplot, using the built-in penguins dataset:
VISUALIZE bill_len AS x, bill_dep AS y FROM ggsql:penguins DRAW point
That wasn’t too bad. Sure, it has the verbosity of SQL, but that also means that you can speak your plot code out loud and understand what it does. We can break down what is going on here line-by-line:
We initiate the visual query with VISUALIZE and provide a mapping from the built-in penguins dataset, relating x to the data in the bill_len column, and y in the bill_dep column. We draw a point layer that, by default, uses the mapping we defined at the top.
With this in place, we can begin to add to the visualization:
... continue reading