This article describes how you can use Databricks Assistant to help you code and debug your notebooks, and provides tips on how to get the most out of the Assistant.
What can Databricks Assistant help with?âDatabricks Assistant is a context-aware AI assistant that you can interact with using a conversational interface, making you more productive inside Databricks. You can describe your task in English and let the assistant generate Python code or SQL queries, explain complex code, and automatically fix errors. The assistant uses Unity Catalog metadata to understand your tables, columns, descriptions, and popular data assets across your company to provide personalized responses.
Databricks Assistant can help you with the following tasks:
For information about enabling and using Databricks Assistant, see Enable and try Databricks Assistant. For general information about Databricks Assistant, see Databricks AI-powered features.
Assistant command shortcuts for notebooksâIn a notebook, Databricks Assistant is available in the Assistant pane or inline in a code cell.
To use Databricks Assistant directly in a code cell, press Cmd+I
on MacOS or Ctrl+I
on Windows. A text box appears in the cell. You can type a question or comment in English and then press Enter
(not Shift+Enter
, like you would to run a cell) to have Assistant generate a response.
Slash commands are a shortcut for creating common prompts.
When you use /fix
or /doc
, in the diff window select Accept to accept the proposed changes or Reject to keep the original code. If you accept the proposed code, the code does not automatically run. You can review the code before running it. If the generated code is not what you wanted, try again by adding more details or information to your comment. See Tips to improve Assistant responses.
Get detailed explanations of code snippets. Use the /explain
prompt and include terms like âbe conciseâ or âexplain code line-by-lineâ to request the level of detail that you want. You can also ask Databricks Assistant to add comments to the code.
For code autocomplete, performance may be better using the Assistant pane than in a notebook cell.
Assistant closes automatically if you Accept or Reject the code it generated.
Reference tables in prompts using@
â
To quickly reference tables in Assistant prompts, use the @
(at) symbol.
Databricks Assistant helps with code, both SQL and Python:
Edit mode applies AI-generated suggestions across multiple cells in your notebook from a single prompt.
To use edit mode:
With a notebook open, click the Assistant icon in the top right of the screen.
In the Assistant pane, click Edit at the bottom of the prompt box.
In edit mode, enter a prompt just as you would in chat mode.
Assistant analyzes your notebook and surfaces suggestions inline in the cells where changes are needed.
After generating suggestions, you can review them directly in the notebook or through the Assistant panel. Click any cell in the Assistant panel to jump to that part of the notebook.
Accept or reject edits individually, either inline in the notebook or from the Assistant panel. To apply all suggestions at once, click Accept All or Reject All.
As you type, suggestions automatically appear. Press Tab
to accept a suggestion. To manually trigger a suggestion, press Option+Shift+Space
(on macOS) or Control+Shift+Space
(on Windows).
AI-based autocomplete can also generate code from comments:
Filter data with natural language promptsâUse Databricks Assistant to filter data outputs with natural language prompts.
To filter outputs with natural language, click the Filter icon in the output table and enter a prompt. For example, as in the animated example following, you can prompt âShow me only males over 70.â
Debug code: Python and SQL examplesâTo use Databricks Assistant to fix code, do any of the following:
The tabs below show Diagnose error examples in Python and SQL code:
When you click Diagnose error, Assistant automatically runs a `/fix` prompt.
When you click Diagnose error, Assistant automatically runs /fix
.
Using the slash prompt /optimize
, evaluate and optimize Python, PySpark, and SQL code.
/optimize
, and click the Generate button.Here's how /optimize
helps with code:
CREATE TABLE CLUSTER BY AUTO
.When code returns errors, Quick Fix automatically recommends fixes for basic errors that can be fixed in a single line change.
Click Accept and run to make the recommended fix and continue running your code:
Additional informationâThe following articles contain additional information about using Databricks Assistant:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4