Public case (sourced). Based on Uber Engineering's published post "QueryGPT - Natural Language to SQL Using Generative AI" (2024-09-19); every fact below is attributed to it.
This case belongs to Agents, Tools and MCP. The post is the only source; where it says nothing, this page says so, and the diagrams draw only the elements the post names.
Context
- Uber's post says that SQL is used daily by engineers, operations managers and data scientists, and that writing queries takes SQL syntax and knowledge of Uber's internal data models.
- It says the data platform handles approximately 1.2 million interactive queries each month, and that the Operations organisation, one of the largest user cohorts, contributes about 36% of them.
- The post says QueryGPT began at Uber's Generative AI Hackdays in May 2023. It describes two of about 20+ iterations: a first version and the current design.
Problem statement
| What the post says | Value |
|---|---|
| Authoring: search the data dictionary for relevant datasets, then write the query | Around 10 minutes per query |
| QueryGPT (the post's own claim) | Can generate reliable queries in about 3 minutes |
The post does not say how either figure was measured, and it states no other numeric target.
Constraints
Everything below is stated in the post.
- Schema size. Some tier 1 tables have schemas spanning over 200 columns, which could use 40-60K tokens in the request. The post says that 3 or more of these tables would break the LLM call, since the largest available model at the time supported only 32K tokens.
- Non-determinism. Identical runs can differ; Uber does not over-index decisions on about 5% run-to-run changes in most metrics.
Why the traditional approach fell short
Two approaches fell short according to the post: manual authoring (see the problem statement) and the team's own first version, a simple retrieval-augmented design (Option B below). The post names three problems with the first version:
- Similarity search of a raw prompt against schema samples and SQL queries did not return relevant results.
- Going from a natural language prompt to the right schemas was very difficult.
- Having 3 or more of the large schemas would break the LLM call.
The post does not discuss other tools such as BI products or semantic layers.
Options considered
| Option | What the post says | Outcome |
|---|---|---|
| A. Write the SQL by hand (non-AI, the status quo) | Around 10 minutes per query; needs SQL and data-model knowledge | The problem QueryGPT addresses |
| B. First version: simple retrieval with few-shot prompting | Vectorised the user's prompt and ran a k-nearest-neighbour search over SQL samples and schemas to fetch 3 relevant tables and 7 relevant SQL samples; sample data set of 7 tier 1 tables and 20 SQL queries | Accuracy declined as more tables and samples were onboarded; replaced |
| C. Current design: workspaces and a chain of narrow LLM agents | Intent agent, Table agent, Column Prune agent, described below | The design the post describes as current |
The post does not describe other options it considered.
Solution architecture
Figure 1. The current design as the post describes it
How to read this: every prompt runs through the intent agent first; the post does not state the order of the table and column prune agents.
Figure 2. One question through the agents
How to read this: the user confirms the table list, and the last note marks the failure the post says it has not solved.
How AI solved it, step by step
Per the post, one request goes like this. Step through it.
The post does not say which model runs each agent or how long the chain takes.
Under the hood
The mechanism the post spells out is the token budget (the schema limits are under Constraints).
| What the post says | Detail |
|---|---|
| Model used | GPT-4 Turbo with a 128K limit (1106), and still intermittent token limit issues for some requests |
| Fix | The column prune agent: it improved the token size and, by extension, the cost of each call, and reduced latency because inputs were smaller. No figures given |
An arithmetic check, which is this page's and not a figure from the post: three tables at the post's 40-60K range would use 3 x 40K = 120K to 3 x 60K = 180K tokens of schema, which can exceed a 128K limit before samples, instructions and the answer are counted.
The post prunes schemas once, before generation, and does not call this compaction. See context growth and compaction in the lesson.
What went wrong / failure modes
The post reports these problems.
| Problem | What the post says |
|---|---|
| Accuracy fell as tables were added; some users reported wrong tables; token-size failures | Addressed by workspaces and the intent agent; the table agent with a confirm-or-edit step; the column prune agent |
| Hallucinated tables and columns | The LLM sometimes generates queries with tables that do not exist; not completely solved. The post mentions prompt changes and a chat mode, and says Uber is looking to add a "Validation" agent that recursively tries to fix them |
| Queries that run but return nothing | A hallucinated filter such as status = "Finished" instead of "Completed"; this is why its metrics count whether a run has output |
| Similarity is not correctness | A question regularly fails because it omits a partition filter, although the LLM similarity score rates it as similar to the golden SQL |
How the post evaluates
It builds a golden set from real questions in QueryGPT logs, with intent, schemas and SQL verified manually. Per question it records:
| Metric | What it is |
|---|---|
| Intent accuracy | Was the intent right |
| Table overlap | 0 to 1; in the post's example two tables were required, one was identified, and the score is 0.5 |
| Successful run | Did the query run |
| Run has output | Did it return more than 0 records |
| Similarity | An LLM scores the query against the golden SQL between 0 and 1 |
Figure 3. The two evaluation flows
How to read this: per the post, the vanilla flow measures baseline performance and the decoupled flow enables component-level evaluation by removing dependencies on earlier outcomes.
The post describes the decoupled flow as measuring performance with the human-in-the-loop experience.
Results
Only the post's own numbers are used here.
| What the post reports | Value |
|---|---|
| Limited release | Some Operations and Support teams |
| Daily active users | About 300 on average |
| Users saying the generated queries reduced the time they would otherwise spend writing queries from scratch | About 78% |
| Estimated time to author a query | About 10 minutes by hand against about 3 minutes with QueryGPT |
The post publishes no accuracy figures, latency, cost or golden-set size; the 78% is user-reported, not a measured accuracy.
Tradeoffs and when NOT to use this approach
This section is this page's reading of the post, not statements by Uber.
- Each agent is another LLM call; the post gives no end-to-end latency or cost figures.
- The first version worked well for a small set of schemas, so simple retrieval can be enough when there are few.
- Silent errors, such as a query on the wrong table, matter most for users who cannot read SQL; the post advises targeting the right personas first.
- The post does not say how access control or data privacy are handled, so a team with strict data permissions needs its own answer.
Design rules extracted
- Narrow the search space before retrieving. The post's workspaces and intent agent cut the retrieval radius.
- Give each LLM step one narrow job. The post says the LLMs worked well when given a small unit of specialised work.
- Add a human confirmation where users report errors, such as the table list.
- Cut the context before the expensive call; the post's column prune agent did this for schemas.
- Evaluate components separately on a golden set from real logs, and check that queries run and return rows.
Sources
- Jeffrey Johnson, Callie Busch and Abhi Khune, "QueryGPT - Natural Language to SQL Using Generative AI", Uber Engineering, 2024-09-19: https://www.uber.com/blog/query-gpt/ (accessed 2026-10-21, re-checked 2026-10-22). All facts above are from this post.
Last verified: 2026-10-22