# Databricks

> Run a LevelFour-generated script in Databricks.

Source: https://docs.levelfour.ai/connectors/databricks


## Prerequisites

* A Unity Catalog enabled workspace.
* Account admin and metastore admin rights. You need both to run the setup script and grant the service principal access to `system.billing`. A workspace admin alone is not enough.

## What it costs you

This connector runs one small scheduled query a day, on a serverless SQL warehouse with auto-stop. The query itself costs a small amount of serverless compute time; the system tables it reads are free.

## Connect

### Get your setup script

Open **Connect Providers**, select **Databricks**, and click **Get setup script**.

### Run the script in Databricks

As an account admin, run the script in your workspace. It creates a dedicated service principal with an OAuth secret (valid for up to 730 days), grants that service principal Data Reader on `system.billing`, and creates or reuses a small serverless SQL warehouse with auto-stop, granting the service principal Can Use on it.

### Add the service principal to LevelFour

Copy the service principal's client ID and the OAuth secret the script prints, along with your workspace host (for example `yourcompany.cloud.databricks.com`) and the SQL warehouse ID. Paste them under **Connect Providers** and click **Verify**.

## Confirming it worked

The connection moves to **Connected**, usually within about 12 hours of the script finishing, since Databricks itself takes time to deliver billing records. Your first data appears within a day.

## Rotating or removing access

### Rotating the credential

Generate a new OAuth secret for the service principal in Databricks, paste it into **Connect Providers**, then revoke the old secret.

### Removing access

Disconnect Databricks under **Connect Providers**, then, as an account admin, revoke the service principal's grants and delete it.

## Troubleshooting

| Symptom                                             | What to do                                                                                                                                                      |
| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Cost figures are all at list price                  | Negotiated rates come from a Databricks table that is in private preview. Ask your Databricks account team to enable it; until then, figures reflect list price |
| The script fails to grant access                    | You need both account admin and metastore admin rights to grant `system.billing` by default. A workspace admin alone is not enough                              |
| The connection stops updating after about two years | The OAuth secret expires after at most 730 days. Rotate it before it lapses                                                                                     |

## Next

* [Connect Providers](/connectors) lists every provider you can connect
* [Snowflake](/connectors/snowflake) connects the same way, with a setup script instead of a pasted key
