Outcome
Typical turnaround dropped from 4-10 hours to under 1 hour.
Case study
Structured metadata, AI SQL agents, and Athena-based validation turned repeated ad-hoc analytics into a reusable Text-to-SQL workflow.
Outcome
Typical turnaround dropped from 4-10 hours to under 1 hour.
Overview
Ad-hoc analytics requests were consuming too much analyst time. In practice, the slow part was not SQL syntax. It was finding the right tables, understanding what columns meant, mapping business logic correctly, and figuring out join patterns that could actually be trusted.
That made even routine questions expensive. Complex requests often took 4 to 10 hours, which limited how many requests the team could realistically support each month.
I built a structured metadata layer in YAML that captured how analysts actually reason about the data model: table definitions, column semantics, keys, partitioning, join patterns, and business terminology.
The workflow then used AI coding agents to generate SQL, execute it in Athena, and validate results before anything was handed back. The leverage came from structuring context well enough that the system could reuse it repeatedly.
Workflow
The workflow narrowed context first, then generated, executed, and checked SQL before any result was handed back to a human.
Tables were grouped by domain and narrowed through index files so the agent only saw the relevant slice of metadata.
AI coding agents used the structured metadata to generate and revise SQL based on the actual business question.
The workflow ran queries in Athena, checked execution success, and validated results before handing anything back to a human.
The resulting structure could be updated and reused so later requests started from a better base instead of from scratch.
System flow
The system did not stop at generation. It executed, checked, and iterated until the result was reliable enough for review.
Results
Before
4 to 10 hrsTypical ad-hoc turnaround before the system.
After
Under 1 hrTurnaround after structured context and validation loops.
Capacity
20 to 50+Approximate monthly ad-hoc capacity after the workflow improved.
Takeaways
The core problem was not generating SQL text. It was capturing how analysts interpret the data model and business logic in a form AI could actually reuse.
By structuring table semantics, joins, and business terms well enough, the workflow reduced repeated research work instead of only accelerating typing.
Related
Case studies and methods that connect to the same operational questions.
Case study
Built a warehouse optimization workflow that combined graph construction and simulation to test inventory placement and picker travel distance before a full optimizer existed.
Method
An inventory planning method that estimates SKU-level seasonality, groups products into seasonal buckets, and connects those signals back to category planning.