Text-to-SQL and Ambiguous Questions: Does Your AI Database Assistant Understand You?

    Ambiguous questions expose a gap between generating valid SQL and understanding business intent. This article examines why AI database assistants struggle with incomplete context, unclear metrics, and business terminology, and outlines four priorities for more reliable systems: clarification, a semantic layer, conversation state management, and realistic evaluation.

    1. An Unusual Experiment: Deliberately Challenging AI

    Most demonstrations of AI database assistants—natural-language analytics or Text-to-SQL applications—follow a familiar pattern. A user asks, “What were last month’s sales in the eastern region?” The system immediately returns a clear table and a precise SQL query. From these demonstrations, it can seem that large language models have largely solved Text-to-SQL.

    But a group of researchers tested a less forgiving scenario. They deliberately constructed questions with vague wording, incomplete context, or multiple plausible interpretations. The reported results showed that even leading large language models achieved only around 50% end-to-end execution accuracy on these questions. In roughly half the cases, the system produced an incorrect answer or failed to capture the user’s intended meaning.

    That finding deserves attention from teams building or planning AI-powered analytics systems. Why can models perform so well on standard benchmarks yet struggle in real business settings? A central reason is ambiguity.

    2. What Makes a Question Ambiguous?

    In Text-to-SQL, ambiguity does not necessarily mean grammatical errors. It means that a question allows multiple reasonable interpretations of the target tables, filters, or aggregation rules.

    Common examples include:

    1. Omitted context or unclear references: “What about sales?” In a multistep conversation, the system must determine which time period and region the user is referring to.
    2. Ambiguous metric definitions: “Which product sold best?” Does “best” mean the highest number of orders or the most units sold? Should canceled orders be excluded?
    3. Unspecified fields or dimensions: “Who performed worst?” The database may contain several measures of performance across sales, customer support, and fulfillment.
    4. Business-specific terminology: “How are the promotional products selling?” Answering requires knowledge of the relevant campaign, not just the database schema.

    Standard evaluation benchmarks often use questions that have been manually rewritten to be complete and unambiguous. This makes the task easier for the model. Real users, however, rarely spell out every assumption. They expect the system to know the context they have in mind.

    3. Why Large Language Models Struggle

    From an engineering perspective, failures can occur at several points in the end-to-end workflow.

    Semantic interpretation: A model selects a likely interpretation based on patterns it has learned. But the correct business definition may not be represented in its general training data. If your organization uses “GMV” in a particular way, the model cannot know whether that definition includes refunds unless it is given that information.

    Schema interpretation: Table and column names vary widely in quality. A field named status2, with no description, gives a model little basis for determining its meaning.

    Query execution: SQL can be syntactically valid and still answer the wrong question. These errors often look credible: a different sales definition might produce a result twice as large, yet the number could still appear perfectly normal. Users may have no immediate way to notice the mistake.

    This is what makes an end-to-end accuracy figure of around 50% concerning. Failure does not always appear as an error message. It can appear as a plausible but incorrect answer.

    4. Four Priorities for More Reliable Systems

    4.1 Manage Ambiguity Explicitly

    A reliable system should ask for clarification when it detects ambiguity rather than silently choosing an interpretation. One approach is to add an intent-confirmation step before SQL generation:

    1. User: What sold best last month?
    2. System: There are several possible interpretations. Please clarify:
    3. 1) Rank by order value, excluding canceled orders
    4. 2) Rank by units sold
    5. 3) Should the time period use order creation time or payment time?

    To decide when clarification is needed, the model can return an interpretation confidence score or a list of candidate interpretations in structured output. Rule-based thresholds can then trigger the clarification workflow.

    The purpose is not to make every query longer. It is to avoid treating an unresolved business question as if it already had a single answer.

    4.2 Build a Business Semantic Layer

    A semantic layer sits between the raw database and the LLM. It describes metric definitions, dimension conventions, synonym mappings, and commonly used filters.

    When a user asks about “promotional products,” this layer translates the phrase into an explicit set of filtering conditions. Work that would otherwise depend on model guesswork becomes a matter of defined configuration and retrieval.

    In practice, the quality of the semantic layer can have a greater impact on end-to-end accuracy than switching to a stronger underlying model.

    4.3 Manage Multiturn Conversation State

    Omitted information and references to previous questions are natural features of conversation. A system needs to maintain query context at the session level, including:

    • Time ranges
    • Filters and dimensions
    • Entities under discussion

    This allows a follow-up such as “What about profit?” to inherit the appropriate context from the preceding query.

    Supporting this behavior requires deliberate engineering around context trimming, slot inheritance, and overrides. Conversation state management deserves its own design rather than being left entirely to the model.

    4.4 Evaluate Against Real User Questions

    Build an evaluation set from users’ original questions, including typos, omitted context, and business jargon. Ensure that it covers ambiguous cases, and make the correctness of execution results a core metric.

    Regular regression testing helps expose weaknesses in both the semantic layer and the prompting approach. A system that scores well only on clean, fully specified questions has not yet demonstrated that it can handle everyday business use.

    5. Conclusion

    The reported experiment’s approximately 51% end-to-end accuracy does not simply mean that large language models are incapable. It highlights a shift in the central challenge of Text-to-SQL: from writing SQL to understanding people.

    Clean, explicit questions are easier to answer. What distinguishes a reliable system is how systematically it handles ambiguity through clarification, business semantics, conversation context, and realistic evaluation.

    For teams preparing to deploy AI database assistants in production, these foundations matter more than pursuing high scores on clean benchmarks alone. A trustworthy assistant should not pretend to understand every request. When something is unclear, it should ask.