Textplot DuckDB Extension

3 kermatt 1 8/22/2025, 5:08:14 PM query.farm ↗

Comments (1)

tanelpoder · 3h ago
Pretty cool. At some point I wrote my own routines with pure DuckDB SQL, so I wouldn't have to import UDFs, it would all be in just SQL files. DuckDB already has a basic `bar()` function for bar charts [1] and also you could use YouPlot [2] if you prefer just piping the output to some other command instead of using a library or extension. I created my own bar charts though, as I wanted to use the "partial" unicode block characters for more fine-grained bar charts.

I created my own sparklines too with LISTAGG and unicode characters for rendering latency histograms, but the bigger problem there was that some latency buckets didn't have any data falling into them. That missing row of data still needs to be rendered as an empty bucket. So while the pure SQL approach worked, it was a convoluted query where I used an outer join with a list of synthetically generated latency buckets to align the rest of the buckets right.

That was a prototype anyway, later on I switched to returning the filled bucket numbers (latency:count) with LISTAGG as CSV that I later parsed and rendered in the app layer [3]

[1] https://duckdbsnippets.com/snippets/54/quick-inline-bar-char...

[2] https://duckdb.org/docs/stable/guides/data_viewers/youplot.h...

[3] https://tanelpoder.com/posts/xcapture-v3-alpha-ebpf-performa...