Sub topic 4
What a workspace is
Prerequisites
This chapter assumes you know what cloud object storage and virtual machines are. It also assumes you can read basic SQL and Python, and that you have seen the control plane and compute plane split from the previous chapter. You do not need a Databricks account to follow the concepts, but the examples run in one.
The working model
A workspace is the environment where you and your team do work in Databricks. It has its own URL, its own sign-in, and its own set of objects such as notebooks, folders, jobs, and compute. Think of it as one deployment of the Databricks web application, tied to one cloud region in one cloud account.
A workspace is not the same thing as your data. Tables live in storage that Unity Catalog governs, and Unity Catalog can be shared across many workspaces. A workspace is the place where you reach that data and run code against it.
The workspace itself is hosted in the control plane. When you open a notebook, edit a job, or change a cluster setting, you are talking to the control plane. When code runs, it runs on compute in the compute plane, either in your own cloud account (classic compute) or in Databricks-managed infrastructure (serverless compute).
What lives inside a workspace
A workspace holds several kinds of objects. Some are stored in the workspace itself, and some are references to things stored elsewhere.
| Object | What it is | Stored where |
|---|---|---|
| Notebook | A document of runnable cells in SQL, Python, Scala, or R | Workspace |
| Folder | A container for notebooks and other files | Workspace |
| Git folder | A folder linked to a remote Git repository | Workspace, synced with Git |
| Job | A scheduled or triggered run of a task | Workspace |
| Compute | Clusters and SQL warehouses | Definition in workspace, machines in compute plane |
| Dashboard and query | Saved SQL and visualizations | Workspace |
| Catalog, schema, table | Governed data objects | Unity Catalog metastore, not the workspace |
The last row matters. Deleting a notebook removes code. It does not remove tables. Dropping a table is a Unity Catalog action that affects every workspace using that metastore.
Workspace, account, and metastore
Three levels of scope are easy to mix up.
- The account is the top-level container for your organization with Databricks. It holds users, groups, workspaces, and billing.
- A workspace is one environment under the account.
- A metastore is the Unity Catalog container for catalogs, schemas, and tables. You normally have one metastore per cloud region, and you attach it to each workspace in that region.
This layout lets several workspaces, for example development, staging, and production, see the same governed data while keeping their notebooks, jobs, and compute separate. Identities are managed at the account level, so a user or group defined once can be given access in any workspace.
Seeing the link between workspace and data
You can check which catalog and schema your session uses, and which workspace-level context you are in, from a notebook. Run this in a notebook attached to compute.
SELECT
current_catalog() AS catalog,
current_schema() AS schema,
current_user() AS user_name;The result shows your default catalog and schema, and the user you are signed in as. Unqualified table names resolve against that catalog and schema. To avoid surprises, use the full three-level name, as in the next example.
CREATE SCHEMA IF NOT EXISTS main.tutorial;
CREATE TABLE IF NOT EXISTS main.tutorial.orders (
order_id BIGINT,
customer_id BIGINT,
amount DECIMAL(10, 2),
order_ts TIMESTAMP
);
INSERT INTO main.tutorial.orders VALUES
(1, 101, 25.00, current_timestamp()),
(2, 102, 40.50, current_timestamp()),
(3, 101, 15.25, current_timestamp());This creates a managed table named by catalog, schema, and table. It assumes you have permission to create objects in the main catalog. Another workspace attached to the same metastore sees the same table, subject to its permissions.
Workspace access versus data access
Getting into a workspace does not give you access to data. The two are controlled separately.
- Workspace access decides whether you can sign in and what you can do with workspace objects, such as creating compute or editing a job.
- Data access decides which catalogs, schemas, and tables you can read or change. Unity Catalog enforces it.
A user can be a workspace member and still get a "permission denied" error on a table. The fix is a grant in Unity Catalog, not a change to workspace settings.
GRANT USE CATALOG ON CATALOG main TO `data-analysts`;
GRANT USE SCHEMA, SELECT ON SCHEMA main.tutorial TO `data-analysts`;The group needs USE CATALOG and USE SCHEMA on the parents as well as SELECT. Missing a parent privilege is the most common reason a grant seems to have no effect.
Common errors and edge cases
- Wrong workspace. Each workspace has its own URL. A notebook or job you built in one workspace does not appear in another, even in the same account. Check the URL and the workspace name in the top bar before concluding something was deleted.
- Metastore not attached. A workspace without an attached metastore cannot use three-level names. The workspace admin or account admin has to attach one.
- Region mismatch. A metastore serves workspaces in its own region. A workspace in a different region needs its own metastore, and data is not shared between them automatically.
- Unqualified names. A query that works for you can fail for a colleague because their default catalog or schema differs. Qualify names in shared code.
- Per-user objects. Items in your personal home folder belong to you. Move shared work to a shared folder or a Git folder so teammates can reach it and it survives if you leave.
- Compute is per workspace. Clusters and SQL warehouses are defined in one workspace. Another workspace cannot attach to them.
Choosing how many workspaces
One workspace per team or environment is a common pattern. Separate workspaces give you isolation of code, compute, and workspace permissions. They also add overhead, since each needs its own setup of networking, compute policies, and access.
| Approach | Benefit | Cost |
|---|---|---|
| One workspace for everyone | Simple to administer | Weak isolation between dev and prod |
| Workspace per environment | Clear separation of dev, staging, prod | More setup, code must be promoted between them |
| Workspace per team or business unit | Team autonomy and cost tracking | Duplicated configuration, harder to standardize |
Because Unity Catalog can span workspaces, the choice mainly affects code, compute, and workspace permissions, not where data lives.
Exercise
A colleague in the same account says they cannot see the notebook you created, and also gets "permission denied" when querying main.tutorial.orders. Name the two separate things to check, and say where each is fixed.
Show answer
First, check that they are in the same workspace as the notebook, because notebooks belong to one workspace and have their own sharing permissions, which are set on the notebook or its folder in that workspace. Second, check their data permissions: they need USE CATALOG on main, USE SCHEMA on main.tutorial, and SELECT on the table, granted in Unity Catalog. Workspace membership does not give data access.
Exercise
You drop a table with DROP TABLE main.tutorial.orders in your development workspace. The production workspace shares the same metastore. What happens to the table there?
Show answer
The table is gone for the production workspace too, because the table belongs to the Unity Catalog metastore and not to a workspace. Only the workspace objects, such as notebooks that referenced it, remain.