CASE FILE

CH.01APPLIED AI

Ask the Warehouse

LANGGRAPHMCPTEXT-TO-SQLDBT SEMANTICEVALS
An engineer sits at a terminal while a spectral ink fox-spirit made of data rises out of the glowing screen.

THE PROBLEM

Analysts were queuing days for the data team to write SQL, and the ones who wrote their own ran it against tables nobody had vetted, so two people brought two different revenue numbers to the same meeting. The status quo was a shared request backlog plus ad-hoc SQL pasted around in chat, and it could not stay because every answer carried a hidden reconciliation tax. I took it on with one rule learned the hard way: an LLM left alone with raw schema will invent a column with total confidence, so I designed the assistant around that failure mode instead of pretending it away.

CONSTRAINTS

  • LLMs hallucinate schema they cannot see — saw it in the first week
  • Read-only access, no production writes, ever
  • Untrusted queries need row and cost limits after one runaway join
  • Every prompt or model change must be regression-gated

DECISIONS & TRADEOFFS

SEMANTIC-LAYER ALLOWLIST over raw schema prompting — because the agent can only ask for metrics and dimensions the dbt semantic layer already defines, so hallucinated columns fail closed

SELF-CORRECTION LOOPS over single-shot generation — because the agent parses execution errors and retries against the validator instead of returning a confident wrong answer

EVAL-GATED DEPLOYS over prompt-and-pray — because a golden question set runs in CI and any prompt or model swap that regresses answer quality never ships

ARCHITECTURE

01NL QUESTIONanalyst asks in plainlanguage02AGENT GRAPHlanggraphplan-act-reflect loop03SEMANTIC LAYERdbt metrics allowlist04SQL VALIDATORread-only, row limits,cost cap05WAREHOUSEquery execution06ANSWER + SQLresponse shows its work

OUTCOME

Analysts answer their own questions now, and every answer shows the exact SQL underneath so trust is checked, not assumed. The data team stopped being a ticket queue and reviews the allowlist instead of rewriting the same queries. Queries the validator does not like are refused, not executed, and the eval gate means the system gets safer with each change instead of drifting into confident nonsense.

PROOF / LINKS

INTERACTIVE DEMO

Ask the Warehouse

sql.ameyaka.com

OPEN ↗

AT 100× SCALE

At 100x this becomes a governed analytics gateway: per-team semantic scopes, query-cost budgets, and an audit trail of every question the business ever asked the warehouse.