AIToday
AI Coding AssistantsLarge Language ModelsHacker NewsPublished: Dec 2, 2026, 13:00 JST

SQLazy essay: move AI SQL generation to a deterministic compiler

Send on LINE
SQLazy essay: move AI SQL generation to a deterministic compiler

3 Key Points

  1. What happened

    A Hacker News essay says direct natural-language-to-SQL lands around 60% accurate, so every error triggers a rework cycle, and proposes SQLazy: AI plans canonical steps, a deterministic compiler generates the SQL.

  2. Why it matters

    Reviewing—not writing—is the bottleneck, so moving uncertainty into auditable planning steps lets reviewers check logic once and recompile the same script for different databases instead of re-reading generated code.

Ask AI

Ask the AI about this article. Questions and answers are published on this page

Context & Analysis

The essay builds its case around a gap between two costs: writing SQL has become cheap with AI, but reviewing it has not. Its argument is that people reverse-engineer generated queries anyway—where a column came from, why a DISTINCT appears—so the uncertainty should be moved into a planning layer where a human can inspect named steps rather than a black-box final statement.

The paper illustrates this with a stock example: a longest-rising-streak query that in nested SQL needs four levels of nesting, but as a step script reads top to bottom in five lines, aligning reading order with evaluation order. From there, the same script can be recompiled for another database—the essay walks through ClickHouse output—so logic is audited once and dialects are left to the compiler. It then extends the division of labor to stored procedures, noting that audit pain concentrates in SELECT computations and WHERE conditions rather than flow code, and suggesting SPL as an optional host when the target database lacks stored procedures.

Against conventional AI translation—repeated compare-and-regenerate loops—the essay frames the choice as comprehension debt: relocated to the target database, or repaid once by reverse-translating legacy code into a readable, compilable script. The existing code becomes an asset rather than a maintenance liability, it argues, and recompilation makes the next change deterministic rather than another round of AI rewriting.

FAQ
Why is SQL described as uniquely hard to audit?
The essay says SQL evaluates from the innermost layer outward while people read front to back, offers no visibility into intermediate state, and is often too short-lived to justify tests—so audit cost lands on people.
What does SQLazy change about how AI writes queries?
AI no longer produces final SQL; it breaks a requirement into canonical steps, and the deterministic compiler generates the SQL, ensuring the same input yields the same output with every step traceable.
What trade-offs does the essay accept for stored procedures?
It deliberately gives up portability and simulated runtime debugging inside the script, instead embedding SQLazy fragments only in SELECT and WHERE clauses while the host keeps flow, variables and write statements.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

By signing up you agree to the Terms of Service and Privacy Policy.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Related Articles

Next articleSakana AI launches free chat app on Namazu and Fugu models