AGWORKF · 10
AHMEDABADIST
VOL. 032024 — 2025
SCROLL
HOME / WORK / SAP Analytics Bot — Text-to-SQLText-to-SQL · conversational analytics · 2024 — 2025
— CASE 10 / TEXT-TO-SQL · SILVER TOUCH

TEXT → SQL
+ DASHBOARDS.

Ask a business question in plain English; get back the SQL, the answer, and two charts — over 100+ SAP tables with cryptic column names, in about 18 seconds.

~89%Query success rate
110SAP tables indexed
~18sNL → answer + charts
2Auto charts per query

— THE PIPELINE

SAP COLUMNS
LIKE VBELN.
USERS ASK
IN ENGLISH.

Business analysts waited hours-to-days for SAP developers to pull reports from a database of 100+ tables with cryptic column names (VBELN, KUNNR, AUART). The goal: a conversational bot that answers with a visualisation in under 30 seconds. Each schema — DDL plus five sample rows — is indexed offline into Qdrant with BGE-M3.

At query time a 5-stage pipeline runs: the LLM expands the question into schema-aware searches, a self-refinement step validates and augments the retrieved table set, a dedicated call generates SQL against the refined DDLs, and execution feeds Pandas preprocessing plus two auto-generated chart specs.

  • Query expansion. SAP names never appear in plain English — the LLM expands each question into 3-5 schema-aware searches.
  • Split the work. Table selection and SQL generation in one prompt degraded accuracy; two focused calls fixed it.
  • Tame big results. Pandas summaries + top-50 rows beat dumping everything into context; exactly two charts keep the JSON parseable.
LLAMA 3.1VLLMQDRANTBGE-M3POSTGRESQLSQLALCHEMYPANDASFASTAPI
— WANT THE FULL STORY?

LET’S
BUILD.