Marketing Analytics & AI Lead
08 September 2026
An excerpt from an article written by Sree, published in ‘AI in Plain English’ Journal.
Large language models have made generating SQL from natural language surprisingly easy.
But in an enterprise environment, generating SQL is only a small part of the problem.
The harder question is:
Can we trust the answer?
Over the past few years, I have worked on building and maintaining analytics products covering sales, marketing, customer experience and operational performance. As these datasets became more mature and widely used, a natural opportunity emerged: could we allow business users to interact with this data directly using plain English?
That led to the development of a series of governed, domain-specific Text-to-SQL assistants.
The objective was simple:
“Allow business users to ask questions in plain English and receive fast, trusted answers from approved analytics datasets - without needing to write SQL.”
This article walks through the thinking behind the solution, its architecture, the governance framework, how we evaluated it, and some of the most important lessons I learned along the way.
One of my core responsibilities at Appliances Online has been building analytics products that help monitor business performance across different time horizons - from yearly and monthly reporting all the way down to daily and near real-time hourly performance.
Over time, we developed data products bringing together areas such as:
But it also created another challenge.
As access to data improved, people naturally started asking more questions.

As the organisation became increasingly data-driven, demand for ad-hoc analysis grew.
A business user might ask:
The data required to answer many of these questions already existed.
The challenge was accessibility.
Answering them often required someone who understood:
The traditional workflow looked something like:
Business question * Analyst * SQL * Validation * Answer
This works, but it doesn’t scale particularly well.
Analysts can gradually become an interface between business users and their own data.
That led to a simple question:
“What if a business user could ask the same question directly in plain English?”
The basic concept behind Text-to-SQL is straightforward.
A user asks:
“Show me revenue by category for the last seven days compared with the previous seven days.”
A large language model interprets the question and generates the corresponding SQL.
BigQuery executes the query and the result is returned to the user in a business-friendly format.
Conceptually:
Business Question * LLM * SQL * BigQuery * Answer
But I quickly realised that this architecture alone wasn’t sufficient for an enterprise analytics environment.
The model shouldn’t have unrestricted access to the data warehouse.
And generating syntactically valid SQL doesn’t necessarily mean generating the correct business answer.
We needed another layer:
governance.
One of the important architectural decisions was not to build a single assistant capable of querying everything in the warehouse.
Instead, I divided the problem into business domains.
The initial framework consisted of three assistants:
Focused on questions around:
Focused on areas such as:
Focused on:
This separation turned out to be useful for several reasons.
Each agent had a clearly defined responsibility.
It reduced the amount of data and metadata the model needed to understand at once.
And, importantly, it made the system easier to govern, evaluate and explain.
I deliberately kept the architecture relatively simple.
For the Sales Performance assistant, the flow looked conceptually like this:

The agent wasn’t simply given a database and told to generate SQL.
Before querying the data, it had access to contextual information including:
That distinction is extremely important.
Valid SQL Doesn’t Always Mean a Valid Answer
Consider a deceptively simple question:
“What was revenue yesterday?”
A model might easily generate perfectly valid SQL. But several business questions remain.
The SQL could execute successfully while still producing the wrong business number.
This was one of the most important lessons from the project:
Text-to-SQL isn’t only a SQL-generation problem. It is a business-semantics problem.
That is why business definitions and the semantic layer became central components of the architecture.
Because the assistants were designed for business users, trust and consistency were critical.
Several safeguards were therefore built around the model.
1. Approved datasets only Agents could query only datasets that had already been validated and were trusted for analytics.
They did not have unrestricted access to the wider warehouse.
2. Business definitions Important metrics and terminology were explicitly defined.
The model shouldn’t have to guess what terms such as revenue, conversion, active customer or returning customer mean within the organisation.
3. Semantic rules Relationships between dimensions, metrics and datasets were provided as context so that queries followed established business logic.
4. Read-only access The assistant was designed for analytics.
Generated SQL therefore operated under read-only principles rather than allowing the model to modify underlying data.
5. Query-cost controls Large analytical queries can become expensive.
Controls were introduced to restrict the amount of data a generated query could process - for example, enforcing a maximum processing threshold of approximately 2 GB for applicable queries.
6. Human oversight AI did not eliminate the analyst.
Complex or unusual questions could still be reviewed, and outputs could be validated against existing dashboards, KPI reports and analyst-written queries.
The objective was not:
AI instead of analysts.
It was:
AI for routine questions, analysts for higher-value investigation and decision support.
Once the system was working, another interesting question emerged:
How do we know whether it is actually good?
Simply checking whether the SQL executes isn’t enough.
I eventually thought about evaluation across three main dimensions.
1. SQL Correctness
Did the agent generate the appropriate SQL logic?
This includes areas such as:
2. Answer Accuracy
Even if the SQL looks reasonable, does the resulting answer match the trusted business result?
Outputs could be compared against:
This distinction matters.
SQL correctness asks whether the query is right.
Answer accuracy asks whether the business answer is right.
3. Reliability
Finally, could the agent continue producing the correct result when:
A useful analytics assistant needs to be more than occasionally impressive.
It needs to be consistently dependable.
Initially, evaluation involved representative business questions and manual comparison against trusted results.
When failures occurred, I looked at where they originated.
Was the problem:
The appropriate layer could then be refined.
Over time, these representative questions became reusable evaluation sets.
That opened the door to automated regression testing.
Changes to prompts, models, semantic definitions or agent logic could be tested against known questions before being released.
This became particularly important as the system expanded beyond the first Sales Performance assistant into additional business domains.
There are two ways I think about the potential value of this type of system.
Reducing repetitive analyst workload
Consider a relatively conservative scenario.
Suppose approximately 25 routine analytics questions are raised each week and each requires around 30 minutes of analyst effort.
That represents:
25 questions * 30 minutes * 52 weeks = 650 analyst hours per year
At an illustrative analytics cost of AUD 80-100 per hour, that equates to roughly AUD 50,000-65,000 of annual analyst capacity that could potentially be redirected toward higher-value work.
The important point isn’t necessarily the dollar figure.
It is what those hours can become.
Instead of repeatedly answering:
“What was revenue yesterday?”
an analyst can spend more time answering:
“Why is revenue changing, and what should we do about it?”
For me, the more interesting value was not simply productivity.
It was decision speed.
Imagine sales suddenly decline by 10%.
The metric may already exist somewhere in a dashboard.
But identifying what changed could require someone to investigate:
Traditionally, that can trigger an analyst request and investigation.
With a governed conversational analytics layer, a leader can begin interrogating those questions immediately.
For a business operating at significant daily revenue volumes, even relatively small improvements in the speed at which material issues are identified and investigated can have meaningful commercial value.
For example, in a hypothetical business generating AUD 5 million per day, 1% of daily revenue represents AUD 50,000.
That doesn’t mean a Text-to-SQL assistant automatically “creates” or “saves” that revenue.
But it illustrates why reducing the time between signal * investigation * action can matter.
The biggest lesson from this project was surprisingly simple.
Generating SQL wasn’t the hardest part. Generating trust was.
Modern language models can generate impressive SQL remarkably quickly.
But enterprise analytics requires more.
The things that ultimately mattered most were:
Model capability certainly matters.
But once the model is reasonably capable, improvements in governance, metadata and business semantics can sometimes be more valuable than simply switching to a more sophisticated model.
That changed how I think about enterprise AI systems.
The goal isn’t to build the most impressive AI demo.
The goal is to build something that people can confidently use to make decisions.
For me, that comes down to three principles:
Trust > Technology
Governance > Model Sophistication
Business Value > AI Novelty
Sree is a Marketing Data Scientist and seasoned writer with over a decade of experience in data science and analytics, focusing on marketing and consumer analytics. Based in Australia, Sree is passionate about simplifying complex topics for a broad audience. His articles have appeared in esteemed outlets such as Towards Data Science, Generative AI, The Startup, and AI Advanced Journals. Learn more about his journey and work on his portfolio - his digital home.