Skip to content
DuckDB community extension

yardstick

Measure-aware SQL implementing Julian Hyde's 'Measures in SQL' paper

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 · SQL
INSTALL yardstick FROM community;
LOAD yardstick FROM community;

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

Create a view with measures

SQL
-- Create a view with measures
CREATE VIEW sales_v AS
SELECT
    year,
    region,
    SUM(amount) AS MEASURE revenue,
    COUNT(*) AS MEASURE order_count
FROM sales;

-- Query with AGGREGATE() and AT modifiers
SELECT
    year,
    region,
    AGGREGATE(revenue) AS revenue,
    AGGREGATE(revenue) AT (ALL region) AS year_total,
    AGGREGATE(revenue) / AGGREGATE(revenue) AT (ALL region) AS pct_of_year
FROM sales_v;

Provided by sidequery. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

yardstick implements Julian Hyde's "Measures in SQL" paper (arXiv:2406.00251), adding measure-aware SQL to DuckDB.

Measures are aggregations that know how to re-aggregate themselves when the query context changes. This enables:

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
sidequery/yardstick
License
MIT
Maintainers
sidequery
Written in
C++
Build source
6b5e9ead9dd6
Build definition
Community descriptor