NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

AV-SQL: Decomposing Complex Text-to-SQL Queries with Agentic Views

Minh Tam Pham, Trinh Pham, Tong Chen, Hongzhi Yin, Quoc Viet Hung Nguyen, Thanh Tam NguyenarXiv 2026

TL;DR

AV-SQL is a novel multi-agent framework that tackles the challenge of generating complex SQL queries over massive, real-world database schemas. By breaking large schemas into manageable chunks and generating verifiable intermediate "agentic views" (Common Table Expressions), it prevents error propagation and achieves a state-of-the-art 70.38% execution accuracy on the rigorous Spider 2.0 benchmark in a fully zero-shot setting.

What Problem Does This Paper Address?

While Large Language Models (LLMs) have gotten incredibly good at translating natural language into SQL (Text-to-SQL), they hit a wall when confronted with enterprise-scale databases. Real-world schemas often contain hundreds of tables and thousands of columns, easily exceeding an LLM's context window or diluting its attention.

When traditional systems attempt to generate a single, monolithic SQL query from a massive schema, they frequently suffer from two major issues:

  1. Schema-linking mistakes: Hallucinating column names or joining tables on incorrect keys.
  2. Entangled errors: A single query might contain a mix of syntax errors, incorrect joins, and bad filters. Because database execution feedback only reports the first error it encounters, debugging these monolithic queries holistically becomes nearly impossible.
Traditional monolithic SQL generation vs. AV-SQL's decomposed approach

Methods

AV-SQL introduces a multi-stage pipeline powered by specialized LLM agents that decompose the problem into smaller, verifiable steps.

  1. Preprocessing & Schema Compression: To fit large databases into LLM prompts, AV-SQL clusters near-duplicate tables and columns (e.g., grouping sales_2023 and sales_2024 into a single pattern). It then splits the compressed schema into length-based chunks.
  2. Question Rewriting: A rewriter agent reformulates the user's query and filters out noisy external knowledge, producing a highly explicit, structured prompt.
  3. Agent View Generation (The Core): Instead of writing the final query, view-generator agents examine individual schema chunks and produce agentic views—executable Common Table Expressions (CTEs) that handle localized logic (like filtering a specific table). Crucially, these intermediate CTEs are executed against the database immediately. If they fail, an iterative validation-and-repair loop fixes them before moving forward.
  4. SQL Generation: Finally, three collaborative agents—a Planner (creates a high-level query plan), a SQL Generator (composes the final query using the validated CTEs), and a Revisor (verifies semantic correctness)—assemble the final executable SQL.
Figure 2: Overview of AV-SQL. The framework begins with preprocessing—schema splitting and vector database initialization for value preprocessing—followed by three main stages: (1) Question Rewriting which reformulates the input question, optionally using external knowledge, into a clearer and more explicit form; (2) Agent View Generation, which decomposes the long-context schema into smaller chunks and produces execution-validated intermediate CTE-based agent views that capture key reasoning steps while identifying relevant schema elements; and (3) SQL Generation, which uses three agents: a planner, a SQL generator, and a revision agent to produce the final executable SQL query from the filtered schema and validated agent views.

Datasets

The authors evaluated AV-SQL across several prominent Text-to-SQL benchmarks:

  • Spider 2.0 (Spider2-Snow): A highly challenging, enterprise-scale benchmark featuring massive schemas (averaging 800 columns per database) and complex multi-step questions targeting Snowflake dialects.
  • BIRD: A large-scale professional domain benchmark.
  • Spider (1.0): The standard cross-domain benchmark for multi-table SQL generation.
  • KaggleDBQA: A benchmark consisting of real-world web databases with unrestricted user questions.

Key Insights and Ideas

  • Decomposition Beats Global Pruning: Traditional methods try to prune the schema globally before generating SQL, which often accidentally discards required join paths. AV-SQL shifts the paradigm by treating chunk-level reasoning as explicit schema filtering via executable code.
  • The Power of Verifiable Intermediate Steps: By forcing agents to write independent, executable CTEs for small parts of the schema, errors are isolated. If an agent links a wrong column, the error is caught and repaired at the CTE level, preventing it from corrupting the final query structure.
  • Zero-Shot Viability: Unlike many top-performing systems that require complex few-shot exemplar selection or expensive task-specific fine-tuning, AV-SQL achieves state-of-the-art results purely through prompt-based agent coordination.

Key Results

AV-SQL demonstrated massive performance leaps, particularly on large-scale databases:

  • Spider 2.0-Snow: Powered by Gemini-3-Pro, AV-SQL achieved 70.38% execution accuracy, dramatically outperforming recent state-of-the-art agentic baselines like ReForCE (35.83%) and AutoLink (34.92%). Standard monolithic approaches like DIN-SQL scored 0.00% because the schemas simply could not fit or function within a single prompt.
  • Standard Benchmarks: AV-SQL remained highly competitive on normal-scale datasets, scoring 85.59% on Spider, 72.16% on BIRD, and 63.78% on KaggleDBQA, beating out several multi-candidate and fine-tuned baselines.

Limitations and Future Work

An analysis of AV-SQL's failures revealed that filtering (36.2%) and aggregation (34.1%) errors constitute over 70% of its mistakes. While the framework successfully eliminated most syntax and schema-linking bugs through execution feedback, the agents still occasionally struggle with complex conditional logic and mathematical groupings over large datasets.

The authors note that future work will focus on sharpening the agents' reasoning capabilities for these complex filters and exploring hybrid LLM configurations to optimize computational costs.

Summary updated

BibTeX
@misc{pham2026av,
  author = {Minh Tam Pham and Trinh Pham and Tong Chen and Hongzhi Yin and Quoc Viet Hung Nguyen and Thanh Tam Nguyen},
  title = {{AV-SQL: Decomposing Complex Text-to-SQL Queries with Agentic Views}},
  year = {2026},
  eprint = {2604.07041},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.07041},
}
Figure