AmbiSQL: Interactive Ambiguity Detection and Resolution for Text-to-SQL

Zhongjun Ding, Yin Lin, Tianjing Zeng, Rong Zhu, Bolin Ding, Jingren Zhou

TL;DR

AmbiSQL is an interactive system designed to automatically detect and resolve natural language ambiguities in Text-to-SQL systems. By introducing a fine-grained taxonomy that covers both database schema mismatches and LLM reasoning flaws, it guides users through intuitive multiple-choice questions to refine their queries, significantly improving the accuracy of downstream SQL generation.

What Problem Does This Paper Address?

Text-to-SQL systems use Large Language Models (LLMs) to translate natural language questions into executable SQL queries, making databases accessible to non-experts. However, human language is inherently ambiguous. For instance, a phrase like "ranked 2" could map to either a rank or a position column in a database, while a phrase like "the end of the Vietnam War" can imply different exact dates depending on the context.

When faced with such ambiguities, standard Text-to-SQL systems often generate syntactically valid but semantically incorrect queries. Existing solutions typically focus only on database schema-linking or data-related ambiguities. They largely ignore ambiguities that disrupt the LLM's internal reasoning process, such as vague temporal or spatial constraints, leading to poor real-world deployment.

Methods

The authors introduce AmbiSQL, which addresses these challenges using a two-stage pipeline integrated with a commercial Text-to-SQL backend called XiYan-SQL:

  1. Ambiguity Identification: Utilizing an LLM with in-context learning, the system scans the user's natural language query alongside the database schema to detect ambiguous phrases. It classifies them based on a novel, fine-grained taxonomy divided into two dimensions:
  2. Database-sourced ambiguity: Includes AmbiSchema (unclear table/column mapping), AmbiValue (mismatched literal values), and AmbiIntent (unclear SQL operations like grouping vs. filtering).
  3. LLM-sourced ambiguity: Includes AmbiSource (external knowledge vs. database content), AmbiContext (missing context like target currencies), AmbiFallacy (false assumptions), and AmbiRef (vague spatial/temporal references).

Following identification, the system generates targeted Clarification Questions (CQs) with multiple-choice options.

  1. Iterative Refinement: The system captures user selections, updates a tree-like preference structure, and rewrites the query. It then loops back to the ambiguity detection module to ensure no new ambiguities were introduced before passing the finalized, unambiguous query to the SQL parser.
Figure 1: An Overview of Ambiguity Detection and Resolution in AmbiSQL.

Datasets

To demonstrate the system, the authors curated a playground dataset consisting of 40 ambiguous queries extracted from two prominent real-world benchmarks:

  • BIRD: A large-scale database grounded Text-to-SQL benchmark.
  • TAG: A benchmark focusing on queries requiring both text attributes and database operations.

Each query in this playground dataset is paired with human-annotated ambiguity categories and actual user intents. AmbiSQL also supports user-customized datasets and databases.

Key Insights and Ideas

  • LLM Reasoning Ambiguities Matter: Traditional disambiguation tools focus almost exclusively on schema matching. AmbiSQL highlights that resolving vague historical or contextual references (LLM-sourced ambiguities) is just as critical for generating correct SQL.
  • Taxonomy Curbs Computational Overhead: Without a structured taxonomy, automated systems often generate an overwhelming number of candidate interpretations. AmbiSQL’s fine-grained categorization keeps clarification questions concise and highly targeted.
  • User-Friendly Disambiguation: Instead of forcing non-expert users to understand complex database schemas or SQL code, AmbiSQL abstracts the problem into simple multiple-choice questions, complete with "Abstain" and "Others" options for flexibility.

Key Results

As a system demonstration paper, the primary result is the qualitative validation of the interactive interface. The authors showcase a running example: "How many drivers born after the end of the Vietnam War have been ranked 2?"

Without AmbiSQL, the base Text-to-SQL system guesses blindly, applying an incorrect date filter (1975-04-30) and mapping "ranked 2" to the wrong table. With AmbiSQL, the system surfaces the ambiguities to the user, correctly refines the date to 1973-03-29 based on user feedback, maps the rank to driverStandings.position, and successfully generates the intended SQL query.

Figure 3: Detailed User Interface of AmbiSQL.

Limitations and Future Work

Because this is a demonstration paper, it lacks extensive, large-scale quantitative evaluation metrics (such as exact-match accuracy improvements across entire standard datasets). Furthermore, the ambiguity detection module relies heavily on prompt-based in-context learning. For massive enterprise databases with thousands of columns, this approach might face scalability limits or require specialized fine-tuning to maintain precision.

Summary updated

BibTeX
@inproceedings{ding2026ambisql,
  author = {Zhongjun Ding and Yin Lin and Tianjing Zeng and Rong Zhu and Bolin Ding and Jingren Zhou},
  title = {{AmbiSQL: Interactive Ambiguity Detection and Resolution for Text-to-SQL}},
  booktitle = {SIGMOD Companion},
  year = {2026},
  doi = {10.1145/3788853.3801581},
}
Figure