Skip to content

ggsql announcement#170

Open
thomasp85 wants to merge 18 commits intoposit-dev:mainfrom
thomasp85:blog/ggsql-announcement
Open

ggsql announcement#170
thomasp85 wants to merge 18 commits intoposit-dev:mainfrom
thomasp85:blog/ggsql-announcement

Conversation

@thomasp85
Copy link
Copy Markdown
Contributor

No description provided.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 14, 2026

Deploy Preview for posit-open-source canceled.

Name Link
🔨 Latest commit 7dbf55d
🔍 Latest deploy log https://app.netlify.com/projects/posit-open-source/deploys/69e1e7119342ec0008462418

Copy link
Copy Markdown

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice piece!

Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd
Comment thread content/blog/ggsql_alpha_release/index.qmd
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
@cwickham
Copy link
Copy Markdown
Collaborator

/deploy-preview

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

@georgestagg
Copy link
Copy Markdown

This plot looks great in landscape on mobile, but terrible in portrait. I don’t know if anything can be done about it, I assume it’s a vegalite problem…

IMG_1150 IMG_1151

Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Co-authored-by: Teun van den Brand <49372158+teunbrand@users.noreply.github.com>
Co-authored-by: George Stagg <georgestagg@gmail.com>
Co-authored-by: Thomas Lin Pedersen <thomasp85@gmail.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 16, 2026

Preview not available

This PR is from a fork and cannot deploy a preview automatically.
A repository member can comment /deploy-preview to trigger one
(including you, if you have member access).

@thomasp85
Copy link
Copy Markdown
Contributor Author

I've noticed other places that vegalite looks horrible on mobile. Currently investigating whether we can shrink the visualisation below a certain width threshold

@jeroenjanssens
Copy link
Copy Markdown
Collaborator

/deploy-preview

@thomasp85
Copy link
Copy Markdown
Contributor Author

/deploy-preview

@cwickham
Copy link
Copy Markdown
Collaborator

/deploy-preview

@cwickham
Copy link
Copy Markdown
Collaborator

@thomasp85 next time you push, you should get a comment checking your post YAML header. We changed a few things recently, so you'll be flagged for (and need to fix): categories -> topics, and place post folder at top-level content/blog. Let me know if it doesn't trigger of if it flags anything unexpected.

@cwickham
Copy link
Copy Markdown
Collaborator

I'm going to close and re-open this PR to try and debug some CI stuff. Sorry for the noise.

@cwickham cwickham closed this Apr 16, 2026
@cwickham cwickham reopened this Apr 16, 2026
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
### A (simple) example
Let's start with some code even though we haven't introduced the syntax yet. I promise we will go through it below. The example is an adaptation of a visualization created by [Jack Davison](https://jack-davison.github.io) for TidyTuesday.

```{ggsql}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance at all of somehow getting this syntax highlighted in the final rendered post?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no... sadly not

Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql/alpha_release/index.qmd Outdated
cwickham added a commit that referenced this pull request Apr 16, 2026
Fork PRs get a read-only GITHUB_TOKEN on pull_request events, so the
sticky-comment step in validate-blog-posts.yml fails with "Resource
not accessible by integration" (e.g. run 24529154129 on PR #170).

Move the commenting step into a second workflow triggered by
workflow_run, which runs from main with a write-capable token.
The validation job now uploads the report (plus the PR number) as
an artifact; the new comment-blog-validation.yml downloads it and
posts the sticky comment. Untrusted PR code only ever runs with
the read-only token; the write-token job never checks out PR code,
only the pre-generated markdown artifact.
cwickham added a commit that referenced this pull request Apr 16, 2026
Fork PRs get a read-only GITHUB_TOKEN on pull_request events, so the
sticky-comment step in validate-blog-posts.yml fails with "Resource
not accessible by integration" (e.g. run 24529154129 on PR #170).

Move the commenting step into a second workflow triggered by
workflow_run, which runs from main with a write-capable token.
The validation job now uploads the report (plus the PR number) as
an artifact; the new comment-blog-validation.yml downloads it and
posts the sticky comment. Untrusted PR code only ever runs with
the read-only token; the write-token job never checks out PR code,
only the pre-generated markdown artifact.
@thomasp85
Copy link
Copy Markdown
Contributor Author

/deploy-preview

Copy link
Copy Markdown

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few last nitpicks, the rest reads great!

Comment thread content/blog/ggsql_alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql_alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql_alpha_release/index.qmd Outdated
Comment thread content/blog/ggsql_alpha_release/index.qmd Outdated
thomasp85 and others added 3 commits April 17, 2026 09:51
Co-authored-by: Teun van den Brand <49372158+teunbrand@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Blog YAML Checks

✅ All 1 posts passed.

Copy link
Copy Markdown

@hadley hadley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh I commented all these on the .md

Comment thread content/blog/ggsql_alpha_release/index.md

Today, we are super excited to formally announce the alpha-release of [ggsql](https://ggsql.org). As the name suggests, ggsql is an implementation of the grammar of graphics based on the SQL syntax, bringing rich, structured visualization support to SQL for the first time.

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 (if you can't wait to get excited, [jump straight to the examples](#meet-ggsql)).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO you should include one example here

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even flip the order; show the results then discuss the motivation.

Comment thread content/blog/ggsql_alpha_release/index.md
Comment thread content/blog/ggsql_alpha_release/index.md
Comment thread content/blog/ggsql_alpha_release/index.md
Comment thread content/blog/ggsql_alpha_release/index.md
Comment thread content/blog/ggsql_alpha_release/index.md
Comment on lines +101 to +104
QUALIFY ROW_NUMBER() OVER (
PARTITION BY name
ORDER BY mission_number DESC
) = 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we simplify this? It's a bit distracting to hit some complex SQL syntax when the focus should be on the visualisation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the example is moved down don't you think it will be ok. The point was really to show a full pipeline including some meaningful SQL preparation

Comment thread content/blog/ggsql_alpha_release/index.md
It should also be noted that the SQL query part is optional. If your data is already in the right shape for plotting you can skip it and instead name the source directly in the `VISUALIZE` clause:

``` ggsql
VISUALIZE year_of_selection AS x, year_of_mission AS y FROM 'astronauts.parquet'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VISUALIZE year_of_selection AS x, year_of_mission AS y FROM 'astronauts.parquet'
FROM 'astronauts.parquet'
VISUALIZE year_of_selection AS x, year_of_mission AS y

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that won't work - everything above VISUALIZE is ignored

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should add support for the equivalent of duckdb's,

D FROM 'penguins.csv' LIMIT 2;
┌─────────┬───────────┬───┬───────────────────┬─────────────┬─────────┐
│ species │  island   │ … │ flipper_length_mm │ body_mass_g │   sex   │
│ varchar │  varchar  │   │       int64       │    int64    │ varchar │
├─────────┼───────────┼───┼───────────────────┼─────────────┼─────────┤
│ Adelie  │ Torgersen │ … │               181 │        3750 │ MALE    │
│ Adelie  │ Torgersen │ … │               186 │        3800 │ FEMALE  │
├─────────┴───────────┴───┴───────────────────┴─────────────┴─────────┤
│ 2 rows                                          7 columns (5 shown) │
└─────────────────────────────────────────────────────────────────────┘

if we can. I have had someone else ask for the same thing, with FROM at the front.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not for initial release, if the required grammar changes end up being a pain.

The last clause in our visual query is `LABEL` which allows us to add or modify various text labels like title, subtitle, and axis and legend titles.

### Stepping back
That was a mouthful. But there are two very silvery linings to it all:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would be better to step people up to the complex example.

If you wanted to keep a complex example first, I'd suggest you just show it, then explain the syntax with simple plots, then come back to an explanation of the complex plot.

SETTING position => 'jitter', distribution => 'density'
```

As you can see the syntax and composable nature makes visualization iteration very ergonomic, something that is extremely valuable in both explorative analyses and visualization design.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add one example of mapping points to colour (or similar) here.

As you can see the syntax and composable nature makes visualization iteration very ergonomic, something that is extremely valuable in both explorative analyses and visualization design.

## Behind the curtains
With a passing understanding of how to use ggsql, let's discuss what goes on behind the scenes. At its core ggsql is a modular Rust library that is split into a Reader module, a Plot module, and a Writer module. Both the Reader and Writer can be swapped out, leaving the Plot module as the only constant.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest you drop this entire section and move it to the site somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants