Analysis

Quail: When a Data Pipeline Becomes a SQL Query

Quail runs language models inside SQL queries. A test on 100,000 movie reviews shows how the open source engine can automate work that once took a custom pipeline.

What used to take a separate pipeline

A burgundy ink-washed quail standing atop a stack of ruled ledger sheets beside a brass fountain pen, on cream paper.
Illustration Quail lets you filter rows by asking a question about the text.

I used to spend days building pipelines to answer questions about large datasets. The question could fit in a sentence. Getting the data into shape, writing the code to answer it, and making the whole thing run again when the question changed took considerably longer. That’s why I stopped at Shreya Shankar’s announcement on X. Her team had put a piece of that work directly into a SQL query.

Quail is an open source engine from Carnegie Mellon’s Full Stack Data Lab and collaborators at Modal. In ordinary SQL, you can filter reviews by a star rating or search for a word in the text. Quail lets you filter by asking a language model a question about each review. The function is called AI.IF: a yes from the model keeps the row; a no drops it.

What happens to 100,000 reviews

In the team’s IMDb demo, they wanted reviews that did two things: discuss the movie’s ending and recommend watching the movie. Those are separate tests. A reviewer can recommend a movie without discussing its ending. Another can describe the last scene in detail and tell you to skip the movie. Neither belongs in the result.

Quail asked the model about the ending for all 100,000 reviews. About 28,000 passed that first test, so Quail only asked the model about recommendations for those reviews. The query returned about 16,000 review IDs, which you could use to pull up the original text and see what the model had selected. Those are the model’s picks, not 16,000 independently verified matches.

Where the time goes

Quail uses Apache DataFusion for ordinary SQL and plans the model’s work alongside it. Skipping the second question for most rows is one saving. For reviews that make it through, Quail can also keep the model’s work on the review in GPU memory. The question changes, but the review doesn’t, so the model can reuse that work instead of starting over. The team reported about five and a half minutes on one NVIDIA H100, including model startup but not downloading the data. At the rate they used, that was about 37 cents in GPU time.

That timing doesn’t mean a five-minute query replaces days of work. What would save me effort is being able to write the two tests in the query instead of building and wiring up a separate classification job. If I decide a lukewarm recommendation shouldn’t count, I can change that condition and rerun it. I’d still check a sample of what the model kept and what it dropped. The work I get back is the plumbing between asking the question and having something I can check.

But is it open?

Yes, the engine is. Its MIT license lets you use, modify, and redistribute it with the notices intact. You need a supported CUDA GPU, and the model you choose has its own license. But you can run the engine on data you control, inspect the code that runs the query, and hand someone the query itself so they can see exactly what you asked.