Problem
When using the the dbutils
command to view your /Workspace
directory, you see a different result compared to when you use the Databricks UI to view your workspace files.
Cause
When accessing workspace files via dbutils
, the prefix file:/
is required to distinguish between the workspace file system and the Databricks File System (DBFS). Without this prefix, the path is interpreted as a DBFS path.
This distinction is crucial because the operations and access permissions can differ between the workspace file system and DBFS. In the context of volumes, listing files with dbutils
refers to DBFS paths because the volumes are part of DBFS.
Solution
Use the file:/
prefix when accessing workspace files via dbutils
to ensure the path is correctly interpreted as a Workspace file system path.
For example, to list files in the workspace folder, use the command:
dbutils.fs.ls("file:/Workspace/Users/<your-folder>/")
For further reading and best practices on distinguishing between workspace and DBFS paths, refer to the What are workspace files? (AWS | Azure | GCP) and Databricks Utilities (dbutils) reference (AWS | Azure | GCP) documentation.