Gallery · Embedded SQL

A year of trips, four files, no import step

A year of bike-share trips split across four Parquet files, queried where they lie by an engine running inside the process. No server, no import step, and a window function that sorts the network into commuters and afternoon wanderers.

duckdb-parquet.verso C# · SQL · Python · 15 cells Read-only preview Download

A year of trips, four files, no import step

DuckDB is an analytical database that runs inside your process. There is no server to start and, for this notebook, no database file either: the data stays in four Parquet files on disk and DuckDB reads them where they lie.

That is the part worth seeing. A year of bike-share trips arrived the way exports usually arrive, split one file per quarter, and the usual next step is to load them into something before you can ask a question. Here the loading step does not exist. The first query reads all four files and the last one hands its result to Python for a chart.

[1]
codeC#
1#r "nuget: DuckDB.NET.Data.Full, 1.5.5"
✓completed
Installed Packages
  • DuckDB.NET.Data.Full, 1.5.5
Transitive dependencies (3)
  • Apache.Arrow, 23.0.0
  • Apache.Arrow.Scalars, 23.0.0
  • DuckDB.NET.Bindings.Full, 1.5.5

Verso connects to any ADO.NET provider, so DuckDB is reached the same way SQL Server or PostgreSQL would be. Data Source=:memory: means there is no database file at all: the engine exists only for the length of this run, and everything it reads comes from the Parquet files.

[2]
codeC#
1#!sql-connect --name trips --connection-string "Data Source=:memory:" --provider DuckDB.NET.Data --default
✓completed
Connected 'trips' (default) using DuckDB.NET.Data — database: :memory:
  Connection string: Data Source=:memory:

What is in the files

read_parquet takes a glob. DESCRIBE in front of a query returns the columns and their types, read out of the Parquet footers rather than declared anywhere, which is the whole reason this works without an import.

[3]
sql
1DESCRIBE SELECT * FROM read_parquet('trips-2026-q*.parquet')
✓completed
column_namecolumn_typenullkeydefaultextra
trip_idBIGINTYESNULLNULLNULL
started_atTIMESTAMPYESNULLNULLNULL
stationVARCHARYESNULLNULLNULL
minutesINTEGERYESNULLNULLNULL
memberBOOLEANYESNULLNULLNULL

Four files, thirty-two thousand trips, a full year. Counting them all is one statement and it never materializes a table.

[4]
sql
1SELECT count(*) AS trips,
2 count(DISTINCT station) AS stations,
3 min(started_at)::DATE AS first_day,
4 max(started_at)::DATE AS last_day,
5 round(avg(minutes), 1) AS avg_minutes
6FROM read_parquet('trips-2026-q*.parquet')
✓completed
tripsstationsfirst_daylast_dayavg_minutes
3199781/1/202612/31/202617.9

When each station is busy

Now a real question: for each station, which hour of the day is its busiest. That is a ranking within a group, which means a window function, and DuckDB has QUALIFY for filtering on one without nesting the query yourself.

The answer sorts the network into three groups, and nobody had to label a single station for it to do so.

[5]
sql
1SELECT station,
2 hour_of_day,
3 trips
4FROM (
5 SELECT station,
6 extract(hour FROM started_at) AS hour_of_day,
7 count(*) AS trips
8 FROM read_parquet('trips-2026-q*.parquet')
9 GROUP BY ALL
10)
11QUALIFY rank() OVER (PARTITION BY station ORDER BY trips DESC) = 1
12ORDER BY hour_of_day, station
✓completed
stationhour_of_daytrips
Business Park8467
Central Station8513
Harbour Steps14327
Lakeside Path15327
Riverside North15345
Market Square16340
Old Mill17317
University Gate17427

Central Station and Business Park peak at eight in the morning, on the way in. Market Square, Old Mill and University Gate peak between four and five, on the way home. Harbour Steps, Lakeside Path and Riverside North peak in the middle of the afternoon, which is nobody's commute: those are the three by the water.

Handing the result to another language

A query with --name publishes its result into the notebook's variable store as a DataTable. C# picks it up by name, pulls out three plain lists, and Python draws from those as though it had built them itself.

[6]
sql
1--name profiles
2SELECT extract(hour FROM started_at) AS hour_of_day,
3 count(*) FILTER (WHERE station = 'Central Station') AS commuter,
4 count(*) FILTER (WHERE station = 'Lakeside Path') AS leisure
5FROM read_parquet('trips-2026-q*.parquet')
6GROUP BY ALL
7ORDER BY hour_of_day
✓completed
hour_of_daycommuterleisure
0610
1125
277
3177
4105
57947
619263
734990
8513120
9387168
10241219
11195214
12153259
13189316
14263304
15348327
16493293
17492261
18432203
19311153
20180120
218680
224965
234553
[7]
codeC#
1using System.Data;
2
3var table = Variables.Get<DataTable>("profiles")!;
4
5var hours = new List<double>();
6var commuter = new List<double>();
7var leisure = new List<double>();
8
9foreach (DataRow row in table.Rows)
10{
11 hours.Add(Convert.ToDouble(row["hour_of_day"]));
12 commuter.Add(Convert.ToDouble(row["commuter"]));
13 leisure.Add(Convert.ToDouble(row["leisure"]));
14}
15
16$"{hours.Count} hours, {commuter.Sum():N0} commuter trips, {leisure.Sum():N0} leisure trips"
✓completed
24 hours, 5,049 commuter trips, 3,389 leisure trips
[8]
codePython
1import matplotlib.pyplot as plt
2
3# hours, commuter and leisure were left behind by the C# cell above
4x = [int(h) for h in hours]
5
6fig, ax = plt.subplots(figsize=(9.2, 4.0))
7ax.plot(x, [float(v) for v in commuter], marker="o", ms=4, lw=2, label="Central Station")
8ax.plot(x, [float(v) for v in leisure], marker="o", ms=4, lw=2, label="Lakeside Path")
9
10ax.set_title("Trips by hour of day, a commuter station and a waterside one")
11ax.set_xlabel("Hour")
12ax.set_ylabel("Trips in 2026")
13ax.set_xticks(range(0, 24, 2))
14ax.legend(frameon=False)
15ax.spines[["top", "right"]].set_visible(False)
16ax.grid(axis="y", alpha=0.25)
17
18plt.tight_layout()
19plt.show()
✓completed

Two shapes, one dataset. The commuter station has the double hump everyone recognizes: a sharp spike at eight and a broader one across four and five. The waterside station has a single afternoon hill and barely notices rush hour.

Take it home

Download this notebook and the four trips-2026-q*.parquet files from the gallery page, put them in the same folder, then open it in VS Code with the Verso extension or serve it with verso serve duckdb-parquet.verso. Delete three of the four files and rerun: the glob picks up whatever is there, and every query still works on what is left.

Run it yourself

Nothing on this page is executable; the outputs were baked in by a real run. Download the notebook and it runs anywhere Verso does: VS Code, the browser, or the terminal.

dotnet tool install --global Verso.Cli
verso serve duckdb-parquet.verso

This notebook reads trips-2026-q1.parquet, trips-2026-q2.parquet, trips-2026-q3.parquet, trips-2026-q4.parquet; download it into the same folder as the notebook.

What this shows

A year of bike-share trips split across four Parquet files, queried where they lie by an engine running inside the process. No server, no import step, and a window function that sorts the network into commuters and afternoon wanderers.

Every language in this notebook reads and writes the same variable store, so a value produced in one cell is simply there in the next, whatever the language.