SQL Editor & SQL Warehouses
Databricks · Databricks SQL & BI
Theory
Databricks SQL is the analytics side of the platform. You write queries in the SQL Editor and run them on a SQL warehouse, a compute resource built only for SQL. Warehouses come in serverless, pro and classic types. Serverless starts in seconds, scales automatically and is what Databricks recommends; pro and classic run in your cloud account. All of them use the Photon engine. A warehouse has a size (the cluster size, from 2X-Small upward), a scaling range for concurrency, and an auto stop time so it shuts down when idle. The editor gives you a catalog browser, autocomplete, multiple result tabs, visualizations, and Genie Code for help writing or fixing SQL.
Example: Karan opens SQL Editor, picks Serverless Starter Warehouse, sets the context to main.sales and runs a query that totals orders by region.
Why we use it
Analysts need fast, concurrent SQL without managing Spark clusters. SQL warehouses are tuned for BI-style queries, scale with users and stop when idle, and the editor gives one place to write, save and share SQL on governed Unity Catalog data.
When to use it
Use a SQL warehouse for ad-hoc SQL, dashboards, Genie and BI tools like Power BI. Use notebooks on general compute for Python, ML or complex Spark jobs. Choose serverless where available; scale up size for slow complex queries and raise max clusters for many concurrent users.
How it works
- Open SQL Editor
- Pick a SQL warehouse (it starts if stopped)
- Set the default catalog and schema, e.g. main.sales
- Write the query; use autocomplete and Genie Code for help
- Is the query slow? Yes: Check the query profile, then size up or optimize the table. No: Save it and share.
- Add a visualization or use it in a dashboard
Syntax
UI: SQL Editor → choose warehouse → set catalog.schema → write query → Run (Ctrl/Cmd + Enter)
UI: SQL Warehouses → Create SQL warehouse → Name, Cluster size, Auto stop, Scaling (min/max), Type
SQL: USE CATALOG main; USE SCHEMA sales;Example
USE CATALOG main;
USE SCHEMA sales;
SELECT region,
SUM(amount) AS total_sales,
COUNT(*) AS orders
FROM orders
WHERE order_date >= '2026-10-01'
GROUP BY region
ORDER BY total_sales DESC;
-- Parameterised version for dashboards and reuse
SELECT region, SUM(amount) AS total_sales
FROM main.sales.orders
WHERE order_date BETWEEN :start_date AND :end_date
GROUP BY region;Key points
- SQL warehouses run SQL only; all types use Photon
- Serverless is recommended: fast start, autoscaling, no cloud setup
- Cluster size = speed for each query; max clusters = concurrency
- Auto stop shuts the warehouse when idle so you stop paying
- Named parameters like :start_date turn into input boxes in the editor
- You need CAN USE on the warehouse plus SELECT on the tables