Databricks Quick Reference & Cheat Sheet
7/30/2026, 12:07:46 AM
A concise Databricks platform guide covering core concepts (Lakehouse, Delta Lake), workspace essentials (notebooks, clusters, jobs), and key Spark SQL / DBFS / Delta operations for everyday data engineering and analytics tasks.
Databricks Quick Reference & Cheat Sheet
Getting Started

Cluster & Compute Configuration
| Setting | Description |
|---|---|
| Cluster Type | Select cluster mode (Single Node, Standard High Throughput, High Concurrency) |
| Worker Nodes | Number of worker nodes; autoscaling controls min/max workers |
| Runtime Version | Photon-enabled runtime recommended for performance |
| Init Scripts | Python scripts to run on node start-up |
Cluster Configuration Basics
- Cluster mode: Choose based on workload type (development, production, ML)
- Worker nodes: Autoscale between configured bounds for cost efficiency
- Photon: Enable for large-scale query acceleration
- Job clusters: Best for one-time or scheduled workloads — no upfront cost
Databricks SQL & Warehousing
-- Create a table in Unity Catalog
CREATE TABLE catalog.schema.table_name (
id BIGINT,
name STRING,
value DOUBLE
);
-- Query via Serverless SQL Warehouse
SELECT * FROM catalog.schema.table_name LIMIT 10;
-- Change warehouse / query context
ALTER WAREHOUSE warehouse_name SET AUTOSTOP = 30 MINUTE;
Key takeaway: Databricks SQL warehouses (Standard or Serverless) handle BI/SQL workloads with separate compute from Notebook clusters.
Delta Lake Essentials
| Operation | Command |
|---|---|
| Read delta table | spark.read.format("delta").load("/path/to/table") |
| Write (overwrite) | df.write.format("delta").mode("overwrite").save("/path/to/table") |
| OPTIMIZE & ZORDER | OPTIMIZE table_name; ZORDER BY(col1, col2); |
Delta Time Travel
-- Read by delta version
SELECT * FROM table_name VERSION AS OF 42;
-- Read by timestamp
SELECT * FROM table_name TIMESTAMP AS '2025-08-01 00:00:00';
ZORDER BY co-locates related information in the same set of files, drastically speeding up filtered queries.
Spark SQL Cheat Sheet
DataFrame Creation & Common Patterns
# Read from various sources
df = spark.read.format("csv").option("header", "true").load("/path/to/file.csv")
df = spark.read.json("/path/to/file.json")
df = spark.read.parquet("/path/to/data/")
# SQL-Style Querying
spark.table("catalog.schema.table_name").createOrReplaceTempView("t")
results = spark.sql("SELECT col1, COUNT(*) FROM t GROUP BY col1")
Common Spark Transformations
| Transformation | Description | Example |
|---|---|---|
| select | Pick / rename columns | df.select("col1", "col2") |
| filter | Filter rows | df.filter(df.col > 10) |
| groupBy | Aggregate | df.groupBy("region").count() |
| join | Combine DataFrames | df1.join(df2, "id") |
| orderBy | Sort results | df.orderBy(desc("date")) |
| withColumn | Add / modify columns | df.withColumn("x2", df.x * 2) |
Common Spark Aggregations
from pyspark.sql.functions import col, avg, count, sum, max, min, when
df.agg(
avg("price").alias("avg_price"),
count("*").alias("total_records"),
sum("quantity").alias("total_qty"),
max("date").alias("latest_day")
)
-- Conditional aggregation with CASE WHEN equivalent
df.withColumn("tier", when(df.amount > 1000, "high").otherwise("low"))
Unity Catalog (UC) Navigation
| Object | Syntax / Pattern |
|---|---|
| Metastore | spark.conf.set("spark.sql.catalog.spark_catalog", "com.databricks.backend.catatalogs.catalyst.CatalogHandler") |
| Schema / Database | USE CATALOG my_catalog; USE SCHEMA my_schema; |
| Table | catalog.schema.table_name |
| View | CREATE VIEW catalog.schema.view AS SELECT ... |
Unity Catalog Permissions (GRANT/REVOKE)
-- Grant table read access
GRANT SELECT ON TABLE catalog.schema.table TO role_name;
-- Grant schema usage
GRANT USE SCHEMA ON SCHEMA catalog.schema TO role_name;
-- Revoke
REVOKE ALL ON TABLE catalog.schema.table FROM role_name;
Unity Catalog provides centralized governance across workspaces: one place for access control, data discovery, and audit logs.
Notebooks & Development Tips
| Feature | Shortcut / Tip |
|---|---|
| Run cell | Shift + Enter |
| Auto-complete | Ctrl + Space (or Cmd + Space on Mac) |
| SQL cell | Start with %sql magic |
| Python cell | Default; start with %python explicitly if needed |
| Multi-language | Use cell headers to select language per cell |
Cell Magics
%sql -- switch cell language to SQL
%python -- switch to Python
%sh -- shell commands
%md -- Markdown rendering
%fs -- Databricks File System operations
Delta Live Tables (DLT)
@dlt.table
def clean_data():
return (
spark.readStream.format("delta").load("/path/to/source")
.filter(col("status") == "active")
)
DLT defines declarative data pipelines with built-in schema enforcement, incremental processing, and automatic refresh.
Databricks Jobs / Workflows
Triggering Jobs via CLI or API
# Databricks CLI — create a job
databricks jobs create \
--name "ETL Pipeline" \
--new-cluster '{"spark_version":"14.3.x-scala2.12","NodeType":"r6id.xlarge", ...}'
# Run a job now
databricks jobs run-now --job-id 12345
Workflow Task Patterns
| Pattern | Use Case |
|---|---|
| Notebook task | Run an existing notebook as part of a larger workflow |
| Task dependency | Define upstream → downstream execution order |
| Conditional tasks | Check task.run status before proceeding to next node |
Common File Operations (DBFS / /dbfs/)
# Listing files
dbutils.fs.ls("/path/to/dir")
# Copying
dbutils.fs.cp("file:/local/path", "/dbfs/mnt/gcs/bucket/folder")
# Creating directories
dbutils.fs.mkdirs("/dbfs/tmp/new_folder")
# Downloading from external storage (mount example)
dbutils.fs.mount(
source="gs://bucket-name/path",
mount_point="/mnt/gs/bucket-name",
extra_configs={"fs.gs.auth.service.account.json.keyfile": "…"}
)
Key takeaways
- Cluster mode: Use Standard for dev, High Concurrency for BI/shared SQL warehouses. Use Photon-enabled runtimes where possible.
- Delta Lake is the storage layer; leverage time travel and OPTIMIZE/ZORDER for performance.
- Unity Catalog centralizes governance (metastore → catalog → schema → table).
- Notebook cells support multi-language switching via
%sql,%python, etc. — use them inline as needed. - DLT & Workflows turn notebooks into production-ready, scheduled pipelines with clear lineage and SLAs.
Learning map
Databricks Learning Map
Stage 1 — Foundation
- Understand the Lakehouse architecture concept
- Explore Delta Lake fundamentals (ACID transactions, time travel, schema enforcement)
- Set up a Databricks workspace (community edition or cloud trial)
Stage 2 — Workspace Navigation
- Create & run notebooks (pySpark / SQL / Python / Scala)
- Provision and manage compute clusters (serverless vs. all-purpose, jobclusters)
- Navigate DBFS (Databricks File System) basics
Stage 3 — Spark & SQL Operations
- Write Spark DataFrame transformations in pySpark
- Run Delta Lake commands (
delta,create table,MERGE INTO) - Use Databricks SQL warehouses for dashboarding and ad-hoc queries
Stage 4 — Automation & Governance
- Schedule Jobs (notebook-based and task-based workflows)
- Enable Unity Catalog for data governance and access control
- Automate ELT pipelines with Delta Live Tables (DLT)
Get hands-on — step by step
- Sign up for Databricks Community Edition or a free cloud trial.
- Log into the workspace and create a new notebook — choose pySpark as the language.
- Create an all-purpose cluster from your notebook, select the runtime version "Databricks Runtime 14.x" (or latest ML/Standard), and attach it.
- Upload a CSV file to DBFS by dragging it into the sidebar or running:
dbutils.fs.put("/FileStore/my_data.csv", ...). - Load the data into a DataFrame:
df = spark.read.csv("/FileStore/my_data.csv", header=True, inferSchema=True). Display results withdisplay(df.head(10)). - Register as a Delta table:
df.write.format("delta").mode("overwrite").saveAsTable("my_customers)`. - Query the table using Spark SQL in another cell:
%sql SELECT * FROM my_customers WHERE age > 25 ORDER BY revenue DESC LIMIT 10; - Test time travel by modifying data and querying a previous version:
SELECT * FROM my_customers FOR SYSTEM_TIME AS OF timestamp('2024,01'). - Create a MERGE (upsert): Run a Delta
MERGE INTOstatement to update or insert rows based on matching conditions. - Schedule the notebook as a Job: go to Jobs > New Job > set Trigger to "Schedule" (e.g., daily at 2 AM) and add your notebook as a task.
- Create a SQL warehouse — connect with Databricks SQL editor and build a simple dashboard from results.
Top 3 sources
- 1Databricks Docs — Delta Lake Quickstart
Official Delta Lake documentation covering table creation, merges, time travel, and best-practice patterns.
https://docs.databricks.com/en/delta-lake/index.html
- 2Databricks Academy — Getting Started with Databricks Community Edition
Free, self-paced training that walks you through workspaces, notebooks, clusters, and hands-on labs.
https://www.databricks.com/learn/training/community-edition
- 3Apache Spark SQL Language Reference
The canonical reference for Spark SQL syntax, DataFrame APIs, and built-in functions (runs identically on Databricks).
https://spark.apache.org/docs/latest/sql-programming-guide.html
Links are AI-suggested — worth a quick sanity check before diving in.