[KongchangAI]
· 2 min read· 1,363 words

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

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

New research proposes a schema-documentation-free Text-to-SQL framework that learns database structure from query logs.

The article discusses enterprise Text-to-SQL challenges: existing methods rely on complete schema documentation, but enterprise databases lack it, causing similarity retrieval to fail. A new study proposes the first schema-documentation-free framework that learns implicit structure from query logs, builds a knowledge graph, and uses entity-driven GraphRAG. It achieves 95.7% execution validity on Beaver vs. 60.8% for embedding retrieval, and data engineers prefer it 70% to 10%.

Title

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

Meta Description

New research proposes the first schema-documentation-free Text-to-SQL framework, building a knowledge graph from historical query logs and introducing entity-driven GraphRAG retrieval. It achieves 95.7% execution validity on the Beaver benchmark, far surpassing 60.8% for embedding-based retrieval, offering a new path for natural language interfaces to schema-ambiguous enterprise databases.

Article Content

The real-world struggle of enterprise Text-to-SQL often lies not in the model being insufficiently powerful, but in an assumption masked by academic benchmarks: that the database must have complete schema documentation. In reality, enterprise databases generally lack documentation, table names are obscure, and relationships are implicit, causing systems that perform excellently on academic benchmarks to lose significant accuracy once deployed in production. A new study proposes the first Text-to-SQL framework that requires no schema documentation, instead learning database structure from historical query logs, offering new ideas for making natural language database interfaces viable in real-world environments.

Schema-Free Text-to-SQL research overview

The Gap Between Academic Benchmarks and Production Environments

Existing Text-to-SQL methods achieve considerable accuracy on academic datasets, but the paper points out that this success is built on the premise of complete schema documentation. The reality of enterprise databases is the opposite: naming often uses internal abbreviations or legacy vocabulary, associations between tables have no explicit foreign key constraints, and business semantics are scattered in engineers' experience rather than in documentation. When systems can only rely on embedding similarity to match user questions with table structures, obscure naming can cause the retrieval phase to deviate from the correct target, and no matter how strong the subsequent generation is, it cannot recover.

This observation explains why similarity-based retrieval—the current mainstream industrial practice—performs unstably in enterprise scenarios. The root cause is not in the generation model, but in the fact that the source of structural information on which retrieval depends is itself incomplete.

Query Logs: An Overlooked Carrier of Structural Knowledge

The core insight of the paper is that historical query logs themselves encode rich implicit structural knowledge. Which tables are frequently queried together, through what conditions they are joined, and which columns correspond to the same business concept—this information appears repeatedly in SQL statements but has never been systematically extracted and utilized.

The research team builds a knowledge graph by parsing query patterns, transforming tables, columns, and join relationships into a retrievable graph structure. Unlike approaches that rely on embedding similarity, they introduce entity-driven GraphRAG retrieval, anchoring user questions on domain terminology rather than relying solely on semantic vector proximity. This means that even if the user's wording differs greatly from table names, as long as the business concept can be mapped to a corresponding entity in the knowledge graph, retrieval can still hit the correct table.

This approach shifts "understanding database structure" from static documentation to dynamic usage records—essentially using behavioral data to compensate for missing documentation.

Knowledge Graphs and GraphRAG

A knowledge graph is a way of organizing knowledge in a graph structure, where nodes typically represent entities (such as tables, columns, business concepts) and edges represent relationships between entities (such as foreign key joins, co-occurrence associations). In this study, after parsing historical SQL query logs, frequently co-occurring tables, column correspondences in join conditions, etc., are extracted as triples to form a graph-based representation of database structure.

GraphRAG (Graph Retrieval-Augmented Generation) is a variant of retrieval-augmented generation, in which the retrieval phase is not limited to vector similarity; instead, entity recognition and multi-hop traversal are first performed on the graph, and the matched subgraph is then injected as context into the generation model. Compared with pure embedding retrieval, GraphRAG's advantage lies in its ability to use explicit structural relationships as constraints, avoiding semantic vector drift on obscure naming.

Entity-Driven Retrieval

Entity-driven retrieval means the system first identifies domain terms in the user's natural language question as entity nodes in the knowledge graph, then uses these nodes as anchors to expand candidate tables and columns along graph edges. This contrasts with embedding similarity retrieval: the latter encodes the entire question as a vector and compares distances with vectors of table/column names; when naming is obscure, proximity relations in vector space are unreliable. The entity-driven approach refines the matching granularity from "whole sentence to whole name" to "term to entity." Even if a table name is an internal abbreviation, as long as that abbreviation has co-occurred with a certain business term in query logs, a mapping can be established.

Quantitative Results: Executability and Expert Preference

The paper validates the method in two scenarios: an industrial deployment with expert evaluation, and the Beaver benchmark. On Beaver, the method achieves 95.7% execution validity, compared with 60.8% for embedding-based retrieval—a significant gap. Beyond execution validity, answer quality also comprehensively outperforms similarity retrieval, the mainstream industrial approach.

Expert evaluation in the internal deployment provides evidence from another dimension: data engineers preferred the proposed system by a ratio of 70% to 10%. For engineers long troubled by obscure table names, an interface that understands business terminology rather than mechanically matching table names offers value not only in accuracy numbers but also in reducing the communication cost of repeatedly correcting queries.

It should be noted that the evaluation details of the industrial deployment are not fully elaborated in the abstract, and the specific evaluation dimensions of expert preference await clarification in the full paper. However, the consistent direction across the two scenarios strengthens the credibility of the conclusions.

Execution Validity and the Beaver Benchmark

Execution validity refers to the proportion of generated SQL that can execute without syntax errors on the target database and return non-empty results. It measures whether a query "can run," which is a different level from whether the results fully match user intent (execution accuracy). In scenarios where schema documentation is missing, execution validity is especially indicative of whether the retrieval phase found the right tables—choosing the wrong table often directly leads to execution failure due to non-existent columns or invalid join conditions.

Beaver is a benchmark dataset for enterprise-level Text-to-SQL. Its characteristics are that it is collected from real enterprise databases, schema documentation is incomplete, and there is a large semantic gap between table names and business terminology, making it closer to production environments than academic benchmarks such as Spider.

Implications for Enterprise Data Infrastructure

This work points to a broader judgment: the query logs accumulated by enterprises are an undervalued asset. Most teams treat them as operational audit data, but they actually record the real paths of interaction between business and data. When schema documentation is unavailable, reconstructing structural understanding from usage traces may be more realistic than filling in documentation.

For teams advancing natural language database interfaces, the practical significance of this research lies in re-examining the design of the retrieval layer. Investing resources in parsing query logs and building knowledge graphs, rather than merely optimizing embedding models, may bring more substantial improvements in schema-ambiguous environments. The viability of Text-to-SQL "in the wild" ultimately depends on whether systems can learn from an enterprise's own operational data, rather than waiting for a perfect document that may never appear.

One-line Summary

New research proposes a schema-documentation-free Text-to-SQL framework that learns database structure from query logs.

Paragraph Summary

The article discusses the real-world challenges of enterprise Text-to-SQL: existing methods' success on academic benchmarks depends on complete schema documentation, while enterprise databases generally lack documentation, have obscure table names, and implicit relationships, causing similarity retrieval to deviate from the correct target at the retrieval stage. A new study proposes the first schema-documentation-free framework, with the core insight that historical query logs encode implicit structural knowledge such as inter-table associations and business concept mappings. The research team parses query patterns to build a knowledge graph and introduces entity-driven GraphRAG retrieval, anchoring user questions with domain terminology rather than relying on semantic vector proximity. On the Beaver benchmark, execution validity reaches 95.7%, compared with 60.8% for embedding retrieval; in internal deployment, data engineers prefer the system by a ratio of 70% to 10%. The article accordingly suggests that enterprises view query logs as structural knowledge assets, and that retrieval layer design is more critical than generation model optimization.

#Text-to-SQL#schema-free#query logs#knowledge graph#GraphRAG#enterprise databases#natural language interface
Share:

Related articles