NuoData

Why Text-to-SQL Fails Silently in Enterprise Data Warehouses

Why Text-to-SQL Fails Silently in Enterprise Data Warehouses

Why Text-to-SQL Fails Silently in Enterprise Data Warehouses

Data Insights

Data Insights

No blog headings found.
Check the Article and Heading selectors.

Vipul Gupta

Senior Architect

Anchal Sharma

SDE-II

A finance leader asks the analytics assistant how much the company collected from government payers last quarter. A number comes back in seconds. It looks right, and it goes into the board deck. Three weeks later, someone reconciles it by hand and finds it was off by a factor of four.

Text-to-SQL allows LLMs to translate plain-language questions into warehouse queries, but it poses a major risk: silently returning incorrect numbers that look plausible and go undetected until reconciled manually.

Human data experts translate questions by reasoning through business context first, then identifying necessary tables and joins. In contrast, an LLM relying solely on schema dumps pattern-matches names and guesses joins, producing confidently wrong numbers without warning.

To make conversational BI reliable, systems need a purpose-built semantic layer, hybrid schema retrieval, and graph-based join solving to ground queries before execution.

Why Do Text-to-SQL Queries Return Wrong Numbers Without Errors? 

Most text-to-SQL errors don't crash. The query executes, the dashboard renders, and the wrong answer looks exactly like a right one. This issue typically stems from three main shortcuts.

  1. A full schema dump overwhelms the model : Real warehouses have hundreds of tables and thousands of columns, far more than fits usefully in a prompt. Most of it is irrelevant to any one question, and the noise makes the model's guesses worse.

  1. Keyword search misses business language : Plain keyword search over table and column names fails the moment a business question uses different words than the schema does. Nobody's table is literally named how_much_we_collected.

  1. The wrong join path produces the wrong number: Finding the right tables is only half the problem. The tables that answer a question are often connected through two or three other tables the question never mentions. Getting that connecting path wrong doesn't break the query. It silently multiplies or duplicates rows and hands back a wrong answer.

The approach described here treats finding the right slice of the warehouse as its own retrieval problem, with a domain model built specifically for it. It does not rely on general-purpose document search to get close enough.


See how NuoData helps your team turn enterprise data into trusted insights. See Cosmo on your own warehouse

Book a Demo

How to Build a Semantic Layer for Accurate Text-to-SQL 

The semantic layer is built from three distinct kinds of entities, all scoped under one project-level catalog: tables and columns, metrics, and relationships. Each one does a different job in keeping LLM SQL accurate.


  1. Tables and columns: business vocabulary plus structural facts

Tables and columns carry two kinds of information side by side. One is business framing — human-readable names and synonyms, a description, a domain tag — the vocabulary a person would actually use. The other is physical and structural fact — a semantic type (a monetary amount, a category, a timestamp, independent of its raw column type), whether it's a key, whether it's sensitive, and what one row of the table represents.

Keeping these separate matters. Business framing drives retrieval: does this look like what the question is asking about? Structural facts drive correctness: can this column safely be joined on, summed, or grouped by?


  1. Metrics as grounding hints for the query

Metrics are deliberately thin — a name, a description, roughly what gets aggregated and how. A metric here is retrieval vocabulary. It is not an executable formula layer. Citing a known metric by name tells the system, "here's a business-vetted way to compute this, prefer it over inventing your own aggregate." It is a grounding hint for whatever assembles the final query.

That's a real trade-off. A fixed formula layer buys consistency but can't flex to an ad hoc question nobody anticipated. Treating metrics as strong suggestions buys flexibility, at the cost of not guaranteeing every number was computed the one true way. In conversational BI, most questions are ad hoc by definition, so the trade leans toward flexibility.


  1. Relationships: defining join direction and cardinality

Relationships are the most consequential entity of the three. In many real warehouses, foreign keys aren't consistently declared or enforced. Even where a key relationship exists, it only tells you two columns are comparable. It never tells you which side is the "one" side of a one-to-many.

Guessing that wrong doesn't error out. It can change a sum by an order of magnitude or more, because the join fans out rows it shouldn't. So relationships — including direction and cardinality — are authored, curated facts in the semantic layer. That's the reason they're modeled as a first-class entity instead of a query-time inference.

How Schema Linking Anchors Questions Before Runs

The retrieval flow starts with a step many RAG-style systems skip. Before any embedding search runs, the incoming question is checked directly against the schema's own vocabulary for literal matches. Did the question name something that actually exists?

This schema linking step is deliberately conservative about what counts as a match. A wrong guess here poisons everything downstream, so it's better to report that nothing was named outright than to anchor on a similar-looking word.

What the question names then shapes how the search behaves. A question that clearly names one thing gets a tight, narrow search. A vague or open-ended question gets a wider one. A system that always searches with the same breadth either wastes budget on easy questions or comes back too narrow on hard ones.

Why Text-to-SQL Needs Both Semantic and Keyword Search 

Hybrid search combines two approaches:

  • Semantic search matches meaning, finding relevant columns even when names differ from the query.

  • Keyword search matches exact names that semantic search might under-rank.

Results from both are merged, slightly boosting confirmed schema matches and downweighting overly broad tables.

Noisy tables are down-ranked rather than deleted, keeping them available if needed later.

How Graph Traversal Solves Multi-Table Join Paths in Text-to-SQL 

Finding relevant tables is a different problem from finding a connected, executable set of tables. This is where the architecture treats the join path as something to solve for, rather than an afterthought.

Once a question has been anchored on a handful of tables, the system looks for the minimal connected structure in the relationship graph that spans all of them. It adds whatever intermediate tables are structurally necessary, even when the question gives no textual or semantic signal that they exist.

For example, answering "what did each customer buy" requires an intermediate join table between customers and products that neither semantic search nor the prompt explicitly mentions. Graph traversal solves for this unstated connecting path to build a valid query.

Two Guardrails That Stop Wrong SQL From Reaching Users 

Two final checks ensure incorrect query results never reach users:

  1. Structural soundness caps confidence: If a query is structurally invalid (like broken joins or missing keys), its confidence score is capped. Strong keyword matches cannot override a broken query structure.


  2. Strict query execution boundary: SQL generators can only reference schema elements pre-approved by the retrieval step. If a requested column isn't found, the system stops instead of guessing.

Why Accuracy Is the Real Product in Conversational BI 

Taken individually, these concepts are far from novel. Hybrid retrieval strategies, graph path resolution, and execution guardrails are well-understood engineering techniques. What sets this architecture apart is recognizing that in text-to-SQL, failure is almost always silent. An incorrect relationship or a misplaced aggregation will not throw a runtime error; it simply produces a plausible-looking figure that quietly misinforms decision-makers.

To address this, every layer of retrieval must be configured to filter out ambiguities long before code generation occurs, rather than relying on basic syntax checks. When the ultimate goal is enabling business leaders to query data naturally without doubting the underlying calculations, rigorous semantic grounding is not just a feature — it is the core foundation of the platform.

How NuoData Cosmo Delivers Grounded Text-to-SQL

NuoData's Cosmo leverages semantic context, lineage, and secure access to create governed dashboards, embedded analytics experiences, and real-time business intelligence views directly on governed datasets.

It is built around the grounding principles of text-to-SQL, so business users can ask questions in plain language and get answers that trace back to governed definitions.

  • One governed catalog of tables, metrics, and relationships, so Finance, Sales, and Operations work from the same definitions.


  • Authored relationships with direction and cardinality, so joins don't silently fan out.


  • Retrieval-bounded query generation, so an answer only uses schema elements that were found and vetted.

    See how Cosmo answers business questions on your own warehouse

A finance leader asks the analytics assistant how much the company collected from government payers last quarter. A number comes back in seconds. It looks right, and it goes into the board deck. Three weeks later, someone reconciles it by hand and finds it was off by a factor of four.

Text-to-SQL allows LLMs to translate plain-language questions into warehouse queries, but it poses a major risk: silently returning incorrect numbers that look plausible and go undetected until reconciled manually.

Human data experts translate questions by reasoning through business context first, then identifying necessary tables and joins. In contrast, an LLM relying solely on schema dumps pattern-matches names and guesses joins, producing confidently wrong numbers without warning.

To make conversational BI reliable, systems need a purpose-built semantic layer, hybrid schema retrieval, and graph-based join solving to ground queries before execution.

Why Do Text-to-SQL Queries Return Wrong Numbers Without Errors? 

Most text-to-SQL errors don't crash. The query executes, the dashboard renders, and the wrong answer looks exactly like a right one. This issue typically stems from three main shortcuts.

  1. A full schema dump overwhelms the model : Real warehouses have hundreds of tables and thousands of columns, far more than fits usefully in a prompt. Most of it is irrelevant to any one question, and the noise makes the model's guesses worse.

  1. Keyword search misses business language : Plain keyword search over table and column names fails the moment a business question uses different words than the schema does. Nobody's table is literally named how_much_we_collected.

  1. The wrong join path produces the wrong number: Finding the right tables is only half the problem. The tables that answer a question are often connected through two or three other tables the question never mentions. Getting that connecting path wrong doesn't break the query. It silently multiplies or duplicates rows and hands back a wrong answer.

The approach described here treats finding the right slice of the warehouse as its own retrieval problem, with a domain model built specifically for it. It does not rely on general-purpose document search to get close enough.


See how NuoData helps your team turn enterprise data into trusted insights. See Cosmo on your own warehouse

Book a Demo

How to Build a Semantic Layer for Accurate Text-to-SQL 

The semantic layer is built from three distinct kinds of entities, all scoped under one project-level catalog: tables and columns, metrics, and relationships. Each one does a different job in keeping LLM SQL accurate.


  1. Tables and columns: business vocabulary plus structural facts

Tables and columns carry two kinds of information side by side. One is business framing — human-readable names and synonyms, a description, a domain tag — the vocabulary a person would actually use. The other is physical and structural fact — a semantic type (a monetary amount, a category, a timestamp, independent of its raw column type), whether it's a key, whether it's sensitive, and what one row of the table represents.

Keeping these separate matters. Business framing drives retrieval: does this look like what the question is asking about? Structural facts drive correctness: can this column safely be joined on, summed, or grouped by?


  1. Metrics as grounding hints for the query

Metrics are deliberately thin — a name, a description, roughly what gets aggregated and how. A metric here is retrieval vocabulary. It is not an executable formula layer. Citing a known metric by name tells the system, "here's a business-vetted way to compute this, prefer it over inventing your own aggregate." It is a grounding hint for whatever assembles the final query.

That's a real trade-off. A fixed formula layer buys consistency but can't flex to an ad hoc question nobody anticipated. Treating metrics as strong suggestions buys flexibility, at the cost of not guaranteeing every number was computed the one true way. In conversational BI, most questions are ad hoc by definition, so the trade leans toward flexibility.


  1. Relationships: defining join direction and cardinality

Relationships are the most consequential entity of the three. In many real warehouses, foreign keys aren't consistently declared or enforced. Even where a key relationship exists, it only tells you two columns are comparable. It never tells you which side is the "one" side of a one-to-many.

Guessing that wrong doesn't error out. It can change a sum by an order of magnitude or more, because the join fans out rows it shouldn't. So relationships — including direction and cardinality — are authored, curated facts in the semantic layer. That's the reason they're modeled as a first-class entity instead of a query-time inference.

How Schema Linking Anchors Questions Before Runs

The retrieval flow starts with a step many RAG-style systems skip. Before any embedding search runs, the incoming question is checked directly against the schema's own vocabulary for literal matches. Did the question name something that actually exists?

This schema linking step is deliberately conservative about what counts as a match. A wrong guess here poisons everything downstream, so it's better to report that nothing was named outright than to anchor on a similar-looking word.

What the question names then shapes how the search behaves. A question that clearly names one thing gets a tight, narrow search. A vague or open-ended question gets a wider one. A system that always searches with the same breadth either wastes budget on easy questions or comes back too narrow on hard ones.

Why Text-to-SQL Needs Both Semantic and Keyword Search 

Hybrid search combines two approaches:

  • Semantic search matches meaning, finding relevant columns even when names differ from the query.

  • Keyword search matches exact names that semantic search might under-rank.

Results from both are merged, slightly boosting confirmed schema matches and downweighting overly broad tables.

Noisy tables are down-ranked rather than deleted, keeping them available if needed later.

How Graph Traversal Solves Multi-Table Join Paths in Text-to-SQL 

Finding relevant tables is a different problem from finding a connected, executable set of tables. This is where the architecture treats the join path as something to solve for, rather than an afterthought.

Once a question has been anchored on a handful of tables, the system looks for the minimal connected structure in the relationship graph that spans all of them. It adds whatever intermediate tables are structurally necessary, even when the question gives no textual or semantic signal that they exist.

For example, answering "what did each customer buy" requires an intermediate join table between customers and products that neither semantic search nor the prompt explicitly mentions. Graph traversal solves for this unstated connecting path to build a valid query.

Two Guardrails That Stop Wrong SQL From Reaching Users 

Two final checks ensure incorrect query results never reach users:

  1. Structural soundness caps confidence: If a query is structurally invalid (like broken joins or missing keys), its confidence score is capped. Strong keyword matches cannot override a broken query structure.


  2. Strict query execution boundary: SQL generators can only reference schema elements pre-approved by the retrieval step. If a requested column isn't found, the system stops instead of guessing.

Why Accuracy Is the Real Product in Conversational BI 

Taken individually, these concepts are far from novel. Hybrid retrieval strategies, graph path resolution, and execution guardrails are well-understood engineering techniques. What sets this architecture apart is recognizing that in text-to-SQL, failure is almost always silent. An incorrect relationship or a misplaced aggregation will not throw a runtime error; it simply produces a plausible-looking figure that quietly misinforms decision-makers.

To address this, every layer of retrieval must be configured to filter out ambiguities long before code generation occurs, rather than relying on basic syntax checks. When the ultimate goal is enabling business leaders to query data naturally without doubting the underlying calculations, rigorous semantic grounding is not just a feature — it is the core foundation of the platform.

How NuoData Cosmo Delivers Grounded Text-to-SQL

NuoData's Cosmo leverages semantic context, lineage, and secure access to create governed dashboards, embedded analytics experiences, and real-time business intelligence views directly on governed datasets.

It is built around the grounding principles of text-to-SQL, so business users can ask questions in plain language and get answers that trace back to governed definitions.

  • One governed catalog of tables, metrics, and relationships, so Finance, Sales, and Operations work from the same definitions.


  • Authored relationships with direction and cardinality, so joins don't silently fan out.


  • Retrieval-bounded query generation, so an answer only uses schema elements that were found and vetted.

    See how Cosmo answers business questions on your own warehouse

Turn your data into trusted answers.

Subscribe to our Newsletter

© 2026 NuoData. All rights reserved.

Subscribe to our Newsletter

© 2026 NuoData. All rights reserved.

Subscribe to our Newsletter

© 2026 NuoData. All rights reserved.

Subscribe to our Newsletter

© 2026 NuoData. All rights reserved.