Investigations with DuckDB 2.0 and public data

The DuckDB Casebook

Investigations of markets, consumer behavior and public data, showing how to turn imperfect records into defensible answers. Each chapter defines what a row means, makes the comparison that answers its question, separates a change in the world from a change in the records, and tests whether the answer survives.

First draft December 2026. Numbers may still change.

Vishal Singh · Uma Huggins

Contents

Part IV — Business workflows

The kind of work an analyst inherits: a wholesaler's invoices, a shop's order book, a stack of annual reports, a product catalog enriched by a model. Each ends with tables someone can run again next month.

  1. 10A state wholesaler's books, rebuilt from its invoicesIowa is the only wholesaler of spirits in the state, and it publishes every invoice line since 2012. Loading the files naively overstates recent revenue by a fifth; loaded idempotently, they match the state's annual report, and they show sales growing on mix and price while volume fell after 2021.
  2. 11Cohort retention for an online shop, from one Excel workbookA UK online gift wholesaler's two years of invoices, read straight from Excel: about one new customer in five orders again the next month, returning customers bring in 80% to 91% of revenue, and in 2011 the shop held revenue flat on half as many new customers.
  3. 12Peer benchmarks from every 10-KBuilt from the SEC's XBRL extracts of every 10-K, an industry benchmark for fiscal 2025 shows the typical semiconductor company earning 2 cents of operating profit per dollar of revenue while the industry as a whole earned 35. One company in seven later changed a prior-year figure.
  4. 13A catalog that knows what needs reviewDecision models tag jewelry images with a probability for every option. Stored as rows in DuckDB, those probabilities pick out answers worth a second look, but a threshold tuned on half of 28 labelled images missed its error target on the other half. The output is a review queue, not an accuracy claim.

Gallery

  1. When New York rides: 2009 vs 2026Pickups by hour and weekday in April 2009 and April 2026, read in place from TLC's parquet files and shaped with PIVOT.
  2. Rain and ridesNew York pickups in wet and dry hours, March to June 2026, matched to Central Park's hourly weather report with an ASOF JOIN.
  3. Chain footprints on a hex gridWhere the 12 US storefront chains with the most places in Overture are, counted into H3 cells straight from Overture's S3 parquet.
  4. GitHub's event mix, and the day it stopped being comparableEvent types in 58 sampled GH Archive hours from 2015 to 2026, read with read_json over a URL list and probed with VARIANT across a payload change.
  5. The family tree of OLMo 2 13BEvery Hugging Face model that declares OLMo 2 13B as an ancestor, fetched generation by generation and walked with a recursive CTE.
  6. Ride-hail overtakes cabsMonthly New York trips by yellow and green cabs and by the four app companies, 2009 to 2026: the apps passed the cabs in February 2017.
  7. Tip bunching by yearThe share of New York yellow-cab card-coded trips whose tip lands exactly on a percentage where that vendor's tips bunch (the screens' likely defaults), by year and payment vendor, 2009 to 2026, from Chapter 8's read of every TLC trip file.
  8. One dataset, two layouts120 million yellow-cab trips written as one file, as Hive year/month partitions, and with DuckDB 2.0's PARTITION_PATH and ORDER_BY, then measured by how much of each a query has to read.
  9. Nutri-Score by food groupHow many US packaged products in each food group Open Food Facts grades D or E on Nutri-Score, from Chapter 4's read of the Open Food Facts product file.