Adding example queries

Introduction to Databricks Genie

Gang Wang

Senior Data Scientist

Why example queries matter

mermaid: example query routing decision

Example queries are pre-written SQL

Add examples when:

  • A calculation is non-standard (e.g., Gross Margin)
  • Logic involves multiple joins across tables
  • Business-specific filters apply (e.g., "Active User" = last_login > 30 days)

Like SOPs

Introduction to Databricks Genie

Static vs parameterized examples

$$

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

Introduction to Databricks Genie

Screenshot 2026-04-17 at 10.01.05.png

Introduction to Databricks Genie

How Genie routes to examples

Routing step 1

$$

Introduction to Databricks Genie

How Genie routes to examples

Routing step 2

$$

Step 1: Genie checks your Example Queries

Introduction to Databricks Genie

How Genie routes to examples

Routing step 3

$$

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

Introduction to Databricks Genie

How Genie routes to examples

Routing step 4

$$

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

Introduction to Databricks Genie

How Genie routes to examples

Routing step 5

$$

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

Introduction to Databricks Genie

Best practices

$$

layers: Natural Language, Parameterized, Test Variations, Don't Over-Engineer

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

Let's practice!

Introduction to Databricks Genie

Preparing Video For Download...