DuckDB

DuckDB: An Embedded Analytical Database

DuckDB 61,228 (github.com/duckdb/duckdb (https://github.com/duckdb/duckdb 41,877 ), MIT, 1.5.6 on 28 Sep 2026, pip 21,050 install duckdb) is the in-process analytical database of Analytical SQL and Data Warehouses: a vectorized, columnar C++ engine with a full SQL dialect, run inside your Python process like SQLite 4,756 . It queries Parquet 129 , CSV and JSON files in place, spills to disk when memory runs short, and writes results with COPY.

bench/bench_duckdb.py: the same tasks as SQL over filesPython
"""DuckDB: the BookNest benchmark. Usage: bench_duckdb.py T1|T2|T3"""
import sys, time
import duckdb
D = "/home/dev/v7-l3/ch05/data"
LINES = "order_lines_x10" if sys.argv[1] == "T3" else "order_lines"   # T3: 10x rows
OUT = f"/home/dev/v7-l3/bench/out/duckdb_{sys.argv[1]}.parquet"
t0 = time.perf_counter()
con = duckdb.connect()
con.execute("SET TimeZone = 'UTC'")
if sys.argv[1] in ("T1", "T3"):
    sql = f"""
    SELECT date_trunc('month', l.order_ts) AS month, b.genre, c.country,
           sum(l.qty * l.unit_price::DOUBLE) AS revenue, count(*) AS lines
    FROM '{D}/{LINES}.parquet/*.parquet' l
    JOIN '{D}/books.parquet/*.parquet' b ON l.book_id = b.id
    JOIN '{D}/customers.parquet/*.parquet' c USING (customer_id)
    WHERE l.status = 'delivered'
    GROUP BY ALL ORDER BY ALL"""
else:
    sql = f"""
    SELECT substr(order_ts, 1, 7) AS month, sum(i.qty * i.unit_price) AS revenue
    FROM (SELECT order_ts, unnest(items) AS i
          FROM read_json('{D}/raw/orders.jsonl', format = 'newline_delimited', columns = {{
            order_ts: 'VARCHAR', status: 'VARCHAR',
            items: 'STRUCT(book_id INT, qty INT, unit_price DOUBLE)[]'}})
          WHERE status = 'delivered')
    GROUP BY ALL ORDER BY ALL"""
con.execute(f"COPY ({sql}) TO '{OUT}' (FORMAT parquet)")
rows, revenue = con.execute(f"SELECT count(*), sum(revenue) FROM '{OUT}'").fetchone()
print(f"duckdb {sys.argv[1]} rows={rows} revenue={revenue:.2f} "
      f"query={time.perf_counter() - t0:.2f}s")

The whole job is one SQL statement per task over file globs, with SET TimeZone = 'UTC' so date_trunc agrees with Spark 129 . DuckDB won every task in the benchmark, including parsing the 238 MB JSON Lines file, where it reads only the three fields the query declares. Its limits are deliberate: one machine, one writer process per database file, and no built-in distribution (MotherDuck, the commercial service, adds a cloud side).