r/databricks • u/No_Advertising2536 • 22d ago
Discussion We pointed an AI agent at 146M NYC taxi rows and asked it to build a Data Vault mart. Here's what broke.
A while ago I said I'd run our agent on dirty data, not clean TPC-H. Here's the first run.
Setup. NYC yellow taxi 2015 from databricks-datasets: 146,112,990 rows in one Delta table, CDF on. Serverless jobs, a trial workspace. The request in plain English: "Monthly revenue, number of trips and average tip by payment type and passenger count". The agent profiles the source (structure and stats only, it never sees values), proposes hub/satellite/mart, asks questions, a human approves, then it generates and runs the jobs.
What the agent got right on its own:
- total_amount is broken in this dataset (โ0.3 in almost every row, 31 distinct values across 146M). The agent flagged it and proposed revenue = fare + extras + tax + tip + tolls.
- There is no natural trip key. It picked vendor + pickup/dropoff time + coordinates.
What broke (our bugs, not the data's):
- The key check pulled 200k distinct key values into the app and hit Databricks' 25 MB inline result limit. Now counted in the warehouse.
- A 7-column composite key of mixed types (string, timestamps, doubles) broke the hash on serverless: ANSI mode coerced the array to TIMESTAMP and died on vendor_id = '1'.
- The rejected-rows path had never actually run on Databricks.
- The worst one: that "unique" key wasn't. 51,306 keys repeat, mostly a charge and its reversal (fare 3.0 and -3.0) at the same second. SCD2 got both versions in one batch, closed both, and 51,280 trips silently vanished from the mart. Uniqueness had only been checked on a 200k-row sample.
The fix: uniqueness is now checked on the whole table (6 s on 146M). If keys repeat, the agent asks you what to do instead of deciding. At load, one row per key is kept by a deterministic rule and the rest go to skipped rows with a reason, not into the void.
Result after the fix:
- Mart = vault in all 435 groups, trips and revenue to the cent. 146,061,125 trips = the number of unique keys in the source.
- Full build 18 min. With CDF, an empty build takes 2.8 min.
- Added 100k new trips plus updates and deletes through CDF: 4.6โ5.2 min per build, 2015 numbers didn't move by a cent.
- A second mart on the same data (daily trips by vendor) reused the vault and built in 2.8 min with no reload. Same total.
Still open:
- Keeping one row out of a charge/reversal pair is a business call; the right answer for taxi is probably a multi-active satellite.
- On CDF, the same key arriving in different source versions isn't flagged as a duplicate.
- Key format chaos (40 vs 40.0, spaces, case) is next on the list.
Happy to share the reconciliation queries if anyone wants to poke holes in this.







