Databricks SQL editor

The Azure Databricks UI includes a SQL editor that you can use to write queries, collaborate with colleagues, find available data, and create visualizations. This page introduces the SQL editor and links to pages that cover each task in detail.

Open the SQL editor

To open the SQL editor in the Azure Databricks UI, click SQL Editor Icon SQL Editor in the sidebar.

The SQL editor opens to your last open query. If no query exists, or all of your queries have been explicitly closed, the SQL editor landing page opens.

What you can do with the SQL editor

Use the SQL editor to explore data and collaborate on SQL in your workspace:

  • Write and refine queries: Connect to a SQL warehouse, browse catalogs and schemas, and author SQL with autocomplete and Genie Code.
  • Run and share: Run single or multi-statement queries, share them with collaborators, and edit together in real time.
  • Explore results: Visualize, filter, download, and analyze query results.
  • Parameterize and format: Add parameter widgets and customize SQL auto-formatting.

Orientation

This section highlights key differences in the UI and explains how to find and use available features.

SQL editor with numbered callouts marking the workspace file browser, Databricks Assistant pane, code collapse arrow, command palette, code comments tool, and version history.

  1. Open the workspace file system: You can open and organize your workspace objects directly from the SQL editor.
  2. Use the integrated Genie Code: Chat with Genie Code to help you write, refine, or understand queries. Run code generated by Genie Code from the side pane.
  3. Collapse sections of code: Click the collapse arrow to the left of a code block to selectively hide and expand code sections. This can make working through large files easier.
  4. Open the command palette: The command palette includes common actions, keyboard shortcuts, custom themes, and links to help you quickly find what you need. After you open it, use the search bar to look for specific tools and shortcuts.
  5. Comment on code: Add comments to code to enhance collaboration.
  6. Review version history: Review recent changes to your query.

Work with the SQL editor

The following pages cover the primary tasks you can perform in the SQL editor:

Task Description
Write queries Connect to compute, browse data assets, and author queries.
Run and share queries Run single or multi-statement queries, share them, and edit them together in real time.
View query results Explore, visualize, download, and filter query results.
Use parameters Use named parameters and configure parameter widgets.
Custom format SQL Customize SQL auto-formatting options.
Keyboard shortcuts Reference of common keyboard shortcuts.

Copy the legacy query ID

To get the legacy query ID for a query that you migrated to the new SQL editor, copy it from the File menu. The legacy query ID can be useful for API calls or other integrations that reference it.

  1. Open the query in the new SQL editor.
  2. Click the kebab menu Kebab menu icon. at the top of the editor.
  3. Click File > Copy legacy query ID.