Sub topic 1
Where files live in Databricks: volumes, DBFS and workspace files
Prerequisites
This chapter assumes you have:
- Basic familiarity with the Databricks workspace and notebooks.
- Basic Python and SQL.
- A general idea of what cloud object storage is, such as S3, ADLS or GCS.
- A general idea of what a catalog, schema and table are.
Three places for files
Databricks has three main places to keep files. They differ in who governs access, how large the files can be, and how code addresses them.
- Unity Catalog volumes are governed storage for non-tabular files such as CSV, JSON, images, PDFs and model artifacts. A volume lives inside a catalog and schema, so Unity Catalog privileges control who can read and write it.
- DBFS (Databricks File System) is a legacy file system layer. It includes the DBFS root, a storage location created with the workspace, and any mounts, which are cloud storage locations attached under
/mnt. Access to it is not governed per object by Unity Catalog. - Workspace files are files stored next to notebooks in the workspace tree, under
/Workspace. They suit small project files such asrequirements.txt, configuration files and helper Python modules.
Tables are a separate topic. Tabular data belongs in Unity Catalog tables. Volumes cover everything that is a file but not a table.
How each location is addressed
Each location has its own path style. Recognizing the prefix tells you which system a piece of code uses.
| Location | Typical path | Governed by | Best for |
|---|---|---|---|
| Volume | `/Volumes/main/default/landing/sales.csv` | Unity Catalog privileges | Raw files, ingestion landing zones, shared datasets |
| DBFS | `dbfs:/FileStore/sales.csv` or `/dbfs/FileStore/sales.csv` | Workspace-level access | Reading older code. Avoid it for new data. |
| Workspace files | `/Workspace/Users/[email protected]/config.json` | Workspace permissions | Small code and config files |
The DBFS entry has two spellings. The dbfs:/ form is used by Spark and dbutils. The /dbfs/ form is a local-file view of the same data for Python's open(). A later chapter covers this in detail.
Seeing the difference in code
The same dbutils.fs.ls call works on all three prefixes. Only the path changes.
# Volume: governed by Unity Catalog
display(dbutils.fs.ls("/Volumes/main/default/landing/"))
# DBFS: legacy, avoid for new data
display(dbutils.fs.ls("dbfs:/FileStore/"))
# Workspace files: use the file: scheme with the local path
display(dbutils.fs.ls("file:/Workspace/Users/[email protected]/"))The volume call succeeds only if you hold the right privileges on that volume. The DBFS call works for most workspace users, which is part of why DBFS is no longer recommended for data.
Choosing at a glance
The diagram shows a first-pass decision. Later chapters refine it.
Common mistakes
Most errors at this stage come from mixing up the systems.
- Putting large datasets in workspace files. They have size limits and are not built for data pipelines.
- Starting new projects on
dbfs:/FileStore. You then have to migrate later. - Assuming a
/Volumespath works without privileges. You needREAD VOLUMEto read andWRITE VOLUMEto write.
Exercise
A teammate wants to store a folder of raw CSV files that three groups of engineers will share, with different read and write rights per group. Which location fits best, and why?
Show answer
A Unity Catalog volume. It lets you grant READ VOLUME and WRITE VOLUME to each group separately. DBFS has no per-object Unity Catalog governance, and workspace files are meant for small code and config files.