What you will be able to do
- Open the Databricks Assistant (Genie Code) in a notebook cell, the notebook pane, and the SQL editor, and know which compute it uses to run code
- Write queries faster by using autocomplete, natural-language prompts, @ references and well-documented Unity Catalog metadata
- Pick the right slash command (/explain, /fix, /doc, /findTables, /optimize, /prettify) for a query task
- Tell Quick Fix, Diagnose Error and /fix apart, and know which Accept button runs code and which does not
- Use /optimize's pre-run warnings, post-run analysis and table-level suggestions to improve a SQL query
Key concept
Databricks Assistant (Genie Code) — The exam guide calls it the Databricks Assistant. The current documentation pages for this feature call it Genie Code. It is a context-aware AI helper built into notebooks and the SQL editor. It reads the code you are working on and your Unity Catalog metadata, then generates, explains, fixes and optimizes queries for you to review before you run them.
1.Where the assistant lives: notebooks and the SQL editor
The exam guide asks you to use the Databricks Assistant "within a Notebook or SQL Editor". The documentation pages for this feature now use the name Genie Code, so expect to see both names. The tool does the same jobs in both places. It generates SQL or Python from plain-English requests, explains code, debugs errors, and transforms, optimizes or refactors existing code. What changes from one surface to the other is how you open it.
In a notebook you can reach the assistant in two ways: the Genie Code pane at the side, or inline inside a code cell. To work inline, press Cmd+I (macOS) or Ctrl+I (Windows). A text box appears in the cell. Type your request and press Enter, not Shift+Enter. In a notebook, Shift+Enter runs the cell, so pressing it here would not send your prompt to the assistant. You can also mention Genie Code in a notebook comment to get help in that comment thread.
In the SQL editor the assistant is a chat window you open from the Genie Code icon. The write-queries page describes the left pane as the place to find workspace files, browse data objects and get help from Genie Code. It also says to click the Genie Code icon on the right side of the editor for inline help while you write. In both cases you can click a suggested question or type your own. The SQL editor overview lists the integrated assistant as a key feature: you chat with it to write, refine or understand queries, and you can run its code straight from the side pane.
Which compute runs that code? By default Genie Code uses serverless compute. But the notebook and the SQL editor already have compute attached, and on a page like that Genie Code uses the attached compute instead. If you don't have serverless access, you need some other compute available before you can run code from the Genie Code panel.
Checkpoint 1 of 9· Check yourself
An analyst has a SQL editor tab attached to a running SQL warehouse. They ask the Databricks Assistant (Genie Code) to write a query and run it from the side pane. Which compute runs the query?
Serverless is only the fallback. When the page already has compute selected, as a notebook or the SQL editor does, Genie Code uses that compute.
“already has a compute resource selected (for example, notebooks or the SQL editor), Genie Code automatically uses that compute instead.”Source: docs.databricks.com
2.Writing queries: autocomplete, prompts and context
The lightest form of help is AI-based autocomplete, which works in notebooks, the SQL editor and the file editor. Suggestions appear as you type, and Tab accepts one. To ask for a suggestion yourself, press Option+Shift+Space on macOS or Control+Shift+Space on Windows. Autocomplete can also generate code from a comment, so a line such as a comment describing the query you want can become the query. The docs add that autocomplete may perform better in the Genie Code pane than in a notebook cell.
For whole queries you describe the result you want in plain English. This works because Genie Code doesn't only see your words. The docs list the context it uses:
| Context source | How it helps query writing |
|---|---|
| Code or queries in the current notebook cell or Databricks SQL editor tab | Lets it explain, fix or extend what you have already written |
| Table and Column names and descriptions | Lets it map plain-English terms, such as a State column, to real identifiers |
| Previous prompt questions | Lets you refine a previous answer without rewriting the whole prompt |
| Favorite and active tables | Points it toward the data you are actually working with |
| The stack trace from the error output (diagnose error feature) | Gives it the failure details it needs to propose a fix |
You can also add context on purpose. Type @ followed by a resource name, such as @<table-name>, or click Add context to attach tables, queries, notebooks or files. Every item you attach stays listed at the top of the prompt box for the rest of the chat. In notebooks, @cell lets you point at a particular cell's code or output. To find data you don't know yet, ask "Find tables" or use /findTables.
Two habits make the generated SQL more accurate. First, give it a starting query. If the assistant has already seen a statement that selects from a table, it can read the column names instead of guessing them. The SQL editor documentation includes a sample query that does this job:
SELECT
o_orderdate,
o_orderkey,
o_custkey,
o_totalprice,
o_shippriority
FROM
samples.tpch.ordersSecond, document your tables and columns in Unity Catalog. The docs give the example of a height column stored as a string like '6-2'. A comment that explains this format tells the assistant how to read the values. Finally, be specific about what you want back, such as the level of detail, the structure of the answer, or which library to use. The same prompt can produce differently structured answers from one try to the next.
Checkpoint 2 of 9· Check yourself
Why does giving Genie Code a starting query such as a SELECT statement from a table make its generated SQL more accurate?
A starting query shows the assistant the real column names, so it builds on them instead of guessing.
“This allows Genie Code to get the column names and not have to guess.”Source: docs.databricks.com
Genie Code reads table and column names and descriptions as part of its context. A comment that explains a column's format, or gives a line of sample data, lets it read and filter that column correctly without you repeating the explanation in every prompt.
3.Slash commands: shortcuts for common query tasks
Many requests come up again and again, so they have slash commands, which are shortcuts that start a common prompt. Typing just / shows the list. These are the commands an analyst uses when writing and tidying queries:
| Command | What Genie Code does |
|---|---|
| /explain | Provides an explanation of the code in a cell |
| /doc | Comments the code in a diff view |
| /fix | Proposes a fix to any code errors in a diff view |
| /findTables | Searches for relevant tables based on Unity Catalog metadata |
| /findQueries | Searches for relevant queries based on Unity Catalog metadata |
| /optimize | Suggests performance improvements for SQL queries |
| /prettify | Formats SQL queries for readability |
You can control how much detail /explain gives by adding a phrase such as "be concise" or "explain code line-by-line". Notice that /fix and /doc do not edit your code directly. Each one shows its proposal in a diff view, where you choose Accept or Reject. The next section explains what Accept does and doesn't do.
Checkpoint 3 of 9· Match them up
Match each slash command to the task an analyst would use it for
Tap a term, then the definition that fits it.
Each command is a shortcut for one common prompt. Formatting, finding tables, explaining and commenting are separate commands.
“Formats SQL queries for readability.”Source: docs.databricks.com
Checkpoint 4 of 9· Exam question
A data analyst is writing a query in the Databricks SQL editor and introduces a trailing comma before the `FROM` clause. Genie Code (the assistant formerly named Databricks Assistant) underlines the line and offers a one-click correction that the analyst can accept and immediately rerun. Which Genie Code capability is behaving this way?
Correct answer: A — Quick Fix, which flags common single-line issues like trailing commas or mistyped names and lets the analyst accept the correction and rerun the query immediately.
- A. This describes Quick Fix, which is designed to catch common single-line mistakes like trailing commas, mistyped identifiers, or missing `GROUP BY` clauses and surface an inline correction the analyst can accept and run immediately, matching the scenario.
- B. This behavior handles deeper, multi-cause failures rather than a simple one-line syntax slip, and it works by triggering a fix request under the hood instead of surfacing an instant one-click correction, so it does not match a trailing-comma typo.
- C. This capability targets query performance rather than syntax correctness, so it would not be the feature that flags and offers to correct a malformed clause.
- D. This capability summarizes query logic in prose and leaves the code untouched, so it would not be the source of an inline syntax correction the analyst can accept and run.
Sources1
4.Debugging: Quick Fix, Diagnose Error and /fix
When a query fails, the assistant offers help at three levels. Each one fits a different kind of error, and the exam expects you to tell them apart.
Quick Fix appears on its own when an error is simple, meaning one that a single-line change can fix, such as a misspelled column name. You don't need to ask for it. Diagnose Error is a button that appears in the cell results when an error occurs. The features page says it analyzes more complex errors and attempts to fix them. Behind the scenes, clicking it just runs /fix. You can also describe the problem in the Genie Code pane, or click Debug to step through code line by line with breakpoints.
The difference is in the buttons. A Quick Fix offers Accept and run, which applies the one-line change and continues running your code. A /fix (or /doc) proposal shows up in a diff window with Accept and Reject. Accept writes the proposal into your code but does not run it, so you get a chance to review it first. If the proposal is wrong, try again with more detail in your prompt. The assistant closes automatically after you accept or reject.
| Feature | When it applies | What accepting does |
|---|---|---|
| Quick Fix | Basic errors that can be fixed in a single-line change; it appears automatically | Accept and run applies the fix and continues running your code |
| Diagnose Error | Button in the cell results when an error occurs; for more complex errors | Runs /fix, so the proposal arrives in a diff view |
| /fix | You type it, or Diagnose Error triggers it | Accept changes the code but does not run it |
One more difference matters if your team customizes the assistant. Custom user or workspace instructions, such as coding conventions, apply to almost every response, including chat, inline suggestions and Suggest Fix. They do not apply to Quick Fix or Autocomplete.
Checkpoint 5 of 9· Check yourself
A SQL cell fails with a long, multi-part error. No single-line Quick Fix is offered. The analyst clicks the Diagnose Error button in the cell results. What happens?
Diagnose Error is a shortcut for /fix, which proposes the change in a diff view for you to accept or reject. Debug is a separate button for stepping through code.
“When you click Diagnose error, Genie Code automatically runs /fix.”Source: docs.databricks.com
Checkpoint 6 of 9· Exam question
In a notebook cell, a query fails with an error that Genie Code identifies as caused by a misconfigured cluster environment rather than a simple typo. The analyst clicks a button labeled "Diagnose error" to investigate further. What happens when the analyst does this?
Correct answer: B — Genie Code analyzes the complex failure, including possible environment causes, and automatically runs `/fix` on the analyst's behalf to propose a resolution.
- A. Diagnose error investigates and proposes a fix immediately rather than pausing the cell and deferring the retry to a later scheduled run.
- B. Diagnose error is built to reason about complex failures, including environment problems, and it triggers a `/fix` request automatically so a proposed resolution is presented to the analyst, which matches this behavior.
- C. Genie Code shows proposed fixes in a diff view for the analyst to review rather than silently editing and rerunning code without any visibility into the change.
- D. Diagnose error works within the editor to analyze and propose a code-level fix; it does not file tickets with workspace administrators on the analyst's behalf.
5.Optimizing queries with /optimize
A query can be correct and still be slow. The /optimize command evaluates code and suggests performance improvements. The SQL editor documentation names it specifically as the way to ask Genie Code to evaluate and optimize queries. To use it explicitly, open Genie Code from a notebook cell or the SQL editor, type /optimize, click Generate, and click Accept to apply the suggestions.
Checkpoint 7 of 9· Put it in order
Put the steps for running /optimize on a query in order
- 1.In a notebook cell or the SQL editor, click the Genie Code icon
- 2.To use the optimization suggestions from Genie Code, click Accept
- 3.In the prompt box, type /optimize, and click the Generate button
You open the assistant, generate suggestions with /optimize, and then accept them. Nothing changes in your code until you click Accept.
“In the prompt box, type /optimize, and click the Generate button.”Source: docs.databricks.com
/optimize also helps at three points that don't need a typed prompt:
| Mode | When | What you see |
|---|---|---|
| Pre-run warnings | Before execution | Yellow underlines, for example when you are not filtering on a partition column; hover to see the suggestion |
| Post-run analysis | After you run the code | An Optimize button to click |
| Table-level suggestions | When you create a table | A hint recommending CREATE TABLE CLUSTER BY AUTO |
Checkpoint 8 of 9· Exam question
An analyst notices a query against a large fact table is taking much longer than expected to return results in the SQL editor. The query is syntactically correct and produces the right output, but it runs slowly. The analyst highlights the query and asks Genie Code for help making it run faster. Which Genie Code feature should the analyst use?
Correct answer: C — The `/optimize` command, which evaluates the selected SQL query and suggests specific changes aimed at improving its execution performance on the warehouse.
- A. This feature adds explanatory comments for readability, which does not affect how fast the query executes.
- B. This feature produces a prose summary of the query's logic and leaves the query unchanged, so it would not address a performance problem.
- C. This slash command is designed to evaluate and optimize the performance of selected SQL or code, which is exactly the goal when a correct query runs too slowly.
- D. This feature targets syntax-level mistakes rather than a query that already runs correctly but too slowly, so it would not change execution performance.
Sources1
6.Reviewing what the assistant produces
Everything above ends with you making the decision. Databricks says to review generated code before you run it, because the assistant can make mistakes. That is why the diff view requires an Accept, and why accepted /fix code does not run on its own. The assistant is also limited to what you are allowed to do. It works within your Unity Catalog permissions, so it cannot read data or run operations that you couldn't.
Genie Code runs in Agent mode. In this mode it can plan multi-step work, run code and fix errors on its own. Genie Code asks for your permission before running code in the chat. Approval modes control how often it asks. Auto-approve is the default for first-time users, and an AI classifier checks each action against your request. If you only want an explanation, say so in the prompt, for example "Just explain this to me, don't run any code."
Checkpoint 9 of 9· Check yourself
Which statement about queries generated by the Databricks Assistant (Genie Code) is accurate?
The documentation tells you to review generated code before running it. Access is limited to your own Unity Catalog permissions, and auto-approve is explicitly not a security control.
“Databricks recommends that you always review any code generated by Genie Code before running it, because it can sometimes make mistakes.”Source: docs.databricks.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Clicking Accept on a /fix or /doc suggestion re-runs the cell with the corrected code.Why is that wrong?
The diff-view Accept only puts the proposed code in place. It does not run it, so you review it and run it yourself. Only Quick Fix's "Accept and run" continues running your code.
2.Quick Fix is the tool for any query error, including complex multi-part failures.Why is that wrong?
Quick Fix only covers basic errors that a single-line change can fix. For more complex errors, use Diagnose Error, which runs /fix.
3.After typing a prompt into the inline Cmd+I box in a notebook cell, press Shift+Enter to submit it.Why is that wrong?
Press Enter to have Genie Code generate a response. Shift+Enter is the shortcut for running a cell.
Covered in Where the assistant lives: notebooks and the SQL editor
4.Custom workspace instructions, such as naming conventions, shape every Genie Code suggestion, including Quick Fix and Autocomplete.Why is that wrong?
Instructions apply to chat, inline suggestions and Suggest Fix, but Quick Fix and Autocomplete are the exceptions.
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“To use Genie Code directly in a code cell, press Cmd+I on MacOS or Ctrl+I on Windows.”
↩︎ Where the assistant lives: notebooks and the SQL editor“As you type, suggestions automatically appear. Press Tab to accept a suggestion.”
↩︎ Writing queries: autocomplete, prompts and context“Slash commands are a shortcut for creating common prompts.”
↩︎ Slash commands: shortcuts for common query tasks“Click Accept and run to make the recommended fix and continue running your code”
↩︎ Debugging: Quick Fix, Diagnose Error and /fix“Pre-run warnings: Yellow underlines highlight opportunities to optimize your query before execution, such as when you are not filtering on a partition column.”
↩︎ Optimizing queries with /optimize“Table-level suggestions: For example, when users create a table, they receive a hint recommending CREATE TABLE CLUSTER BY AUTO.”
↩︎ Optimizing queries with /optimize“Genie Code uses Unity Catalog metadata to understand your tables, columns, descriptions, and popular data assets across your company and provide personalized responses.”
↩︎ Key concept“If you accept the proposed code, the code does not automatically run.”
↩︎ Exam trap 1“When code returns errors, Quick Fix automatically recommends fixes for basic errors that can be fixed in a single-line change.”
↩︎ Exam trap 2“press Enter (not Shift+Enter, like you would to run a cell) to have Genie Code generate a response.”
↩︎ Exam trap 3“already has a compute resource selected (for example, notebooks or the SQL editor), Genie Code automatically uses that compute instead.”
↩︎ Checkpoint“Formats SQL queries for readability.”
↩︎ Checkpoint“If you accept the proposed code, the code does not automatically run.”
↩︎ Prediction“When you click Diagnose error, Genie Code automatically runs /fix.”
↩︎ Checkpoint“In the prompt box, type /optimize, and click the Generate button.”
↩︎ Checkpoint - 2.
“Use the left pane in the SQL editor to find workspace files, view data objects, and get help from Genie Code.”
↩︎ Where the assistant lives: notebooks and the SQL editor“Click the Genie Code icon on the right side of the editor to get inline help and suggestions when writing queries.”
↩︎ Where the assistant lives: notebooks and the SQL editor - 3.
“Chat with Genie Code to help you write, refine, or understand queries. Run code generated by Genie Code from the side pane.”
↩︎ Where the assistant lives: notebooks and the SQL editor - 4.https://docs.databricks.com/aws/en/genie-code/tipsOfficial docs
“Code or queries in the current notebook cell or Databricks SQL editor tab.”
↩︎ Writing queries: autocomplete, prompts and context“This allows Genie Code to get the column names and not have to guess.”
↩︎ Writing queries: autocomplete, prompts and context“you can ask Genie Code to alter the output of a previous response without having to rewrite the entire prompt.”
↩︎ Writing queries: autocomplete, prompts and context“Genie Code asks for your permission before running code in the chat.”
↩︎ Reviewing what the assistant produces - 5.
“Diagnose error Genie Code analyzes more complex errors, including environment errors, and attempts to fix them.”
↩︎ Debugging: Quick Fix, Diagnose Error and /fix“Databricks recommends that you always review any code generated by Genie Code before running it, because it can sometimes make mistakes.”
↩︎ Checkpoint - 6.https://docs.databricks.com/aws/en/genie-codeOfficial docs
“Genie Code is governed by your Unity Catalog permissions, so it can only access data and perform operations that you have permissions for.”
↩︎ Reviewing what the assistant produces - 7.
“Auto-approve is a productivity feature, not a security boundary.”
↩︎ Reviewing what the assistant produces
Also cited
“With the exception of Quick Fix and Autocomplete, Genie Code applies instructions to every response it generates”
↩︎ Exam trap 4