Achieve Sorted Tables With Pure SQL Using DuckDB
Ever wanted to sort a table in SQL? CREATE TABLE sensor_data(ts TIMESTAMP, measurement INTEGER, ..., SORTED(ts)); DuckDB's columnar storage format & CHECK constraint make it possible! Achieve sorted tables with pure SQL, no human moderation needed.
🪝 Intro
Ever wanted to get that kind on constraint on a table :
CREATE TABLE sensor_data(
ts TIMESTAMP,
measurement INTEGER,
...,
SORTED(ts)
);
Well, it turns out this topic has a dedicated discussion:
For now it's not implemented...yet. But we have a lot of use cases out there.
Let's see how to achieve this in pure sql... and why it would be so useful.
🍿 Demo
🤔 (A bit of) Context
We are currently using duckdb on GitHub Actions (see opt-nc/setup-duckdb-action) as it's a very convenient and efficient way to check data quality with s...