Urgent.News

What's breaking now, across thousands of outlets.

Tech

One SQL predicate, eleven implementations: unifying them and what our differential harness caught

This is a story about paying down the most expensive kind of technical debt in a query engine — duplicated semantics — and the testing harness that made it safe. It comes from building MoteDB , an embedded multimodal database in Rust for robotics workloads, but the pattern applies to any engine that grew fast. The bug that kept coming back Through four rounds of pre-release bug hunting on v0.17,…

This story explains how paying down technical debt in a query engine, specifically duplicated semantics, was achieved through building a testing harness. The focus is on MoteDB, a Rust-based embedded multimodal database for robotics workloads, but the pattern applies to any fast-growing engine.

Throughout the development of MoteDB, the same SQL predicate, evaluated by different code paths, returned different answers. This inconsistency stemmed from SQL comparison semantics living in 11 separate implementations. These included the interpreter's eval_binary_op, the fast per-row evaluators, the compiled WHERE path with hand-rolled arms per operator, vectorized scan leaves, JOIN predicate pushdown, aggregate pre-filter, and two inline closures.

To address this issue, the team took the following steps:

1. Lock the present before changing it: Characteristic tests were written to lock the current behavior of each path before making any changes. This allowed the team to enumerate every behavior and explicitly decide which changes to implement.

2. One semantics layer: An effort was made to have everything route through a single module, reducing the number of implementations from 11 to one. This module defined a single comparison function, Cmp3, and a coercion pair built on Cow to avoid unnecessary allocations. The choice between equality and ordering operations was made once, ensuring consistent behavior for incomparable types.

3. The differential harness: A differential harness was created to generate random predicates with mixed types, NULLs, boundary values, bracketed vector literals, ISO timestamps, and run them through nine execution paths. Any disagreement between paths would fail the run, printing the seed, predicate, and all nine answers. This allowed the team to catch seven pre-existing divergences present in the released version 0.17.

One notable divergence involved hash-set normalization for IN lists, where pure-numeric text was incorrectly parsed as a microsecond timestamp. The differential harness revealed that the equality route did not parse 7 as a timestamp, while the hash route did, contradicting the same predicate across paths. The verdict was to stop parsing pure-numeric text as timestamps in the equality route, and the characteristic tests were amended accordingly.

In conclusion, the story demonstrates how a testing harness can identify and unify duplicated semantics in a query engine, leading to more consistent behavior across implementations, and improving overall code quality.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why Linear Agent Chains Break in Production Banking (And How We Built Deterministic State Graphs with LangGraph + Redis)

Author: Chaman Shah, Principal AI Systems Architect at Elesium The "Prompt and Pray" Crisis in Enterprise AI If you spend any time browsing GitHub or Twitter, you have seen dozens of AI agent…

  • Linear agent chains prone to infinite loops in production banking
  • State loss during external gateway timeouts causes restarts or duplicates
  • Prompt injection attacks bypass system, gain unauthorized access

JobRequester: I built this free Chrome extension that tracks job applications and am looking for feedback

Hi all, I'm the person who built this, and I'd really like honest feedback from people who are job hunting right now. I've been job searching myself, and two parts of it were pure busywork: copying…

  • JobRequester is a Chrome extension that automates job application processes.
  • It captures job details from platforms like LinkedIn and Indeed.
  • User feedback is requested via the Chrome Web Store.

WARN Act and Age Discrimination — Are Older Workers Protected When Layoffs Hit?

A WARN notice tells you a layoff is coming, not why you were chosen. That gap matters: the WARN Act and the laws against age discrimination do different jobs, and a layoff can satisfy one while…

  • WARN Act requires 60-day notice for plant closures or mass layoffs.
  • Age Discrimination in Employment Act protects workers aged 40+, with 20+ employees.
  • Older workers can file claims under WARN Act, ADEA, or both for layoff discrimination.

More from Sunday 8 November →