mlsanityData to 14 Oct 2026

SQL Query Engine: A Self-Healing LLM Pipeline for Natural Language to PostgreSQL Translation

arXiv 2604.16511 ↗First posted 15 Apr 2026cs.DB cs.CLcited by 0

Not on the map. Why?

Abstract (arXiv)

We present SQL Query Engine, an open-source, self-hosted service that translates natural language questions into validated PostgreSQL queries through a two-stage LLM pipeline. The first stage performs automatic schema introspection and SQL generation; a multi-strategy response parser extracts SQL from any LLM output format (JSON, code blocks, or raw text) without requiring structured output APIs. The second stage executes the query against PostgreSQL and, upon failure or empty results, enters an iterative self-healing loop in which the LLM diagnoses the error using full SQLSTATE codes and PostgreSQL diagnostic messages. Two mechanisms prevent regressions: early-accept returns successful queries immediately without LLM re-evaluation, and best-result tracking preserves the best partial result across retries. Schema context is cached per session in Redis, progress events stream via Redis Pub/Sub and SSE, and an OpenAI-compatible /v1/chat/completions endpoint lets existing tools work without modification. All database connections are read-only at the driver level. We evaluate across five LLM backends on a synthetic benchmark (75 questions, three databases) where the self-healing loop yields up to +9.3pp accuracy gains with zero regressions on the best model (Llama 4 Scout 17B, 57.3%), and on BIRD (437 questions, 11 databases migrated from SQLite to PostgreSQL) where the full pipeline reaches 49.0% execution accuracy (GPT-OSS-120B, +4.6pp). Source code: https://github.com/codeadeel/sqlqueryengine.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 21 of its 30 references that are in the map. First posted on arXiv 15 Apr 2026.

Builds on

21 of 30 references.

References · 21

  1. 2020Language Models are Few-Shot Learnerscited by 32,419
  2. 2023GPT-4 Technical Reportcited by 18,396
  3. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  4. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
  5. 2018Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Taskcited by 1,139
  6. 2023Teaching Large Language Models to Self-Debugcited by 988
  7. 2023Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLscited by 688
  8. 2017Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learningcited by 687
  9. 2023DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correctioncited by 477
  10. 2019RAT-SQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parserscited by 424
  11. 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 411
  12. 2023Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluationcited by 385
9 more
  1. 2024CodeS: Towards Building Open-source Language Models for Text-to-SQLcited by 187
  2. 2023C3: Zero-shot Text-to-SQL with ChatGPTcited by 164
  3. 2023MAC-SQL: A Multi-Agent Collaborative Framework for Text-to-SQLcited by 164
  4. 2024CHASE-SQL: Multi-Path Reasoning and Preference Optimized Candidate Selection in Text-to-SQLcited by 138
  5. 2024Next-Generation Database Interfaces: A Survey of LLM-based Text-to-SQLcited by 120
  6. 2024A Survey on Employing Large Language Models for Text-to-SQL Taskscited by 67
  7. 2024DTS-SQL: Decomposed Text-to-SQL with Small Large Language Modelscited by 45
  8. 2025ReFoRCE: A Text-to-SQL Agent with Self-Refinement, Consensus Enforcement, and Column Explorationcited by 37
  9. 2024MAGIC: Generating Self-Correction Guideline for In-Context Text-to-SQLcited by 35

Built on by

Not cited yet.