Problem
Project managers and analysts at Salesforce had data questions that only SQL could answer. Engineers and data scientists became gatekeepers and spent dozens of hours per week writing custom queries, while users waited just as long. Dashboards in a BI tool such as Tableau take engineering time to build and do not cover every question. Some users did not wait and decided on stale data or guesses.
Example from the article: a user asks in Slack, "what was the cost of my service in September?", and then "break the cost out by AWS service".
Solution in brief
The team built an internal Slack agent, Horizon Agent. It adds to each question a business glossary and table metadata (retrieval-augmented generation, RAG), asks the LLM for SQL and an explanation, and posts both. The agent generates 10 candidate queries, keeps the one closest to the majority, and checks it with EXPLAIN before running anything.
Questions this case answers
- How to let non-technical users query a warehouse in natural language when business terms are ambiguous and the model is non-deterministic
- How to raise the share of correct generated SQL queries when one generation per question is unreliable
- How to let non-technical colleagues get answers from the data warehouse without waiting for an engineer to write SQL?
- How to give a text-to-SQL agent the company's business jargon and table knowledge so that it writes valid queries?
Tools and methods
- Slack app (Bolt, Python) — the interface; a Python microservice on AWS receives the messages
- Fack — Salesforce's open-source tool that holds the glossary, concepts and Trino SQL-writing rules
- Horizon Data Platform — internal dbt-like catalog: table descriptions, sample queries and sample records
- Einstein Gateway — internal gateway to LLMs
- Trino over an Iceberg data lake — runs the approved query
- Cosine similarity and Levenshtein distance — voting over the candidate queries
Google or a one-time email code. No password.