Search Shortcut cmd + k | ctrl + k
improv

Improv's spreadsheet formula language (674 functions) and multidimensional models (categories, measures, formulas over them) on DuckDB tables

Maintainer(s): gburd

Compatibility Matrix

This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.

Platform 1.4.4 1.4.5 1.5.5 1.5.6 2.0.0
Linux AMD64
Linux ARM64
macOS AMD64
macOS ARM64
Windows AMD64
Windows ARM64
WebAssembly

Installing and Loading

INSTALL improv FROM community;
LOAD improv;

Example

LOAD improv;
-- Any of Improv's 674 built-in functions, on named inputs.
SELECT improv_calc('ROUND(PMT(rate/12, n, -pv), 2)',
                   json_object('rate', 0.06, 'n', 360, 'pv', 200000));  -- 1199.1
SELECT improv_calc_text('1/0');                                          -- #DIV/0!
SELECT name, signature FROM improv_functions(query := 'pmt');
-- A multidimensional model over a table: one row per computed cell.
CREATE TABLE sales AS SELECT * FROM (VALUES
  (2024, 'WidgetA', 10, 100), (2024, 'WidgetB', 20, 50),
  (2025, 'WidgetA', 11, 120), (2025, 'WidgetB', 20, 40)) t(year, product, price, qty);
SELECT * FROM improv('sales', '
  category Time = year
  category Product = product
  input Price = price
  input Quantity = qty sum
  Revenue = Price * Quantity
  Share = Revenue / SUM(Revenue OVER Product)
  Growth = Revenue - PREV(Revenue, Time, 1, 0)');

About improv

Improv is a multidimensional spreadsheet in the Lotus Improv / Quantrix tradition: data lives in categories (Time, Product, Region) instead of cell addresses, and formulas name measures (Revenue = Price * Quantity), so one formula covers every cell it applies to.

This extension brings its formula engine to DuckDB:

  • improv_calc(formula [, inputs]) evaluates a scalar Improv formula (math, statistics, financial, text, dates, engineering, IF, LET, LAMBDA; aggregations over categories need a model) on named inputs passed as a JSON object. An error value is NULL; improv_calc_text returns any type and renders errors (#DIV/0!).
  • improv_functions([query := ...]) lists the functions with their signatures and descriptions.
  • improv(source, model) reads a table or a SELECT, builds a model from a short spec (categories from columns, inputs from columns with an optional sum/avg/min/max/count, derived measures as formulas, with aggregations across categories and PREV/NEXT along them) and returns one row per computed cell, ready to join.

The same engine runs Improv's desktop GUI, terminal UI, CLI and its PostgreSQL extension (pg_improv). Source: https://codeberg.org/gregburd/improv

Added Functions

function_name function_type description comment examples
improv table NULL NULL  
improv_calc scalar NULL NULL  
improv_calc_text scalar NULL NULL  
improv_functions table NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

name description input_type scope aliases typed_value
temp_directory Set the directory to which temporary files are written. VARCHAR GLOBAL [] post.db.tmp