Problem
Business users at Intercontinental Exchange (ICE), the operator of the New York Stock Exchange, need answers from structured financial data products. They do not know the data models, schemas or SQL, so every question goes through someone who does. The data cannot be moved out of the existing application. Without a ground-truth question set there is also no way to tell whether generated SQL is right.
Example from the article: a user asks for properties sold in cities where the total FBI crime count is below 50. The system must pick the tables and join them. The post uses synthetic data for confidentiality.
Solution in brief
The system retrieves table definitions, sample rows and similar question-SQL pairs by vector search and puts them in a few-shot prompt. Generated SQL is scored against expert SQL by syntactic and execution matching. Wrong queries, with their ground truth, become future few-shot examples.
Questions this case answers
- How to answer questions over governed tables with generated SQL when users cannot write queries and the data must stay in place
- How to evaluate generated SQL deterministically, without an LLM judge, on a small expert-labeled question set
- How to let business users query structured tables in natural language without knowing the schema or SQL?
- How to give an LLM enough table context to write correct SQL without moving the data?
Tools and methods
- Databricks Vector Search (AI Search) — indexes the table-definition and sample-query tables for retrieval.
- Unity Catalog — stores the tables, their descriptions and the metadata tables.
- Databricks Foundation Model APIs — access to the LLM (Llama 3.1 70B in the prompt example).
- Databricks Model Serving with Inference Tables — serves the app and logs every question and answer.
- Label Studio — lets experts write ground-truth SQL for logged questions.
- Spider evaluation framework — syntactic matching, adapted to the enterprise tables.
Google or a one-time email code. No password.