Sub topic 16
Common errors and how to fix them
This chapter assumes you have read the earlier chapters on volume paths, volume privileges and DBFS paths. You should be able to read a /Volumes/... path and run SQL and Python in a notebook.
Most file-loading errors come from three causes: a wrong path, a missing privilege, or compute that cannot reach Unity Catalog. Check them in that order.
A quick triage
Path errors
Typical messages are "path does not exist" or "volume not found". Check these causes:
- A missing leading slash. The path must start with
/Volumes/. - A wrong catalog, schema or volume name. Names are three levels followed by the file path:
/Volumes/<catalog>/<schema>/<volume>/<path>. - A stray prefix. In notebooks, Spark,
dbutilsandopen()all accept/Volumes/...directly. Do not write/dbfs/Volumes/.... Thedbfs:/Volumes/...form is for the Databricks CLI. - A local file that was never copied.
file:/tmp/sales.csvexists only on the driver's disk. Copy it into the volume first.
Confirm what exists before guessing:
SHOW VOLUMES IN main.default;
LIST '/Volumes/main/default/landing/';Permission errors
A PERMISSION_DENIED error means a privilege is missing. Reading a volume file needs USE CATALOG on the catalog, USE SCHEMA on the schema and READ VOLUME on the volume. Writing needs WRITE VOLUME. Granting only the volume privilege is a common mistake.
SHOW GRANTS ON VOLUME main.default.landing;
GRANT USE CATALOG ON CATALOG main TO `data-engineers`;
GRANT USE SCHEMA ON SCHEMA main.default TO `data-engineers`;
GRANT READ VOLUME ON VOLUME main.default.landing TO `data-engineers`;Run the grants as the volume owner or another user with the right to grant.
Compute and DBFS errors
- Volumes fail on some clusters. Volume paths need compute that works with Unity Catalog. If a cluster has no access mode that supports it, switch the cluster or use a SQL warehouse.
- Old DBFS code fails. Paths such as
dbfs:/FileStore/or/dbfs/mnt/...depend on the DBFS root or on mounts. Admins can restrict DBFS root access, and mounts are legacy. Move the files to a volume and change the path. - A mount works in one place only. Mounts are tied to the workspace and its configuration. Point the code at a volume or an external volume instead.
The following snippet shows the fix for old code:
# Fails when DBFS root access is restricted
# display(dbutils.fs.ls("dbfs:/FileStore/"))
display(dbutils.fs.ls("/Volumes/main/default/landing/"))Debugging checklist
- Print the exact path and compare it with the output of
SHOW VOLUMES. - List the parent folder to confirm the file name and its case.
- Run
SHOW GRANTSand look for the three privileges. - Try the same read from a SQL warehouse. If it works there, the cluster is the problem.
- Search the code for
dbfs:,/dbfsand/mnt, and replace them.
Exercise
A job reads /Volumes/main/default/landing/sales.csv and fails with PERMISSION_DENIED. The user already has READ VOLUME on the volume. What else should you check, and how?
Show answer
Check USE CATALOG on main and USE SCHEMA on main.default. READ VOLUME alone is not enough. Run SHOW GRANTS on the catalog, schema and volume, then grant the missing privilege.