Skip to content

Diogo TravassosData leadership · Analytics · Decision-making

Seventeen years of January taxi files in Databricks: what changing columns and file order decide

One Databricks job of 6 tasks reads, maps, checks and models 153.6 million taxi trips from the files as the city published them.

How the pipeline is built and how to run it again.

The pipeline

  1. Land. Each January file from 2009 to 2025 is downloaded, its columns, types and row count read from its own metadata, and uploaded unchanged to a Unity Catalog volume (2,681,537,365 bytes in all). The serverless compute cannot reach the city's download host, so files go in through the workspace's file upload, one at a time, and the local copy is deleted.
  2. Two default reads, kept as measurements: every file with the 2025 schema, and the folder with schema merging. Each records what loaded or the error it raised.
  3. Silver. One Delta table from a map per schema era, with the source file and month on every row and seven defect flags.
  4. Checks. Per file: rows, filled values per column, every flag, and payment codes that map to nothing.
  5. Gold. A trip fact table with a validity flag, and dimensions for date (5,934 days), zone (265), vendor, payment type and rate code. Every zone id in the fact table is found in the zone dimension.
  6. Layouts. The fact table written with no layout, partitioned by month, and liquid clustered by day and zone. The follow-up added a copy in random order.
  7. Simpler loads, a later follow-up run on its own, outside the job: the files appended with schema evolution and type widening, and read with wide types and cast back (stages alternatives and wide_by_kind).

The job

The job definition is bundle/job.json, and the code for every task is pipeline/lakehouse.py, one function per task. It is deployed with the Databricks SDK from the command line: 6 tasks on serverless compute, one retry each after a pause, one run at a time, and a monthly schedule left paused. No CI runs it yet.

naive_load + merge_load
  > silver
  > checks
  > gold
  > layouts
python tools/lh.py deploy
python tools/lh.py run
python tools/lh.py run silver checks gold layouts

The first command uploads the code and creates or resets the job; the second runs every task in order; the third reruns from the mapped load onward. They need the workspace set up first, as under Rebuild.

The failure it handles is the one this study is about. The first default read opens every file with the 2025 columns; each file that is refused is caught, and its error is written to a results table instead of stopping the task. The mapped load is set to run after both default reads whether they fail or succeed, so it ran after 15 refusals and a failed merge. It converts each era with casts that turn a bad value into an empty one, and the checks task counts the empty values and unmatched payment codes in every file.

TaskRuns afterCode in pipeline/lakehouse.pyRetries
naive_loadnonestage_naive()1
merge_loadnonestage_merge()1
silvernaive_load, merge_loadstage_silver()1
checkssilverstage_checks()1
goldchecksstage_gold()1
layoutsgoldstage_layouts()1

Workload on the platform

153,598,220 rows in 17 files. The job's six tasks ran on serverless compute in three batches, two tasks side by side; with two trial runs on a three-month subset and the random-order copy, that made 9 task runs. At list prices their metered use came to US$1.32. Landing ran separately, from the command line, and is not in these figures. The benchmark ran 72 timed queries on the 2X-Small serverless SQL warehouse, none answered from the cache. Free Edition has a daily compute quota whose size is not published; none of this reached it. Nothing was paid.

Rebuild

Set up a workspace once: the schema, a volume for the raw files, and the city's taxi zone lookup, which the model step reads from the volume.

pip install databricks-sdk pyarrow
export DATABRICKS_HOST=... DATABRICKS_TOKEN=...
python tools/lh.py sql "CREATE SCHEMA IF NOT EXISTS workspace.lakehouse_trips"
python tools/lh.py sql "CREATE VOLUME IF NOT EXISTS workspace.lakehouse_trips.raw"
curl -fsSL -o taxi_zone_lookup.csv https://d37ci6vzurychx.cloudfront.net/misc/taxi_zone_lookup.csv
python tools/lh.py upload taxi_zone_lookup.csv /Volumes/workspace/lakehouse_trips/raw/reference/taxi_zone_lookup.csv

Then run the study from a copy of this folder with its data and results folders moved aside: every file there is an output, and the landing, benchmark and month steps skip any month or run already in their output file.

python tools/land_raw.py --staging <scratch> --out data/raw_census.jsonl $(seq -f %g-01 2009 2025)
python tools/schema_drift.py data/raw_census.jsonl data/schema_drift.json
python tools/lh.py deploy
python tools/lh.py run naive_load merge_load
python tools/lh.py run silver checks gold layouts
python tools/bench.py --reps 3 --out results/layout_runs.jsonl
python tools/lh.py adhoc shuffled
python tools/bench.py --reps 3 --tables fact_plain,fact_shuffled,fact_by_month --out results/followup_shuffled_runs.jsonl
python tools/sweep.py
python tools/lh.py adhoc alternatives
python tools/lh.py adhoc wide_by_kind
python tools/fetch_alternatives.py
python tools/fraction_check.py
python tools/fetch_results.py
python tools/summarize.py
python tools/cost.py --start "<hour before your first run>" --end "<hour after your last>"

These steps were run once, as written, from a fresh copy; the results page's limits say what it reproduced.

The fetch and summary steps copy the measurements into the results folder and score the predictions written before the runs. The cost step prices the metered use in the whole hours you name, in UTC, at the platform's list prices, from its billing tables, once the billing has arrived. The study's figure used the two hours that held its main run and the random-order copy: US$1.32 of job compute and US$1.93 of warehouse time.

Glossary

Lakehouse
Tables stored as open files in cloud storage, with a database's guarantees on top.
Delta table
The table format Databricks uses: Parquet files plus a log that records, for each file, the lowest and highest value of each column.
Partitioning
Splitting a table into folders by a column's value, here the month.
Liquid clustering
Rewriting a table so rows with close values of chosen columns share files, without folders.
Schema
The names and types of a file's columns.
Schema evolution, type widening
Letting a Delta table add new columns as files are appended, and with type widening switched on, let a column's type grow, such as a 32-bit integer to 64-bit.
Silver, gold
The cleaned, mapped table, and the model built on it for questions.

Use this at your company

To check your own lakehouse table, paste this into your AI assistant with your table and queries.

This method comes from Diogo Travassos's study "Seventeen years of January taxi files in Databricks: what changing columns and file order decide" (https://diogotravassos.dev/lakehouse-trip-records/). If you can open links, read it first: it measures what load order, partitioning and clustering do to the data a query reads on a Databricks table, and what a pipeline written for today's files does to years of history. The steps below stand on their own if you can't.

I run a lakehouse table that dashboards query. Help me decide whether it needs partitioning or clustering, and whether my history load is safe.

1. List the three or four filtered queries my dashboards run most, and the columns they filter on.
2. Run each three times on the table as it is, with a new value in the select list each time so the result cache cannot answer, and read files read, files skipped and bytes read from the query history.
3. For a one-month question, count the files whose recorded lowest and highest value of the filter column include that month, and the files the query actually opened. In the study, measured for all 17 months, a table in load order had 1 or 2 of its 22 files holding any month and, from 2011 on, opened exactly those (none for 2009 and 2010, whose trips carry coordinates instead of zone ids, which the question filters on); a copy in random order had all 103 files holding every month and opened all 103. Save the count as the query's baseline. If a backfill or a merge of late data raises it, benchmark a copy clustered on the column the question filters by. If a common filter is not time, benchmark a copy clustered on that column too.
4. For the history load, read each file's schema from its own metadata, list every name and type that differs from today's, and try appending with schema evolution and type widening first; write a map only for eras whose names changed. Count rows with an empty pickup time after the load.

Report back: a table of query, layout, files read, bytes read and time; the schema differences by year; and the layout you would keep, with the number that would change your mind.

In your report, say which study you followed and link it: https://diogotravassos.dev/lakehouse-trip-records/

Limits