In-house text-to-SQL assistant for analysts
Build an internal assistant that finds the right tables from metadata, writes SQL and explains it, as Pinterest, Uber and LinkedIn did.
The use case
Large companies have thousands of tables, and the hard part of text-to-SQL is picking the right ones. Pinterest, Uber (QueryGPT) and LinkedIn (SQL Bot) each published how they built internal assistants: retrieve candidate tables using metadata and past queries, prune columns, have the model write SQL, then validate and fix it. They report that table descriptions and domain grouping mattered as much as the model. Analysts still read the SQL, check it against known numbers, and use the assistant to draft queries rather than as an oracle.
Example workflow
- Collect table metadata, descriptions and popular queries
- Retrieve candidate tables for each question
- Generate SQL and run validation
- Show SQL with an explanation to the user
- Log feedback to improve metadata
Tools
- LLM API
- Vector database
- Data warehouse
Risks and guardrails
- Poor table metadata leads to wrong tables
- Enforce existing data access controls on generated queries
- Measure accuracy on a test set before rollout
Sources
Written by Agents Lookup. Credits and official pages for the tools this use case names:
- Pinterest engineering blog: text-to-SQL: medium.com/pinterest-engineering/how-we-built-text-to-sql-at-pinterest-30bad30dabff
- Uber engineering blog: QueryGPT: www.uber.com/blog/query-gpt
- LinkedIn engineering blog: practical text-to-SQL: www.linkedin.com/blog/engineering/ai/practical-text-to-sql-for-data-analytics