A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.databricks.com/aws/en/notebooks/code-assistant below:

Get coding help from Databricks Assistant

Get coding help from Databricks Assistant

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.

Use slash commands for prompts​

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.

Get help with code​

Databricks Assistant helps with code, both SQL and Python:

Edit mode for suggestions across multiple notebook cells​

Edit mode applies AI-generated suggestions across multiple cells in your notebook from a single prompt.

To use edit mode:

  1. With a notebook open, click the Assistant icon in the top right of the screen.

  2. In the Assistant pane, click Edit at the bottom of the prompt box.

  3. 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.

  4. 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.

  5. 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.

Get inline code suggestions: Python and SQL examples​

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.

Optimize Python, PySpark, and SQL code​

Using the slash prompt /optimize, evaluate and optimize Python, PySpark, and SQL code.

  1. In a notebook cell or the SQL editor, click the Assistant icon.
  2. In the prompt box, type /optimize, and click the Generate button.
  3. To use the optimization suggestions from Assistant, click Accept.

Here's how /optimize helps with code:

Quick Fix​

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