rithik.ghantasala
← Work/Data Engineering2026

DataPilot

Natural language to governed SQL over BigQuery

A self-serve analytics system that resolves business meaning before generating SQL. An ontology layer holds metric definitions, join paths and access policies, so a question is mapped to governed semantics first and only then handed to a model for generation, with validation, PII checks and a dry-run cost estimate before anything executes.

01The problem

Text-to-SQL systems fail in a way that is worse than erroring: they return a plausible number computed the wrong way. If revenue means something specific in your business, a model that infers it from column names will get it subtly wrong, and nobody will notice until two dashboards disagree.

02How it works

Resolve semantics before generating anything. An intent classifier routes the question, an ontology layer resolves metric definitions, join paths and role-based access policy, and only then does a model generate SQL against that resolved context. Generated SQL passes through guardrails that reject destructive statements, a PII check, and a dry run for cost before execution. A fallback manager handles templates for common questions.

03Decisions worth defending

Why it is built this way

  1. 01Semantics first, generation second

    The model never sees a bare question and a schema. It receives resolved metric definitions and join paths, which turns generation from inference into translation.

  2. 02Validate before executing, always

    Destructive statements are rejected outright, and a dry run bounds cost before a query touches the warehouse. On a metered engine, an unvalidated generated query is a billing incident waiting to happen.

  3. 03Templates for the common path

    Frequently asked questions resolve to reviewed templates rather than fresh generation, which is both cheaper and more consistent.

04What I took from it
Writing the ontology layer before the generation layer forced me to answer a question I had been avoiding: what does this metric actually mean, and who is allowed to see it. That turned out to be the hard part of text-to-SQL. Generating syntactically valid SQL is nearly solved; generating SQL that computes what the business means is a data modelling problem wearing an AI costume.
05Stack
PythonSQLBigQuerydbtVertex AIGeminiFastAPINext.jsCloud RunTerraform

Next project

MyClaw

Agentic automation with approval gates on side effects