frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

ggsql: A Grammar of Graphics for SQL

https://opensource.posit.co/blog/2026-04-20_ggsql_alpha_release/
96•thomasp85•1h ago

Comments

thomasp85•1h ago
The new visualisation tool from Posit. Combines SQL with the grammar of graphics, known from ggplot2, D3, and plotnine
thomasp85•1h ago
I'm one of the authors - happy to take any questions!
mi_lk•1h ago
I don't think D3 uses grammar of graphics model?
thomasp85•59m ago
I'd say it does, though it is certainly much more low-level than e.g. ggplot2. But the basic premises of the building blocks described be Leland Wilkinson is there
zcw100•58m ago
Don't forget Vega! https://vega.github.io/vega/
kasperset•1h ago
Looks intriguing. Brings plotting to Sql instead of “transforming” sql for plotting.
radarsat1•1h ago
Wow, love this idea.
anentropic•58m ago
Maybe I skim read it too fast, but I did not find any clear description in the blog post or website docs of how this relates to SQL databases

I was kind of guessing that it doesn't run in a database, that it's a SQL-like syntax for a visualisation DSL handled by front end chart library.

That appears to be what is described in https://ggsql.org/get_started/anatomy.html

But then https://ggsql.org/faq.html has a section, "Can I use SQL queries inside the VISUALISE clause," which says, "Some parts of the syntax are passed on directly to the database".

The homepage says "ggsql interfaces directly with your database"

But it's not shown how that happens AFAICT

confused

password4321•54m ago
Yes this was my question as well, an example showing all the plumbing/dependencies to generate a graph from an external database server would be very helpful.
thomasp85•50m ago
We certainly plan to create a few videos showing how to set it up and use it. If you use it in Positron with the ggsql extension it can interact directly with the connection pane to connect to the various backends you have there
thomasp85•52m ago
That is fair - it is somewhat of a special concept.

ggsql connects directly with your database backend (if you wish - you can also run it with an in-memory DuckDB backend). Your visual query is translated into a SQL query for each layer of the visualisation and the resulting table is then used for rendering.

E.g.

VISUALISE page_views AS x FROM visits DRAW smooth

will create a SQL query that calculates a smoothing kernel over the data and returns points along that. Those points are then used to create the final line chart

georgestagg•39m ago
ggsql has the concept of a "reader", which can be thought of as the way ggsql interfaces with a SQL database. It handles the connection to the database and generating the correct dialect of SQL for that database.

As an alpha, we support just a few readers today: duckdb, sqlite, and an experimental ODBC reader. We have largely been focusing development mainly around driving duckdb with local files, though duckdb has extensions to talk to some other types of database.

The idea is that ggsql takes your visualisation query, and then generates a selection of SQL queries to be executed on the database. It sends these queries using the reader, then builds the resulting visualisation with the returned data. That is how we can plot a histogram from very many rows of data, the statistics required to produce a histogram are converted into SQL queries, and only a few points are returned to us to draw bars of the correct height.

By default ggsql will connect to an in-memory duckDB database. If you are using the CLI, you can use the `--reader` argument to connect to files on-disk or an ODBC URI.

If you use Positron, you can do this a little easier through its dedicated "Connections" pane, and the ggsql Jupyter kernel has a magic SQL comment that can be issued to set up a particular reader. I plan to expand a little more on using ggsql with these external tools in the docs soon.

nojito•16m ago
Highly suggest leveraging adbc. I would love to use this against our bigquery tables.
efromvt•43m ago
Love the layering approach - that solves a problem I’ve had with other sql/visual hybrids as you move past the basics charts.
kasperset•35m ago
Will this ever integrate rest of the ggplot2 dependent packages described here: https://exts.ggplot2.tidyverse.org/gallery/ in the near or distant future? Sorry if it already mentioned somewhere.
thomasp85•9m ago
I don't think we will get the various niche geoms that have been developed by the ggplot2 community anytime soon.

The point of this is not to superseed ggplot2 in any way, but to provide a different approach which can do a lot of the things ggplot2 can, and some that it can't. But ggplot2 will remain more powerful for a lot of tasks in many years to come I predict

dartharva•33m ago
Would be awesome if somehow coupled into Evidence.dev
gh5000•32m ago
It is conceivable that this could become a duckdb extension, such that it can be used from within the duckdb CLI? That would be pretty slick.
thomasp85•11m ago
That is conceivable, not a top priority as we want to focus on this being a great experience for every backend, but certainly something we are thinking of
getnormality•30m ago
I skimmed the article for an explanation of why this is needed, what problem it solves, and didn't find one I could follow. Is the point that we want to be able to ask for visualizations directly against tables in remote SQL databases, instead of having to first pull the data into R data frames so we can run ggplot on it? But why create a new SQL-like language? We already have a package, dbplyr, that translates between R and SQL. Wouldn't it be more direct to extend ggplot to support dbplyr tbl objects, and have ggplot generate the SQL?

Or is the idea that SQL is such a great language to write in that a lot of people will be thrilled to do their ggplots in this SQL-like language?

EDIT: OK, after looking at almost all the documentation, I think I've finally figured it out - it's a standalone visualization app with a SQL-like API that currently has backends for DuckDB and SQLite and renders plots with Vegalite.

nojito•15m ago
It seems to be for sql users who don’t know python or r.
nchagnet•5m ago
I would even add that it fits into a more general trend where operations are done within SQL instead of in a script/program which would use SQL to load data. Examples of this are duckdb in general, and BigQuery with all its LLM or ML functions.
data_ders•13m ago
ok, this is definitely up my alley. color me nerd-sniped and forgive the onslaught of questions.

my questions are less about the syntax, which i'm largely familiar with knowing both SQL and ggplot.

i'm more interested in the backend architecture. Looking at the Cargo.toml [1], I was surprised to not see a visualization dependency like D3 or Vega. Is this intentional?

I'm certainly going to take this for a spin and I think this could be incredible for agentic analytics. I'm mostly curious right now what "deployment" looks like both currently in a utopian future.

utopia is easier -- what if databases supported it directly?!? but even then I think I'd rather have databases spit out an intermediate representation (IR) that could be handed to a viz engine, similar to how vega works. or perhaps the SQL is the IR?!

another question that arises from the question of composability: how distinct would a ggplot IR be from a metrics layer spec? could i use ggsql to create an IR that I then use R's ggplot to render (or vise versa maybe?)

as for the deployment story today, I'll likely learn most by doing (with agents). My experiment will be to kick off an agent to do something like: extract this dataset to S3 using dlt [2], model it using dbt [3], then use ggsql to visualize.

p.s. @thomasp85, I was a big fan of tidygraph back in the day [4]. love how small our data world is.

[1]: https://github.com/posit-dev/ggsql/blob/main/Cargo.toml

[2]: https://github.com/dlt-hub/dlt

[3]: https://github.com/dbt-labs/dbt-fusion

[4]: https://stackoverflow.com/questions/46466351/how-to-hide-unc...

hei-lima•3m ago
Really cool!

Montgomery Multiplication in Signed Redundant Representations [pdf]

https://github.com/pornin/small-ecdsa/blob/main/tex/mmul.pdf
1•eripen•44s ago•0 comments

The Ultimate Question: What Does the Endgame Look Like?

https://brodzinski.com/2026/04/what-endgame-looks-like.html
1•flail•2m ago•0 comments

Lessons from Going Solo

https://alex000kim.com/posts/2026-04-20-lessons-from-going-solo/
1•alex000kim•2m ago•0 comments

The $400M Machine That Spawned the Most Coveted Toy

https://www.wsj.com/lifestyle/asml-lego-set-euv-machine-61dd93c6
1•pondsider•2m ago•0 comments

GitHub Trip Report (2019)

https://fossil-scm.org/forum/forumpost/536ce98d85
1•thunderbong•3m ago•0 comments

Rip language. Compiles to ES2022. Built-in reactivity

https://github.com/shreeve/rip-lang
1•perfunctory•4m ago•0 comments

Open-Weight Models: Curated Guide for Production LLM Deployment

https://github.com/phlx0/awesome-open-weight-models
1•phlx0•6m ago•0 comments

Cryptocurrency industry on track to surpass 2024 spending on Texas midterm races

https://www.texastribune.org/2026/04/20/texas-crypto-currency-pacs-fairshake-menefee-green/
1•hn_acker•7m ago•1 comments

Codebase Readiness Grid: can your repo handle AI agents?

https://github.com/Kenogami-AI/codebase-readiness
1•zoyth•7m ago•0 comments

Could 'A River Runs Through It' Have Been a Hit Today?

https://www.nytimes.com/2026/04/20/books/could-a-river-runs-through-it-have-been-a-hit-today.html
1•duxup•9m ago•1 comments

Reflections on Vibe Researching

https://joshuagans.substack.com/p/reflections-on-vibe-researching
2•alphabetatango•10m ago•0 comments

Show HN: Evading an AI SOC with Sable from Vulnetic

https://blog.vulnetic.ai/evading-an-ai-soc-with-sable-from-vulnetic-fad12376995c
1•danieltk76•12m ago•0 comments

Why the Wellness Elite Such as Jordan Peterson and Mark Hyman Are Getting Sepsis

https://sgcarney.substack.com/p/the-miracle-treatment-that-almost
2•randycupertino•12m ago•1 comments

Show HN: ANSI Saver for Apple TV

https://apps.apple.com/us/app/ansi-saver/id6762137767
1•lardissone•12m ago•0 comments

Yann LeCun says Dario Amodei "knows nothing about AI effects on jobs"

https://timesofindia.indiatimes.com/technology/tech-news/godfather-of-ai-and-metas-most-popular-e...
2•kordlessagain•13m ago•0 comments

Anthropomorphism and Trust in Human-Large Language Model Interactions

https://arxiv.org/abs/2604.15316
1•Brajeshwar•13m ago•0 comments

Show HN: We trained a 32B model to beat Opus 4 at credit card optimization

https://huggingface.co/spaces/endishai/blog-grpo-credit-cards
2•dimberman•16m ago•0 comments

GraalVM JavaScript Sandboxing

https://www.graalvm.org/latest/security-guide/sandboxing/
1•eatonphil•18m ago•0 comments

A Security Framework Sized for the Business You Run

https://nerdsec.io/blog/a-security-framework-sized-for-the-business-you-actually-run/
2•levidurfee•18m ago•0 comments

You don't need a RAG, you just need RAG

https://enopdf.com/blog/rag-for-pdfs/
1•gcassie•19m ago•0 comments

MNT Reform is an open hardware laptop, designed and assembled in Germany

http://mnt.stanleylieber.com/reform/
1•speckx•19m ago•0 comments

Two Paradoxes Blocking Bitcoin

https://alignmenteconomy.org
2•moeman245•20m ago•1 comments

Show HN: Self-hosted Raspberry Pi wall display (no cloud, no subscription)

https://github.com/silentg33k/chalkboard-installer
1•g_33_k•21m ago•1 comments

Learn Vim for the Last Time

https://danielmiessler.com/blog/vim
1•dolfmaggot•24m ago•1 comments

Build the Dam System

https://jsfour.substack.com/p/build-the-dam-system
1•js4•25m ago•0 comments

Show HN: Germball – Drone-deployed seeds triggered by soil moisture

https://www.indiegogo.com/en/projects/germball/germball--smart-seed-capsule
1•lukascodes•25m ago•0 comments

Corporate Bullshit Considered Harmful

https://chuniversiteit.nl/papers/corporate-bullshit
1•ibobev•26m ago•0 comments

Highlighting Interactive Code Blocks

https://www.redblobgames.com/blog/2026-04-16-highlighting-interactive-code-blocks/
1•ibobev•26m ago•0 comments

US birth records uncover an autism risk surge tied to common drugs

https://medicalxpress.com/news/2026-04-millions-birth-uncover-autism-surge.html
1•OutOfHere•26m ago•0 comments

Haversine Distance

https://www.4rknova.com//blog/2026/04/19/haversine-distance
1•ibobev•27m ago•0 comments