> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getunblocked.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Databricks

> Connecting Databricks to Unblocked

Connect Databricks to let Unblocked reference data from the catalogs you select when answering questions.

## Prerequisites

* A Databricks workspace administrator who can create a service principal and generate an OAuth secret.
* Permission to manage the SQL warehouse and grant privileges on the catalogs and schemas you want Unblocked to access.
* A SQL warehouse in the workspace you want to connect.

Use the same workspace throughout setup. The screenshots show example workspaces and the service principal name `unblocked`; use your own workspace, catalog, and schema names.

## Set up OAuth in Databricks

Before connecting in Unblocked, create a dedicated service principal, grant it access to a SQL warehouse and read access to the data you want indexed, and generate an OAuth secret restricted to SQL. This gives you the **Client ID** and **OAuth secret** that Unblocked needs.

<Steps>
  <Step title="Open service principal settings">
    In your Databricks workspace, click your profile icon and select **Settings**.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/open-settings.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=800bbce2add7252c5e2487ab431be8b1" alt="Databricks profile menu with Settings selected" width="2872" height="2236" data-path="img/databricks/open-settings.png" />

    Under **Workspace admin**, select **Identity and access**. Next to **Service principals**, click **Manage**.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/identity-and-access.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=dda477cdaa03c4befd5184c270b373bf" alt="Identity and access settings with the Service principals Manage button" width="2872" height="2236" data-path="img/databricks/identity-and-access.png" />
  </Step>

  <Step title="Create a service principal with SQL access">
    Click **Add service principal**. Open the **Service principal** dropdown and select **Add new service principal to account and workspace**.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/add-service-principal.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=76abfe1fcf8bfbb0d022ade39f197ee0" alt="Option to add a new service principal to the account and workspace" width="2872" height="2236" data-path="img/databricks/add-service-principal.png" />

    Enter a name such as `unblocked`. Enable **Databricks SQL access** and leave the other entitlements off, including **Admin access**, **Unrestricted cluster creation**, and **Allow instance pool creation**. Click **Add service principal**.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/sql-entitlement.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=276f56b6b6d45b3ded8bc351f2b72794" alt="Service principal with Databricks SQL access enabled" width="2872" height="2236" data-path="img/databricks/sql-entitlement.png" />

    <Note>
      If you already have a dedicated service principal, select it from the dropdown instead. Ensure it is assigned to this workspace and has the **Databricks SQL access** entitlement.
    </Note>
  </Step>

  <Step title="Generate an OAuth secret">
    Open the service principal, select **Secrets**, and click **Generate secret**.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/secrets.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=8297653f59172a9b5feec556b61ca429" alt="Service principal Secrets tab with the Generate secret button" width="2872" height="2236" data-path="img/databricks/secrets.png" />

    Set **Lifetime (days)** according to your organization's rotation policy. The dialog accepts 1–730 days. Under **Scope**, select **BI Tools**, click **Add scope**, search for `sql`, and select **sql**. Close the dropdown and click **Generate**.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/sql-oauth-scope.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=4800b372fd18eff72ce857323d4215da" alt="OAuth secret configuration with the sql scope selected" width="2872" height="2236" data-path="img/databricks/sql-oauth-scope.png" />

    Copy the **Secret** and **Client ID** into your approved secret store before clicking **Done**. You will enter these in Unblocked. The Client ID is the service principal's application ID.

    <Warning>
      The secret is displayed only once. Keep it out of documentation and source control, and replace it before it expires.
    </Warning>

    The `sql` scope limits API access. You must also grant warehouse and data permissions in the following steps. See [Databricks OAuth setup](https://docs.databricks.com/aws/en/dev-tools/auth/oauth-m2m) for details.
  </Step>

  <Step title="Grant access to a SQL warehouse">
    Select **SQL Warehouses** in the sidebar and open the warehouse Unblocked should use.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/sql-warehouses.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=da6c3745c005f2ca842e26f682355e83" alt="SQL Warehouses list" width="2872" height="2236" data-path="img/databricks/sql-warehouses.png" />

    Click **Permissions**, search for your service principal, and select it. Give it **Can use** permission and apply the change.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/warehouse-permissions.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=a259cd3223103b3288d0b5c51bbd7d49" alt="Warehouse permissions dialog with the unblocked service principal in search results" width="2872" height="2236" data-path="img/databricks/warehouse-permissions.png" />

    Confirm that the principal has **Can use** access on the selected warehouse. You will choose this warehouse in Unblocked after connecting.
  </Step>

  <Step title="Grant read access to your data">
    Choose either the Catalog UI or a SQL script to grant the same read access.

    <Accordion title="Use the Catalog UI">
      Open **Catalog** in the sidebar, expand your catalog, and select the schema you want Unblocked to access. Open **Permissions** and click **Grant**.

      <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/schema-permissions.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=5c64afde6b27d9e56dd8e97180022d4d" alt="Schema Permissions tab with the Grant button" width="2872" height="2236" data-path="img/databricks/schema-permissions.png" />

      Select your service principal. Choose the **Custom** privilege preset, select **SELECT**, and ensure **USE SCHEMA** is included. If the dialog reports missing access to the parent catalog, keep **Also grant USE CATALOG** checked. Click **Confirm**.

      <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/schema-grants.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=35bc2c2aa0747c87d16c9f666d3484c4" alt="Schema grant dialog with SELECT, USE SCHEMA, and the parent USE CATALOG grant selected" width="2872" height="2236" data-path="img/databricks/schema-grants.png" />
    </Accordion>

    <Accordion title="Use a SQL script">
      Open **SQL Editor** in your Databricks workspace and select a SQL warehouse. Run the following as a metastore admin, object owner, or user with permission to grant privileges on the catalog and schema.

      Replace `<catalog>`, `<schema>`, and `<service-principal-client-id>` with your values. Use the service principal's **Client ID** (application ID), not its display name, and keep the backticks around each identifier.

      ```sql theme={null}
      GRANT USE CATALOG ON CATALOG `<catalog>`
        TO `<service-principal-client-id>`;

      GRANT USE SCHEMA ON SCHEMA `<catalog>`.`<schema>`
        TO `<service-principal-client-id>`;

      GRANT SELECT ON SCHEMA `<catalog>`.`<schema>`
        TO `<service-principal-client-id>`;
      ```

      These statements grant data access only. Complete the SQL warehouse **Can use** permission step above as well. See [Manage privileges in Unity Catalog](https://docs.databricks.com/aws/en/data-governance/unity-catalog/manage-privileges) for SQL grant requirements.
    </Accordion>

    Repeat for each schema you want Unblocked to access. Granting `SELECT` on a schema covers its current and future tables and views. The principal needs `USE CATALOG` on each parent catalog and `USE SCHEMA` on each schema. See the [Unity Catalog privileges reference](https://docs.databricks.com/aws/en/data-governance/unity-catalog/access-control/privileges-reference).

    <Note>
      For narrower access to [a single table or view](#grant-single-table-view), or broader access to an [entire catalog](#grant-entire-catalog), see the optional grant variations below.
    </Note>
  </Step>
</Steps>

<Accordion title="Grant access to a single table or view (optional)" id="grant-single-table-view">
  For narrower access, grant **USE CATALOG** on the parent catalog and **USE SCHEMA** on the parent schema. Then open each allowed table or view in **Catalog**, select **Permissions**, and grant **SELECT** to your service principal.

  Alternatively, run the following in **SQL Editor** with permission to grant privileges on these objects. Replace the placeholders with your catalog, schema, table or view, and service principal's **Client ID**. For a view, replace `ON TABLE` with `ON VIEW` and use its name in `<table-or-view>`.

  ```sql theme={null}
  GRANT USE CATALOG ON CATALOG `<catalog>`
    TO `<service-principal-client-id>`;

  GRANT USE SCHEMA ON SCHEMA `<catalog>`.`<schema>`
    TO `<service-principal-client-id>`;

  GRANT SELECT ON TABLE `<catalog>`.`<schema>`.`<table-or-view>`
    TO `<service-principal-client-id>`;
  ```

  Use these grants instead of schema-wide **SELECT**. Schema-wide grants also apply to objects created later.
</Accordion>

<Accordion title="Grant access to an entire catalog (optional)" id="grant-entire-catalog">
  To let Unblocked read every schema, table, and view in a catalog, open the catalog in **Catalog**, select **Permissions**, and click **Grant**. Select your service principal and grant **USE CATALOG**, **USE SCHEMA**, and **SELECT**.

  Alternatively, run the following in **SQL Editor** with permission to grant privileges on the catalog. Replace `<catalog>` and `<service-principal-client-id>` with your catalog name and the service principal's **Client ID**.

  ```sql theme={null}
  GRANT USE CATALOG ON CATALOG `<catalog>`
    TO `<service-principal-client-id>`;

  GRANT USE SCHEMA ON CATALOG `<catalog>`
    TO `<service-principal-client-id>`;

  GRANT SELECT ON CATALOG `<catalog>`
    TO `<service-principal-client-id>`;
  ```

  Catalog-level `USE SCHEMA` and `SELECT` apply to current and future schemas and their tables and views. Use these grants instead of schema-wide grants only when you want all of that data accessible to Unblocked.
</Accordion>

<Accordion title="Revoke Unblocked's access (optional)">
  To stop the dedicated service principal from accessing this workspace, open **Settings** › **Identity and access** › **Service principals** › **Manage**. Select the principal and, under **Status**, uncheck **Active**.

  Deactivation prevents authentication and API access in this workspace while preserving the principal's permissions. Reactivating it restores access with those permissions. See [Deactivate a service principal](https://docs.databricks.com/aws/en/admin/users-groups/manage-service-principals#deactivate-a-service-principal).
</Accordion>

## Connect in Unblocked

With your workspace URL, OAuth secret, and Client ID ready, connect Databricks in Unblocked.

<Steps>
  <Step title="Connect Databricks">
    In the Unblocked sidebar, click **Settings**, then **Data Sources**, then **Connect another data source**, and select **Databricks**.
  </Step>

  <Step title="Enter your workspace and OAuth credentials">
    Enter the following values:

    * **Workspace URL**: The URL of the Databricks workspace where you assigned the service principal and granted warehouse access.
    * **OAuth secret**: The secret you generated for the service principal.
    * **Client ID**: The service principal's application ID, shown when you generated the secret.

    Click **Connect**.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/connect.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=e5e763de2e6d95d601a6bafb5eda8bab" alt="Unblocked Databricks setup form with Workspace URL, OAuth secret, and Client ID fields" width="2872" height="2236" data-path="img/databricks/connect.png" />
  </Step>

  <Step title="Select your SQL warehouse">
    Under **SQL Warehouse**, choose the warehouse you granted the service principal permission to use. Unblocked uses it to query Databricks.
  </Step>

  <Step title="Select your catalogs">
    Under **Catalog Access**, use **Find catalogs** to filter the list. Select the catalogs you want Unblocked to index, then click **Save Settings**. Unblocked starts indexing your selected catalogs.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/catalog-selection.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=e216cc1cb98609bd45a5cde4625138bb" alt="Unblocked Databricks settings with a SQL warehouse selected, catalog access checkboxes, and Save Settings button" width="2872" height="2236" data-path="img/databricks/catalog-selection.png" />
  </Step>

  <Step title="Wait for indexing to complete">
    Unblocked shows **Processing** for Databricks on the **Data Sources** page while indexing is in progress. Unblocked will not use Databricks to answer questions until indexing completes.

    <img src="https://mintcdn.com/unblocked/pdI0jd7AYVQgj7dD/img/databricks/indexing.png?fit=max&auto=format&n=pdI0jd7AYVQgj7dD&q=85&s=3a2ca58afd826c408fc104a9037eef3d" alt="Connected Data Sources page showing Databricks with Processing status" width="2872" height="2236" data-path="img/databricks/indexing.png" />
  </Step>
</Steps>

You can update the warehouse and catalog selection from **Settings** › **Data Sources** › **Databricks**.

## Troubleshooting

* **Connection fails:** Check the workspace URL, Client ID, and OAuth secret. Confirm that the secret has not expired and includes the `sql` scope.
* **No SQL warehouses found:** Confirm that the principal is assigned to the connected workspace, has **Databricks SQL access**, and has **Can use** permission on a warehouse. Reload the page after updating permissions.
* **No catalogs found or queries fail with a permission error:** Confirm `USE CATALOG`, `USE SCHEMA`, and `SELECT` on the data you want Unblocked to access.
