Introduction to Databricks Genie
Gang Wang
Senior Data Scientist

Example queries are pre-written SQL
Add examples when:
last_login > 30 days)Like SOPs
$$
Static example
"Total sales in Q4 2024?"
SELECT SUM(amount)
FROM sales_transactions
WHERE quarter = 'Q4 2024'
Fixed business fact, one-time reference
$$
Parameterized example
"Sales in {{city}}"
SELECT SUM(amount)
Same logic, values change - London, Paris, Tokyo


$$

$$
Step 1: Genie checks your Example Queries

$$
Step 2: Finds match: "Sales for [Product] in [Location]"

$$
Step 3: Populates "New York" and "muffins" into your verified SQL template

$$
Result: 100% accurate answer from YOUR code, not AI guesswork
$$

Good vs. bad examples
| Good | Anti-Pattern |
|---|---|
| Focused, documented, common business terms | SELECT * (teaches nothing) |
| Complex join or calculated field (e.g., Gross Margin) | Easy queries like SELECT count(*) (clutters system) |
| Business rule enforcement (e.g., approved coffee suppliers) | One example per trivial question |
Introduction to Databricks Genie