Top
Best
New

Posted by thomasp85 13 hours ago

ggsql: A Grammar of Graphics for SQL(opensource.posit.co)
332 points | 71 commentspage 2
tauroid 5 hours ago|
Would be quite compelling if the CLI worked with nushell.

I see the (a?) backend is polars, which is good as well.

This in CLI might be the quickest / tersest way to go from "have parquet / csv / other table format" to "see graph", though a keen polars / matplotlib user would also get there pretty quick.

thomasp85 13 hours ago||
The new visualisation tool from Posit. Combines SQL with the grammar of graphics, known from ggplot2, D3, and plotnine
zcw100 12 hours ago||
Don't forget Vega! https://vega.github.io/vega/
thomasp85 12 hours ago|||
I'm one of the authors - happy to take any questions!
mi_lk 12 hours ago||
I don't think D3 uses grammar of graphics model?
thomasp85 12 hours 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
jorin 10 hours ago||
Really cool project! Would love to see a standard established for representing visualizations in SQL! I built a whole dashboarding tool on top of the idea: https://taleshape.com/shaper/docs/getting-started/ But Shaper takes a more pragmatic approach and just uses built in functionality to describe how to visualize the results. The most value I see with viz as SQL is that it's a great format for LLMs to specify what they want while making it easy to audit and reproduce. Just built a slack bot on top of that concept last week: https://taleshape.com/blog/build-your-own-data-analytics-sla...
gh5000 11 hours 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 11 hours 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
rustyconover 10 hours ago||
With the new PEG parser this is just a Claude session away in DuckDB.
ericdfournier 6 hours ago||
Very cool. Though it would be great to see this implemented as a PostgreSQL extension (if possible).
urams 8 hours ago||
What feels like a lifetime ago, I made almost all of the R tooling at Uber and actually implemented what was effectively exactly this on top of the R DB tooling. Everyone, I think correctly in retrospect, I showed it to thought it was more or less useless. I had hoped it would be a nice way to pull and instantly visualize data but that was rarely all that valuable like this.
psadri 7 hours ago|
What do you think is missing? I'm a big SQL fan and the idea of direct SQL to X seems appealing at least on the surface.
urams 7 hours ago||
Probably the biggest issue is that it's primarily useful in the context of exploratory analysis and makes iteration on a plot much slower, requiring you to re-run the query to get a new viz. Iterating on a viz is best done with the data cached locally or elsewhere.

In the context of a query used for a dashboard in prod, you're likely using a different viz environment so it's not useful at all there.

jiehong 10 hours ago||
The cli only produces vega-lite[0] json graphics, right?

It would be nice if it included a rendering engine.

[0]: https://github.com/vega/vega-lite

thomasp85 9 hours ago|
That is certainly in the pipeline. We chose to start with vegalite so we could focus on the internals of the representation
kasperset 12 hours ago||
Looks intriguing. Brings plotting to Sql instead of “transforming” sql for plotting.
jiehong 10 hours ago||
Outstanding!

This can replace a lot of Excel in the end.

It makes so much sense now that it exists!

More comments...