top of page

How to query Databricks tables with Genie Agents and verify the SQL

2 minutes ago
8 min read
Cover with the title How to query Databricks tables with Genie Agents and verify the SQL over a teal city skyline at night, Data Studios original cover

Genie Agents let analysts and business users ask questions about Unity Catalog tables in plain English and get back a written answer, a result table, an automatic chart when one is useful, and the SQL that produced the result. Databricks renamed the feature recently: its documentation now states that Genie Agents were formerly known as Genie spaces, and the product sits in a family that also includes Genie One for business users and Genie Code for developers. The workflow for data teams is the same as before, with a curated agent built on a small set of tables and a chat window where people ask questions.


The practical risk is familiar to anyone who has used a text-to-SQL tool. The answer arrives quickly and reads well, but the generated query can include returned orders that finance excludes, read a fiscal quarter as a calendar quarter, or miss a boundary date. The steps below follow the official Databricks documentation as verified on November 23, 2026, and pair them with a small illustrative dataset whose correct answers were computed in Python and SQL, so each result Genie returns can be checked line by line before anyone shares it.


··········


GENIE AGENTS REQUIREMENTS IN DATABRICKS.


The setup page lists the technical requirements in direct terms. Genie Agents require a pro or serverless SQL warehouse, with serverless recommended for performance, and every table, view or metric view the agent uses must be registered in Unity Catalog. Genie also depends on the partner-powered AI features setting, which must be enabled at the account and workspace levels. When that setting is off, users with the Databricks SQL entitlement can still see the Genie Agents icon in the sidebar, but they cannot open any agent.


Permissions are split between the people who build an agent and the people who use it. A creator needs the Databricks SQL workspace entitlement, CAN USE on a pro or serverless warehouse, SELECT on the data and at least CAN EDIT on the agent. A consumer needs the consumer access or Databricks SQL entitlement, SELECT on every Unity Catalog object the agent uses and at least CAN VIEW or CAN RUN on the agent. Consumers do not need warehouse permissions, because the creator's compute credentials are embedded in the agent, while data access is still evaluated against each user's own Unity Catalog permissions.


........


Item

Documented requirement or limit

Compute

Pro or serverless SQL warehouse

Data

Registered in Unity Catalog

Tables per agent

Up to 50 tables, views or metric views

Recommended scope

Five or fewer tables

Instructions

100 per agent

Benchmarks

Up to 500 questions

Workspace setting

Partner-powered AI features enabled


........


On cost, the Genie documentation states that Genie One and Genie Agents usage by users is free through January 31, 2027, and that service principals are excluded from that promotion and billed for their usage. The Genie budgets page adds that compute used to run queries, such as a SQL warehouse, is billed separately and is not part of Genie budgets, so every question still consumes warehouse time. The current per-DBU rates for warehouses are covered in our breakdown of Azure Databricks pricing for Serverless SQL and warehouse sizes.


··········


CREATING A GENIE AGENT ON A UNITY CATALOG TABLE.


The documented path starts with Genie Agents in the workspace sidebar. Clicking New in the upper-right corner opens a dialog where you choose the data sources, and Create builds the agent. Genie Code then launches automatically and suggests table descriptions and example queries, which you can accept, edit or discard. Additional tables are added under Configure, then Data, then Add.


Accuracy depends far more on configuration than on the wording of the questions. The best-practices page describes Genie as a new data analyst who needs context, and it ranks the tools in a clear order. SQL expressions and example SQL queries come first, clear table and column descriptions come next, and free-text instructions should be used only as a last resort. SQL expressions are added under Configure, then Examples, then Add, where you choose Filter, Measure or Field. Column descriptions and synonyms are edited from Configure, then Sources, using the pencil icon, and the sample questions shown to users go under Configure, then Settings, in Common questions.


For the example in the next section, two definitions do most of the work. A filter named for valid orders captures the rule that returned orders never count as revenue, and a short general instruction explains the fiscal calendar.


Filter (name: valid orders)
is_returned = 0

General instruction
Our fiscal year starts on July 1. Fiscal Q1 2027 runs from
2026-07-01 to 2026-09-30. Revenue always means net revenue
and excludes rows where is_returned = 1.

The documentation counts each example SQL query, each SQL function and the whole general-instructions block as one instruction toward the limit of 100 per agent, so a handful of precise definitions is preferable to long prose.


··········


WORKED EXAMPLE: ASKING GENIE ABOUT QUARTERLY REVENUE.


The dataset below is illustrative and was built to test the most common errors. It holds twelve orders, including two returned orders inside the quarter and two orders that fall just outside it, on June 28 and October 1.


........


order_id

order_date

region

product_category

revenue

is_returned

1001

2026-06-28

West

Software

1200.00

0

1002

2026-07-03

West

Hardware

850.00

0

1003

2026-07-15

East

Software

2400.00

0

1004

2026-07-22

Central

Services

600.00

1

1005

2026-08-05

East

Hardware

1150.00

0

1006

2026-08-19

Central

Software

1800.00

0

1007

2026-08-30

West

Services

950.00

0

1008

2026-09-09

East

Services

700.00

1

1009

2026-09-17

Central

Hardware

1300.00

0

1010

2026-09-30

West

Software

2100.00

0

1011

2026-10-01

East

Software

1600.00

0

1012

2026-09-24

East

Software

900.00

0


........


Two questions cover the typical analyst request. The first asks for a regional breakdown, and the second uses the company's fiscal calendar.


Question 1
What was net revenue by region in Q3 2026?

Question 2
How many orders and how much net revenue did we have
in fiscal Q1 2027?

The correct query for the first question filters on the calendar quarter with a closed start date and an open end date, excludes returns and groups by region. It was executed locally on the illustrative table and uses standard SQL that also runs in Databricks SQL.


SELECT region,
       SUM(revenue) AS net_revenue
FROM orders
WHERE order_date >= '2026-07-01'
  AND order_date < '2026-10-01'
  AND is_returned = 0
GROUP BY region
ORDER BY net_revenue DESC;

........


Region

Correct net revenue

Result if returns are included

East

4,450.00

5,150.00

West

3,900.00

3,900.00

Central

3,100.00

3,700.00

Total

11,450.00

12,750.00


........


The quarter contains ten orders, two of them returned for a combined 1,300.00, which explains the gap between the two totals. If Genie's table shows 5,150.00 for East or 3,700.00 for Central, the generated SQL ignored the return flag, and the valid-orders filter was either missing or not matched. If the total includes 1,200.00 from order 1001 or 1,600.00 from order 1011, the date range is wrong at one of the edges.


For the second question the correct answer is 8 orders and 11,450.00 of net revenue, because fiscal Q1 2027 covers the same July to September window. A model that reads the phrase as calendar Q1 2027 filters on January to March 2027 and returns zero orders and an empty revenue figure on this table, which looks like missing data rather than a misreading. The Databricks tuning guidance lists calendar versus fiscal quarters among the cases that need explicit instructions or SQL expressions, which is why the fiscal rule belongs in the agent configuration and not in each user's question.


SELECT COUNT(*) AS orders,
       SUM(revenue) AS net_revenue
FROM orders
WHERE order_date >= '2026-07-01'
  AND order_date < '2026-10-01'
  AND is_returned = 0;

The same expected results can be produced in pandas with a filter on the date range and the return flag followed by a group-by on region, which gives analysts a second, independent check outside Databricks.


··········


READING AND CHECKING THE SQL THAT GENIE GENERATES.


According to the documentation on talking to Genie, a response can include a natural-language summary, a result table, an automatic visualization, an Applied filters list and an expandable Analysis section that shows how Genie understood the question, which data it found relevant and which SQL example it referenced. Show code reveals the generated query, and in the conversation history the same control is labeled Show generated code, with a Run option to execute it again.


A review routine that takes a minute per answer catches most problems:


........


Check in the generated SQL

What to look for in this example

Date range

Start 2026-07-01 inclusive, end before 2026-10-01

Business filters

is_returned = 0 present

Grouping

One row per region, three regions

Totals

Region values add up to 11,450.00

Referenced example

Valid-orders filter or a trusted query cited


........


The feedback controls matter for the agent owner. Users can mark an answer with Yes, choose Fix it to explain what was wrong and resubmit, or use Request review to send the exchange to the agent's managers, who see feedback with CAN MANAGE permission. The documentation is explicit that Genie does not automatically learn or change its behavior in response to feedback, so a wrong answer is fixed only when an editor adds or corrects a SQL expression, an example query or a description.


For recurring questions, trusted assets give stronger guarantees. Parameterized example SQL queries and Unity Catalog SQL functions count as trusted assets, and answers produced from them are labeled as verified in the response. Benchmarks are the systematic test, with up to 500 benchmark questions per agent, each paired with a SQL answer, and the guidance recommends two to four phrasings of each question. In Chat mode a benchmark result is scored by comparing result sets of up to 5,000 rows. Teams that already use BigQuery will recognize the same review pattern from our guide on how to use BigQuery conversational analytics and check the SQL.


··········


GENIE AGENTS GOVERNANCE AND DATA HANDLING.


Databricks documents that data access is always evaluated using each end user's own Unity Catalog permissions, and that row filters and column masks are applied per user automatically. A question about data a user cannot access produces an empty response. Hiding a column in the agent changes what Genie considers when writing SQL, but the documentation notes that it does not affect the underlying data or Unity Catalog permissions, so hiding is a quality tool and never a security control.


The Databricks AI trust page lists what Genie Agents send to the model: the natural-language prompt, table names and descriptions, relevant values, general instructions, example SQL queries and SQL functions. It states that Databricks does not use data, prompts or responses from these features to train generative foundation models it makes available to third parties, and that partner-powered features use zero data retention endpoints from the model partners. Genie Agents are designed with read-only access, so they generate and run read-only SQL. With partner-powered features enabled, the documentation names Azure OpenAI service, OpenAI on Databricks and Anthropic on Databricks as model providers, and regional processing depends on the workspace region and the cross-geography setting.


Rollout is moving beyond the Databricks interface, with Genie apps for Slack and Microsoft Teams now generally available, and Genie Agents can also answer from documents in Unity Catalog volumes in a public preview that covers PDFs and slides. Every new entry point puts more generated answers in front of business users, which raises the value of benchmarks and trusted assets set up in advance.


··········


DATABRICKS GENIE AGENTS: WHAT TO CONFIRM BEFORE SHARING ANSWERS.


The documented facts are stable enough to plan around. Genie Agents need a pro or serverless SQL warehouse, Unity Catalog tables, the partner-powered AI features setting and SELECT permissions for every user, and an agent can hold up to 50 tables, views or metric views, with five or fewer recommended. User questions are free through January 31, 2027, service principals are billed, and warehouse compute is billed separately.


What varies by workspace is the quality of the configuration. On the illustrative table, a correct agent returns 4,450.00 for East, 3,900.00 for West, 3,100.00 for Central and 8 orders worth 11,450.00 for fiscal Q1 2027, while a poorly configured one can produce 12,750.00 by counting returns or zero by reading the fiscal quarter as a calendar one. A valid-orders filter, a fiscal-calendar instruction and a set of benchmark questions with known answers are the controls that separate the two outcomes, and the generated SQL behind Show code remains the place where every figure should be confirmed before it reaches a report.


··········


FOLLOW US FOR MORE.


·····


DATA STUDIOS


·····


datastudios.org


bottom of page