AI Analytics ResourcesJanuary 8, 2026(Updated October 27, 2026)

Natural Language Query Analytics: How to Interpret Questions and Check Answers

A production NLQ system must clarify intent, enforce semantic and tenant scope, bound execution, and return evidence with every answer.

Natural Language Query Analytics: How to Interpret Questions and Check Answers

Natural language query (NLQ) lets a user state a question in business language.

Before building a query plan, identify the metric, population, time window, level of detail, comparison, and tenant data the query may use.

Before showing an answer, check that it answers the intended question, respects permissions, computes the result correctly, and includes evidence the user can inspect.

Define the Requirements for an NLQ Answer

Natural Language Query (NLQ)

In this article, an analytics interface that accepts questions in ordinary language and interprets them using approved business definitions. It builds a query plan the user is authorized to run and shows the result with enough context and evidence for the user to judge what was answered.

A natural-language query answer evidence contract. A user question enters with tenant, role, locale, and inherited conversation context. Parse and clarify identifies the requested metric, entity, time window, grain, comparison, and unresolved ambiguity. Compile and authorize binds certified semantics, row and field scope, policy, limits, and an inspectable query plan. Execute and verify applies time and cost budgets, observes freshness and partial results, and records a query identifier and errors. The answer packet shows the interpreted question, metric version, filters, scope, freshness, source, result, and query identifier. A follow-up must explicitly keep, change, or clear prior context. The acceptance rule says the answer is releasable only when the interpretation, authorization, result, and evidence agree; otherwise the system clarifies, refuses, or reports failure.
Show an answer only after checking the interpretation, the permissions, the execution and the evidence.

When adding NLQ to an embedded analytics product, plan how it will use metric governance, access control, query execution, and result design. Apply each user's tenant, role, and field permissions to the result, and show which scope was applied.

Before implementation, define which questions the feature is intended to answer, which it must clarify, and which it must refuse.

Turn Language Into an Explicit Interpretation

Consider the question: “Show revenue trends.” A usable interpretation still needs to resolve:

  • which certified revenue metric and version;
  • gross, net, recognized, booked, or another business definition;
  • which entities and eligible population;
  • event time or accounting period;
  • default time window, grain, currency, and timezone;
  • whether “trend” means values over time, change, or a comparison;
  • which inherited filters from the current page or conversation remain active.

Let the language model propose values for these fields, but do not silently apply defaults that affect the answer. Ask a follow-up question when different interpretations could lead the user to different decisions. If a default can be used safely, display it in the interpreted question and let the user change it.

When evaluating AI-powered analytics features or other AI analytics capabilities, check whether you can trace each result to the user's question and the approved definitions used to answer it.

Bind Questions to Governed Semantics

Do not map “revenue” directly to a column name. Give the system the metric definition, join path, eligible set, aggregation, correction policy, currency treatment, and time grain it needs.

The semantic layer or equivalent governed model should provide:

  • stable business names and aliases;
  • certified metrics with owners and versions;
  • permitted dimensions, joins, and aggregations;
  • customer-specific mappings where the product supports them;
  • validation rules for incompatible fields or grains;
  • descriptions suitable for both the planner and the user-facing explanation.

Keep semantic retrieval scoped to the authenticated product context. A model should not receive every tenant's schema, sample values, or hidden field descriptions merely because they might improve generation.

Why can text-to-SQL fail without a semantic model?

A model that sees only table and column names has to infer what a semantic model would state outright: which column is the key, how two tables join, and at which grain a measure may be summed. When the inference is wrong, the query can still run and return a number that looks plausible.

Snowflake's engineering team uses a one-sale example. A customer buys four items in a single $100 sale. Join the customer to the sale, then the sale to its line items, and the sale total repeats once for every line item. Summed, it reports that the customer "spent $300 on four items, when in fact he spent $100" (Will Pugh, March 2026). Nothing in that SQL is invalid. The join path multiplied the measure before the aggregation ran.

On Spider 2.0, a set of 632 enterprise workflow tasks presented at ICLR 2025, the best agent solved 21.3% of tasks, against 91.2% on the older Spider 1.0 and 73.0% on BIRD. Average error rates were 29% to 49% for schema linking and 21% to 26% for joins in a 2024 survey of LLM text-to-SQL. In data.world's insurance benchmark (43 questions, 13 tables), GPT-4 answered 16.7% correctly from raw SQL, and 0% of the questions that combined simple wording with a complex schema.

A semantic model declares the joins and keys the language model would otherwise have to infer. In dbt's semantic models, every join-key column carries an entity type: primary, foreign, unique or natural. A Snowflake semantic view lists the relationships that define how its logical tables join. In Cube, "AI agents don't query the warehouse directly"; they query the semantic layer instead.

Four benchmarks from dbt Labs, Cube, data.world and Snowflake reported higher answer accuracy with a semantic model:

StudySampleWithout a semantic modelWith one
dbt Labs, April 202611 questions, each run 20 times, two current models84.1% to 90.0% on modeled questions98.2% to 100%
Cube authors, arXiv, April 2026100 questions (99 scored), 3 models45.5% to 50.5%67.7% to 68.7% (semantic model given as text context)
data.world, November 202343 questions, GPT-416.7%54.2% (knowledge graph)
Snowflake, August 2024internal question setsingle-prompt GPT-4o"nearly 2x as accurate"

Compare gains within each benchmark: Cube, data.world and Snowflake ran or co-authored their studies using different datasets and baselines. In dbt's run with current models, accuracy rose by about 8 percentage points (90.0% to 98.2%); in data.world's older GPT-4 run, it roughly tripled (16.7% to 54.2%). Measure the improvement on your product's own questions before setting an accuracy target.

In dbt's 2026 run, the semantic layer declined questions its model did not cover, while text-to-SQL answered them, sometimes wrongly. When the product cannot answer a question, explain why and help the user ask one it can answer; the evidence packet below shows how. Define the semantic model before adding the language interface. To use one semantic model across many customers, see the semantic layer guide for embedded analytics.

What is text-to-SQL in an embedded analytics product?

Text-to-SQL is one way to build AI analytics features into a product. A language model turns a question such as "revenue by plan last quarter" into a SQL statement that a database then runs. The rest of this section is written for a customer-facing analytics product.

Google Cloud's engineers say a model needs significant amounts of knowledge to write accurate SQL, including what the schema looks like and what a column means for the business (Per Jacobsson, May 2025). A product serving many customers also needs tenant isolation, enforced outside the model.

Three text-to-SQL patterns compared

The three patterns differ in how they handle errors and data access.

PatternDocumented behavior
The model writes SQL against raw tablesdbt Labs: "failure looks like a plausible but incorrect answer". Cockroach Labs: a dynamically built query can lose the tenant filter. In tests of seven LLMs, unsanitized prompts led to SQL injection attacks
The model writes SQL from a semantic modelSnowflake Cortex Analyst uses the semantic model's metadata only to generate SQL, and integrates with Snowflake's role-based access control
The model queries through a semantic layerdbt Labs: with the semantic layer, failure looks like an error message

In our view, an error message is the safer failure when the customer will not check the SQL. In dbt's run, the semantic layer also declined questions its model did not cover, so a product using the third pattern needs a way to tell the customer what it can answer.

Constraining the SQL a text-to-SQL model writes

We recommend these controls, which follow the least-privilege principle in OWASP's guidance on excessive agency:

  • Give the model the calling customer's metrics, dimensions and relationships from the semantic layer, instead of the raw schema.
  • Allow read-only statements against a fixed list of objects, with a row limit and a timeout. Fix values such as the user ID in the query layer instead of leaving them to the model.
  • Validate each statement before it runs, and reject it if it fails validation instead of repairing it silently.

Tenant scoping in a text-to-SQL pipeline

Enforce tenant isolation outside the model, as these production systems do:

If the database enforces the boundary with row-level security, check which role runs the generated SQL. In PostgreSQL 18, superusers and roles with BYPASSRLS "always bypass the row security system", and table owners normally bypass it unless the table uses FORCE ROW LEVEL SECURITY. A service that runs generated SQL as the table owner needs that setting, or a different role.

How to evaluate text-to-SQL for a customer-facing product

Execution accuracy, the most widely used evaluation metric, still produces many false positives and negatives (NAACL, 2025). Databricks scores Genie by comparing result sets against a reference query, and suggests two to four phrasings per question.

We suggest two additions for a customer-facing product:

  1. Include questions the product should decline to answer, and check that it declines.
  2. Include questions that ask for another customer's data, by name, by ID and inside pasted instructions, and report the number of rows that leak. The pass mark is zero.

Authorize the Compiled Plan

Do not rely on prompt instructions such as “only query the current tenant.” Authorization belongs in trusted services after the question has been interpreted and before execution.

The compiled plan should bind:

  • tenant, user, role, and allowed purpose where applicable;
  • row, field, metric, and artifact permissions;
  • approved datasets and join paths;
  • time range, result size, complexity, and cost limits;
  • export, drill-through, cache, and follow-up behavior;
  • a policy version and audit identifier.

Apply these controls to the generated query or intermediate representation. The browser and the language model can pass the requested context, but neither should be able to expand the user's authorized data scope.

In a customer-facing analytics product, interpret each phrase using that customer's own data and business definitions.

Execute Within a Bounded Runtime

Set runtime limits per tenant and per question.

Use an intermediate representation or inspectable plan when possible, then validate it before generating database-specific SQL or another executable query. Enforce time, row, memory, and cost budgets. Restrict functions and data sources. Cancel abandoned requests. Run interactive queries separately from heavy background jobs when they need different amounts of processing power or memory.

Return distinct states for:

  • no matching data;
  • a valid zero;
  • stale or delayed data;
  • partial results;
  • a refused question;
  • a timeout or resource limit;
  • an execution or source failure.

Show the result state explicitly and keep any explanation grounded in it.

Return an Evidence Packet With Every Answer

The answer should expose enough context for the user to judge what the system did:

  • the interpreted question;
  • metric name and version or definition access;
  • active filters, tenant or entity scope, time window, grain, and comparison;
  • data freshness and relevant source status;
  • the result and its empty, partial, stale, or failed state;
  • a query or audit identifier for support and investigation.

Choose the chart only after the result has passed these checks.

Preserve the answer's scope and interpretation when users drill into it, download it, save it, or share a link to it.

Make Follow-Up Context Visible

In conversational analytics, check every follow-up question for context carried over from earlier turns.

Suppose the user asks “Show net revenue by region for Q4,” then follows up with “now by product.” Decide whether to keep or change the metric, Q4 window, region filter, currency, tenant, and comparison, and show what was kept and what changed before or with the result.

Model conversational state as structured fields rather than only as chat history. Each turn should explicitly keep, change, or clear the metric, entities, filters, time window, grain, and comparison. Reauthorize and revalidate every new plan.

NLQ vs Dashboard Controls: When to Use Each

Use NLQ when users ask varied questions and the product can interpret their business terms with approved definitions and show how it understood each question. Use dashboard controls for repeated monitoring, precise parameter changes, comparisons between known views, and situations where typing is inconvenient.

Let users create or refine a query with NLQ, then adjust its metric, filters, and level of detail through dashboard controls. See also augmented analytics.

Self-service analytics users also need approved metrics and filters, a visible interpretation, ways to recover from errors, and access to support when the system cannot answer reliably.

Test With Realistic Questions and Failure Cases

Build an evaluation set from representative, permitted questions and score the stages separately:

  • intent and entity extraction;
  • metric and semantic mapping;
  • clarification versus safe default selection;
  • tenant, row, and field authorization;
  • plan validity and bounded execution;
  • numeric and categorical result correctness;
  • evidence completeness;
  • follow-up context retention and clearing;
  • refusal and failure behavior.

Include ambiguous wording, synonyms, misspellings, conflicting context, hidden fields, cross-tenant attempts, large ranges, unsupported joins, delayed sources, corrections, empty results, and adversarial instructions. Retain the interpreted plan and query identifier for each failure.

Require human review in high-impact domains and when semantic definitions, policy, or model behavior change. Measure which questions produce clarification, refusal, correction, support contact, or abandonment, not only whether the interface generated an answer.

Release Requirements for an Answer

Before an embedded analytics product shows a natural-language answer, require four things: the question is bound to approved definitions, permissions are checked by trusted services, execution stays within limits, and the answer carries its evidence (the definitions used, the filters applied, the data freshness and a query identifier).

Where to go next

Ready to launch customer-facing analytics?

Stop losing customers to competitors with better analytics. Sumboard's customer-facing analytics platform lets you launch self-service dashboards in days, not months.

Frequently asked questions

How does natural language query analytics work behind the scenes?

▾
Interpret the question and any context carried over from earlier turns. Resolve ambiguity, asking the user to clarify when needed, then map terms to approved metrics and entities. Check permissions for that data scope, run a bounded query plan, check the result state, and return the answer with its interpretation, filters, freshness, source, and query identifier. Let the language model suggest an interpretation or a plan, and use trusted services to enforce business definitions, permissions, and execution policy.

When is NLQ more useful than dashboard controls?

▾
Use NLQ when users ask a wide range of authorized questions, can phrase them in business terms, and can see how the product interpreted each one. Use familiar controls for repeated monitoring, precise parameter changes, comparisons between established views, and tasks that need predictable interactions. Offer both when users need open-ended exploration and routine monitoring.

What should you test before an analytics chat demo goes to production?

▾
Test ambiguous business terms, tenant and field permissions, customer-specific semantics, large or adversarial queries, stale data, corrections, partial results, and unintended context changes in follow-up questions. Check that users can see each of those states.

Why does text-to-SQL return wrong numbers without a semantic model?

▾
Without a semantic model, the language model often has to infer join keys, join paths and the grain at which a measure can be summed, unless the schema declares them. A wrong inference can still produce valid SQL, so the error appears as a plausible number, for example a sale total repeated once per line item. On enterprise schemas, a semantic model with declared keys and relationships raises accuracy, though the size of the gain varies widely by dataset, model and test.

What infrastructure do you need before adding NLQ to a SaaS product?

▾
Authenticate the tenant and role, define approved metrics, and enforce row and field permissions when queries run. Make query plans inspectable, set resource limits, and record data freshness and audit identifiers. Define how the interface shows empty, partial, stale, refused, and failed results. Add evaluation cases from real permitted questions before expanding the interface.

What is text-to-SQL?

▾
Text-to-SQL is a technique in which a language model converts a question written in ordinary language into a SQL query that a database can run. In embedded analytics, the query also has to respect each customer's data boundary.

Can you use text-to-SQL in a customer-facing product?

▾
PAR Technology's agent on AWS filters the tables to the signed-in user's rows before the model is invoked, and Databricks Genie evaluates access with each user's own permissions. Both place the tenant boundary outside the model, which fits OWASP's advice to implement authorization in downstream systems rather than rely on an LLM to decide.

Does the choice of LLM fix text-to-SQL errors?

▾
Both models scored above 98% through a semantic layer in dbt Labs' 2026 benchmark update (11 questions, each run 20 times, after minimal modeling). On text-to-SQL, Claude Sonnet 4.6 scored 90.0% and GPT-5.3 Codex 84.1%; through the semantic layer they scored 98.2% and 100%. Test candidate models on your own questions before choosing one.

How do you stop text-to-SQL from returning another customer's data?

▾
Enforce tenant isolation outside the model: filter the tables before the model runs, or run the generated SQL under a role that row-level security applies to. Then test it with cross-tenant questions and count the leaked rows.

Written by

Nicolae Guzun

Nicolae Guzun

Founder & CEO, Sumboard

Ship analytics faster

Build customer-facing dashboards with Sumboard.

Get started for free