A Semantic-Layer-Mediated Agent for Natural Language to SQL over Heterogeneous Enterprise Databases

📅 2026-06-29
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the challenges of natural language to SQL (NL2SQL) translation in real-world enterprise databases, where complex table schemas, opaque column names, dialect heterogeneity, and deeply nested queries hinder performance. To tackle these issues, the authors propose a semantic-layer mediation mechanism that introduces Semantic Model Queries (SMQ) as an intermediate representation, decoupling user intent from physical SQL generation. They further design a constrained think-execute loop and a deterministic compiler to prevent overfitting to the raw database schema. Built upon the Gemini 3 Pro large language model and supporting SQLite, BigQuery, and Snowflake backends, the system achieves a 94.15% execution accuracy on the 547 tasks of Spider2-snow, ranking third on the official leaderboard and significantly outperforming approaches that rely solely on the original schema, thereby substantially enhancing cross-dialect NL2SQL generalization.
📝 Abstract
Natural language-to-SQL (NL2SQL) over real-world enterprise databases remains significantly more challenging than on academic benchmarks. Enterprise schemas often contain hundreds of physical tables with cryptic column names, heterogeneous SQL dialects, and complex analytical workloads requiring nested aggregations, temporal reasoning, and multi-table joins. We present a semantic-layer-mediated NL2SQL agent that decouples semantic intent from physical SQL execution. Rather than generating SQL directly over raw schemas, the agent reasons over a curated semantic layer through a compact intermediate representation called the Semantic Model Query (SMQ). A deterministic compiler translates each SMQ into dialect-specific SQL, providing verified building blocks that the agent composes into the final query. The system employs a constrained think-act loop, supports SQLite, BigQuery, and Snowflake backends, and is integrated into an end-to-end evaluation framework. Using Gemini 3 Pro, the system achieves 94.15% execution accuracy on the 547-task Spider2-snow benchmark, ranking third on the official leaderboard and substantially outperforming schema-only approaches. We describe the system architecture, SMQ representation, agent workflow, evaluation results, and discuss semantic-layer quality and the trade-off between improved grounding and overfitting.
Problem

Research questions and friction points this paper is trying to address.

Natural Language to SQL
Enterprise Databases
Heterogeneous SQL Dialects
Complex Analytical Queries
Semantic Layer
Innovation

Methods, ideas, or system contributions that make the work stand out.

semantic layer
Natural Language to SQL
intermediate representation
dialect-specific compilation
constrained reasoning