Sub topic 4
Building /Volumes paths
This chapter assumes you know what a Unity Catalog catalog and schema are, and that you can run Python and SQL in a Databricks notebook. You should also know what a volume is. Here you learn how a volume maps to a file path and how to avoid the common mistakes.
The path format
Every file in a volume has a path that follows its place in the three-level namespace. The path starts with /Volumes, then the catalog, schema and volume names, then any folders and the file name:
/Volumes/<catalog>/<schema>/<volume>/<path>/<file>For the volume main.default.landing, the file sales.csv is at:
/Volumes/main/default/landing/sales.csvThe dots in the volume name become slashes. Folders inside a volume are plain directories, so you can nest them as deeply as you need, for example /Volumes/main/default/landing/2026/12/sales.csv.
One path, many tools
The same path works in several places. Spark, Python's open(), dbutils.fs and SQL all accept it.
path = "/Volumes/main/default/landing/sales.csv"
df = spark.read.csv(path, header=True, inferSchema=True)
df.show(5)
with open(path) as f:
print(f.readline())Because the path is the same for every tool, you do not need separate dbfs:/ or /dbfs/ variants. SQL takes the path as a quoted string:
LIST '/Volumes/main/default/landing/';The Databricks CLI is the exception. It needs the dbfs: scheme in front of the same path:
databricks fs ls dbfs:/Volumes/main/default/landing/Building paths in code
Hard-coded paths break when you move code between catalogs, such as dev and prod. Build the path from parts instead:
catalog = "main"
schema = "default"
volume = "landing"
base = f"/Volumes/{catalog}/{schema}/{volume}"
path = f"{base}/sales.csv"
display(dbutils.fs.ls(base))Take the three names from job parameters or widgets so the same notebook runs in each environment.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| `No such file or directory` | A name is misspelled, or the path stops at the schema | Check that you give catalog, schema and volume in that order |
| `PERMISSION_DENIED` | You lack `READ VOLUME` or `WRITE VOLUME` | Ask the owner for the privilege on the volume |
| File not found from the CLI | The `dbfs:` prefix is missing | Write `dbfs:/Volumes/...` |
| Path works in a notebook but fails in a library | A `dbfs:` prefix was added to a path used with `open()` | Use the plain `/Volumes/...` path with local file APIs |
Check your understanding
Exercise
A volume is named analytics.raw.invoices, and it contains a folder q4 with a file jan.csv. Write the path you would pass to spark.read.csv. Then write the path the Databricks CLI needs for databricks fs ls.
Show answer
For Spark: /Volumes/analytics/raw/invoices/q4/jan.csv. For the CLI: dbfs:/Volumes/analytics/raw/invoices/q4/jan.csv. The dots in the volume name become slashes after /Volumes, and the CLI adds the dbfs: scheme.