How production Text-to-SQL systems catch semantically wrong queries that run just fine
Fun-Following-1723 · reddit · 2026-10-15
A developer building a Text-to-SQL agent supporting PostgreSQL, MySQL, and SQL Server outlines a pipeline of schema inspection → read-only SELECT generation → validation → execution with a single LLM retry on errors → summarization. The hard problem: semantic errors, like generating COUNT(invoicelineid) instead of SUM(quantity) for "which tracks were purchased in greatest total quantities" — valid SQL that runs fine, invisible to retry-on-error logic. Candidate mitigations discussed:
- Retry with DB error and schema context
- A second LLM pass reviewing SQL against the original question
- Deterministic checks for common aggregation mistakes
- Generating multiple candidates and selecting the best
- Validating returned rows against the question
- Richer schema context (column descriptions, business definitions, example queries)
They ask how production teams evaluate these approaches and balance accuracy against latency and cost.
More from coding & agent
- TorchLean expands into a verified tensor programming framework with einsum and GPU execution in Lean — burny_tech · 2026-10-15
- One-page cheat sheet maps Kiro, Claude Code, Codex and Cursor feature names — DigitalColmer · 2026-10-15
- One-man software factory: 5-10 parallel agents build POCs, 60% get killed — Stefania_druga · 2026-10-15
- Huawei's SwarmRSI: evolving agent swarms achieve recursive self-improvement in science — Qianru Meng · 2026-10-15
- Prompt With Love: Steering Massive Agent Swarms With Values, Culture and Story — liminal_bardo · 2026-10-15
- Vibe First, Validate Fast: One Chart Nails How AI Development Differs From Agile — burny_tech · 2026-10-15