arXiv:2610.33946cs.CLOct 2026

Manuscript Offprint

arXiv:2610.33946

Schema-Free Text-to-SQL: Learning Enterprise Database Structure from Query Logs

Ömer Faruk Akgül, Nikhil Kapahi, Prajit Reddy Muppidi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Text-to-SQL systems achieve remarkable accuracy on academic benchmarks, yet performance drops dramatically in enterprise deployments. This gap stems from a fundamental assumption: existing approaches require complete schema documentation, but enterprise databases typically lack comprehensive documentation, featuring cryptic naming and implicit relationships. We present the first text-to-SQL framework that operates without schema documentation, instead learning database structure from historical query logs. Query logs encode implicit structural knowledge: which tables are queried together, how they join, and what columns map to business concepts. We construct a knowledge graph from parsed query patterns and introduce entity-driven GraphRAG retrieval that grounds user questions in domain terminology rather than relying solely on embedding similarity. Validated on both an industrial deployment with expert evaluation and the Beaver benchmark, our approach substantially outperforms similarity-based retrieval methods, the dominant industry approach, in both executability and answer quality. On Beaver, we achieve 95.7% execution validity compared to 60.8% for embedding-based retrieval, with expert data engineers preferring our system 70% to 10% on internal deployment. Our work demonstrates that text-to-SQL can operate effectively in schema-ambiguous enterprise environments, enabling natural language database interfaces “in the wild.”

1 Introduction

Text-to-SQL systems have achieved remarkable performance on academic benchmarks, with state-of-the-art methods (Shkapenyuk et al., 2025; Lee et al., 2024; Gao et al., 2023) achieving high accuracy on datasets like Spider (Yu et al., 2018) and BIRD (Li et al., 2023b). Yet these same sys-

Figure

Figure 1: State-of-the-art text-to-SQL systems require complete schema documentation unavailable in enterprise settings. Operating with only historical query logs, our approach achieves 95.7% execution validity and 70% expert preference over embedding-based retrieval.

tems struggle dramatically when deployed in enterprise environments (Lei et al., 2025; Chen et al., 2026). This performance gap reflects a fundamental assumption mismatch: current text-to-SQL approaches universally require database identity known upfront, complete table schemas as input, explicit foreign key relationships, and interpretable column names. Enterprise databases offer none of these.

In practice, enterprise data ecosystems present what we term the schema ambiguity problem. Tables and columns lack meaningful descriptions, with names employing domain-specific abbreviations that obscure their meaning to anyone outside the immediate team. Foreign keys are rarely declared explicitly; join relationships exist only in the institutional knowledge of database administrators or embedded in historical query patterns. These environments span hundreds to thousands of tables (Lei et al., 2025; Chen et al., 2026), and schemas evolve continuously as business needs change, rendering any static documentation quickly outdated. These challenges are not edge cases but the norm in enterprise settings, and recent work on enterprise-oriented benchmarks has begun to quantify this gap (Lei et al., 2025; Chen et al., 2025).

∗^{*}Work done during an internship at Amazon.

Our Insight. We observe that while explicit documentation may be absent, enterprise databases contain an underutilized source of structural knowledge: historical query logs. Production SQL queries encode implicit information about database structure, revealing which tables are frequently queried together, how tables join in practice, and what columns map to specific business concepts. Query logs capture what documentation should contain, learned from usage patterns rather than manual annotation.

Based on this insight, we present a text-to-SQL framework that operates without schema documentation, instead constructing a knowledge graph directly from query log analysis. State-of-the-art text-to-SQL systems are not designed for this setting, as they assume complete, human-readable schemas are available as input. Since state-of-the-art text-to-SQL systems are not designed for this setting, practitioners often turn to retrieval-augmented generation (RAG), which uses embedding-based similarity to narrow candidate tables and columns (Zhang et al., 2023). However, embedding similarity fundamentally struggles in enterprise settings: users ask about "approved time-off requests" and "hours worked" while schemas contain identifiers like f_pto_agg and d_att_dtl. This vocabulary mismatch cannot be bridged by semantic similarity alone (Chen et al., 2026). To address this, we introduce entity-driven GraphRAG retrieval: we extract domain entities from user questions and traverse the knowledge graph to identify relevant tables, leveraging historical join patterns to ensure structural coherence.

Enterprise text-to-SQL also demands rethinking evaluation methodology. Open-ended analytical questions frequently admit multiple valid SQL formulations, rendering traditional exact-match metrics inadequate (Lei et al., 2025; Chen et al., 2026). A query asking for “sales trends” might be correctly answered by grouping on weeks or months, selecting different but equally valid column subsets, or joining through alternative paths. We address this through multi-faceted evaluation combining execution-based accuracy (Lei et al., 2025), blind pairwise comparison via LLM-as-judge validated by 83% agreement with expert data engineers, and rubric-based analysis that decomposes SQL quality into interpretable dimensions. Our generated-versus-gold analysis (§6.4) further demonstrates that on open-ended questions, system-generated SQL achieves quality scores matching or exceeding human-written gold standards.

We make the following contributions:

  1. The first text-to-SQL framework that operates without schema documentation, learning database structure from historical query logs.

  2. Entity-driven GraphRAG retrieval that bridges the vocabulary gap between business terminology and cryptic schema identifiers through domain entity matching.

  3. A multi-faceted evaluation framework addressing open-ended question ambiguity through execution-based metrics, expert-validated LLM judging, and rubric-based analysis.

  4. Validation on an industrial deployment (240 tables, 70% expert preference) and Beaver benchmark (95.7% vs. 60.8% execution validity), with ablations confirming entity matching as the key contributor.

Our work demonstrates that text-to-SQL can operate effectively in schema-ambiguous enterprise environments, providing a new paradigm for natural language database interfaces “in the wild.”

References (15)