> For the complete documentation index, see [llms.txt](https://docs.p0.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.p0.dev/integrations/resource-integrations/databricks/use-cases.md).

# Databricks use cases

Example P0 requests for common Databricks tasks, each with a way to check in Databricks that the access works.

{% hint style="info" %}
The Databricks integration is in beta. Functionality and configuration may change.
{% endhint %}

Each use case below has the P0 CLI request for one common task, and a way to check in Databricks that the access works. To install the CLI, see [Installing p0 CLI](https://docs.p0.dev/p0-cli/installing-p0-cli.md). The examples use a catalog named `main`, a schema named `sales`, and a workspace named `analytics-prod`. Replace them with your own. For every argument a request takes, see [Requesting Databricks access](https://docs.p0.dev/integrations/resource-integrations/databricks/requesting-access.md).

The checks use the [Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/install), signed in as you, and SQL that you run in the workspace's SQL editor. Run a check before you request to see Databricks refuse it, and again once P0 grants the request. When your access expires or is revoked, Databricks refuses it again.

## Read one table

Use this for a one-off report. P0 also grants the `USE_CATALOG` and `USE_SCHEMA` you need to reach the table, and removes them when your access ends.

```bash
p0 request databricks privilege main SELECT --schema sales --table orders --reason "Q3 revenue review"
```

To check, list your privileges on the table, then query it:

```bash
databricks grants get table main.sales.orders --principal <your-email>
```

```sql
SELECT count(*) FROM main.sales.orders;
```

## Read and write a table

Use this to correct bad records.

```bash
p0 request databricks privilege main SELECT MODIFY --schema sales --table customers --reason "Fix duplicate customer records"
```

To check without changing anything, run a `DELETE` that matches no rows. Databricks checks `MODIFY` before it runs the statement:

```sql
DELETE FROM main.sales.customers WHERE 1 = 0;
```

## Read and write files in a volume

Use this to load a data drop into a Unity Catalog volume. You can upload files and read them back.

```bash
p0 request databricks privilege main READ_VOLUME WRITE_VOLUME --schema sales --volume landing --reason "Load this week's supplier files"
```

To check, upload a file and list the volume:

```bash
databricks fs cp suppliers.csv dbfs:/Volumes/main/sales/landing/suppliers.csv
databricks fs ls dbfs:/Volumes/main/sales/landing
```

## Run a function

Use this to try a SQL function, such as a masking function before an export.

```bash
p0 request databricks privilege main EXECUTE --schema sales --function mask_email --reason "Test masking before the export"
```

To check, call the function:

```sql
SELECT main.sales.mask_email('ada@example.com');
```

## Read every table in a schema

The access covers tables created while you hold it. P0 adds `USE_CATALOG` to a request on a schema, but not `USE_SCHEMA`, so name it yourself.

```bash
p0 request databricks privilege main USE_SCHEMA SELECT --schema sales --reason "Audit every table in sales"
```

To check, list the schema's tables, then query one you have no privileges on by itself:

```sql
SHOW TABLES IN main.sales;
SELECT count(*) FROM main.sales.customers;
```

{% hint style="info" %}
P0 fails a request for a privilege you already hold on the same object. If an earlier request of yours gave you `USE_SCHEMA` on this schema, wait for it to end or revoke it first.
{% endhint %}

## Become a workspace admin

Use this for a workspace-wide change, such as updating cluster policies. Your organization must have turned on workspace-admin requests for the workspace.

```bash
p0 request databricks admin workspace-admin --workspace analytics-prod --reason "Update cluster policies"
```

To check, list your groups in the workspace. They include `admins`:

```bash
databricks current-user me -o json | jq '[.groups[].display]'
```

## Become an account admin

Use this for an account-wide change, such as adding a workspace. Your organization must have turned on account-admin requests for the account.

```bash
p0 request databricks admin account-admin --reason "Add a new workspace"
```

To check, list the account's users with the Databricks CLI signed in to the account. Only account admins can:

```bash
databricks account users list
```
