a week ago - last edited a week ago
Retailers run hundreds of trade promotions every month across many stores and SKUs. Discounts, buy one get one offers, and bundle deals are expensive levers, and most teams still evaluate them in silos. A category manager asking a simple business question usually waits days for an analyst to write SQL, reconcile numbers across spreadsheets, and produce a report that is already stale by the time it arrives.
Three blind spots make this worse:
TPO Genie turns this from a slow, analyst gated workflow into a conversation. A category manager types a question in plain English and gets a data backed answer inside the app in seconds, with the exact SQL and the underlying rows shown, never invented.
The synthetic scenario models a retailer we call Company X, an Indian grocery and general retail chain, benchmarked against seven real world competitors: Walmart, DMart, Reliance Retail, Amazon, Flipkart, Blinkit, and Zepto.
The app is designed around three personas:
The contest asks one central question: if Genie were removed, would the main experience change significantly? For TPO Genie the answer is yes. Genie is the primary interface and the reasoning engine, not a side feature.
The main screen, Ask Genie, is a conversational assistant. Every answer is generated by the Databricks Genie Agent and grounded in audited Unity Catalog views. The app shows three things for each answer:
If Genie is removed, there is no answer engine, no natural language to SQL, and no grounded response. The dashboards would remain as static charts, but the product itself, the thing that takes a manager from a question to a certified answer, would be gone.
To make Genie do more than a single query, the assistant exposes three modes:
The Genie Space is configured for enterprise grade grounding:
The routing behaves like this:
| How did promo X perform? | Queries mv_promo_performance and mv_margin_performance |
| Did it cannibalize nearby products? | Uses mv_cannibalization and mv_substitute_network |
| How do we price versus DMart or Blinkit? | Uses mv_competitor_landscape |
| Did rain or competitors or a stockout hurt sales? | Uses mv_external_factors |
| What if I run 15 percent off on SKU X? | Calls predict_promo_impact(...) |
TPO Genie is a full stack Databricks App. The data layer, the semantic layer, the model, the Genie Space, and the web app all run inside one Free Edition workspace.
Instead of a GPU trained graph neural network, which Free Edition cannot serve, we built a governed property graph that delivers the same relational intelligence and reinforces Genie grounding:
Two Gold views sit on top of the graph. mv_substitute_network answers what products compete with a given SKU, and mv_cannibalization answers whether a promotion stole sales from its substitutes during the promo window. These are the views Genie uses for cannibalization questions.
predict_promo_impact(sku_id, store_id, mechanic, discount_pct) is a Unity Catalog SQL table valued function. It returns predicted lift percentage, a cannibalization risk score, and net margin delta. The logic is grounded in each SKU's elasticity, the mechanic response, and the number of substitute edges in the graph. Because it is a native SQL function, Genie can call it inline and it runs on Free Edition with no model serving endpoint required.
To justify the design, we also trained a LightGBM regressor on the synthetic promo response labels and tracked it with MLflow. The model is the evidence that the elasticity and mechanic relationships are real and learnable, and the SQL function is the deployable inference path.
The app is a single deployable unit:
Demo Video: https://drive.google.com/file/d/121d-Al3YCj_l8doGeXAzEjwN84TrjKB7/view?usp=drivesdk
The four screens are:
Every technology used in the build:
We built a 15 question ground truth evaluation set covering historical performance, cannibalization, competitor pricing, external factor attribution, and forward looking simulation. Each question is scored on whether the answer routes to the correct view or function and whether the numbers are consistent. The evaluation checks for the red flags that matter most: invented figures, the wrong margin definition, estimating a prediction by hand instead of calling the function, and ignoring named competitors or substitutes.
Groundedness is enforced structurally, not just by prompting. Genie can only see the Gold views and the function, every column is documented, and the app displays the generated SQL and the returned rows next to every answer, so a reviewer can verify each number.
Building on Free Edition forced good engineering decisions and produced several concrete lessons.
Match the model to the platform. The original design called for a GPU trained GraphSAGE graph neural network. Free Edition has no GPU serving, and a heavy model would have earned little against a contest that scores Genie centrality. Replacing it with a governed knowledge graph plus a CPU LightGBM benchmark gave the same relational story, a stronger Genie grounding narrative, and a design that actually deploys.
Loading 10 million rows on a serverless driver needs care. Converting a 10 million row Python list to a Spark DataFrame in one call overflows the driver. We fixed this with chunked writes, an explicit schema for the large table, and a resumable loader that skips tables already populated.
Schema inference will fight you. Synthetic generators emit an integer in one row and a float in another for the same column, for example a discount of 0 versus 0.15. Spark refuses to merge Long and Double. We wrote a small schema inference helper that scans each column and widens the type once, so Spark never has to merge conflicting types.
Genie tools must return a table. A scalar function that returns a struct is rejected by the Add SQL Functions dialog. Rewriting predict_promo_impact to a table valued function that returns one row made it selectable as a Genie tool.
Mock to real wiring is a real task. The prototype looked complete but the chat never called Genie and the dashboards read from a local mock file. Productionizing meant wiring the frontend to real endpoints, adding a SQL execution helper, and gating every screen behind a real query with a mock fallback, so the app degrades gracefully instead of failing.
Honesty in fallback. Foundation Model and Agent serving can be limited on Free Edition. The Reasoning and Deep Research modes run with a realistic canned trace when serving is unavailable, and the real serving call is already wired behind a flag, so the demo never breaks and the production path is clear.
TPO Genie shows that a governed semantic layer plus Genie can turn trade promotion analysis from a slow analyst workflow into a fast, trustworthy conversation, entirely on Databricks Free Edition.
a week ago
Intersting!