> For the complete documentation index, see [llms.txt](https://docs.soda.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.soda.io/reference/data-source-reference-for-soda-core/databricks.md).

# Databricks SQL

Access configuration details to connect Soda to a Databricks SQL data source.

> For information about how to connect to Databricks Spark Dataframes, see: [Spark Dataframe](/reference/data-source-reference-for-soda-core/spark-dataframe.md#example-contract-spark-databricks)

## Connection configuration reference

Install the following package:

```bash
pip install soda-databricks
```

### Data source YAML

#### Core connection

**Create the config file:**

```shellscript
soda data-source create -f ds_config.yml
```

Databricks supports three authentication methods. Set `auth_type` to choose one. If you omit `auth_type`, Soda uses personal access token authentication.

<table><thead><tr><th width="304.99993896484375">Authentication method</th><th>Soda Cloud support</th><th>Soda Core support</th></tr></thead><tbody><tr><td><a href="#id-1.-personal-access-token">Personal access token</a></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td><a href="#id-2.-databricks-oauth-machine-to-machine">Databricks OAuth (machine-to-machine)</a></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td><a href="#id-3.-azure-service-principal">Azure service principal</a></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr></tbody></table>

Every method shares these connection parameters:

| Parameter               | Required | Default                 | Description                                                                                                          |
| ----------------------- | -------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `type`                  | Yes      | —                       | Must be `databricks`.                                                                                                |
| `host`                  | Yes      | —                       | Databricks workspace hostname, for example `abc.cloud.databricks.com`. A leading `https://` or `http://` is removed. |
| `http_path`             | Yes      | —                       | HTTP path for the SQL warehouse or cluster.                                                                          |
| `catalog`               | No       | —                       | Default catalog to use.                                                                                              |
| `session_configuration` | No       | —                       | Optional session configuration dictionary.                                                                           |
| `auth_type`             | No       | `personal-access-token` | Authentication method. One of `personal-access-token`, `databricks-oauth-m2m`, `azure-service-principal`.            |

{% hint style="info" %}
**Hive Metastore is supported**. When the `catalog` is set to `hive_metastore`, Soda will use Hive-compatible queries.
{% endhint %}

#### Personal access token

Supported in Soda Cloud and Soda Core.

{% code title="ds\_config.yml" %}

```yaml
type: databricks
name: my_databricks
connection:
  host: ${env.DATABRICKS_HOST}
  http_path: ${env.DATABRICKS_SQL_HTTP_PATH}
  catalog: ${env.DATABRICKS_CATALOG}

  # auth_type: personal-access-token   # optional; the default when omitted
  access_token: ${env.DATABRICKS_SQL_ACCESS_TOKEN}

  ## optional
  # session_configuration: <session configuration dict>
```

{% endcode %}

| Parameter      | Required | Default                 | Description                              |
| -------------- | -------- | ----------------------- | ---------------------------------------- |
| `auth_type`    | No       | `personal-access-token` | Omit, or set to `personal-access-token`. |
| `access_token` | Yes      | —                       | Databricks personal access token.        |

***

#### Databricks OAuth (machine-to-machine)

Supported in Soda Cloud and Soda Core.

Authenticates with a Databricks-managed OAuth service principal using the client-credentials flow. Create the service principal and generate an OAuth secret in Databricks (see Databricks' documentation on [OAuth machine-to-machine (M2M) authentication](https://docs.databricks.com/en/dev-tools/auth/oauth-m2m.html)). Soda derives the token endpoint from `host`, so no token URL is required.

{% code title="ds\_config.yml" %}

```yaml
type: databricks
name: my_databricks
connection:
  host: ${env.DATABRICKS_HOST}
  http_path: ${env.DATABRICKS_SQL_HTTP_PATH}
  catalog: ${env.DATABRICKS_CATALOG}

  auth_type: databricks-oauth-m2m
  client_id: ${env.DATABRICKS_CLIENT_ID}
  client_secret: ${env.DATABRICKS_CLIENT_SECRET}
```

{% endcode %}

| Parameter       | Required | Default | Description                                       |
| --------------- | -------- | ------- | ------------------------------------------------- |
| `auth_type`     | Yes      | —       | Must be `databricks-oauth-m2m`.                   |
| `client_id`     | Yes      | —       | Databricks OAuth service-principal client ID.     |
| `client_secret` | Yes      | —       | Databricks OAuth service-principal client secret. |

***

#### Azure service principal

Supported in Soda Cloud and Soda Core.

Authenticates Azure Databricks with a Microsoft Entra ID (Azure AD) service principal. Register the application in Entra ID and note its client ID, client secret, and directory (tenant) ID (see Microsoft's documentation on [creating a Microsoft Entra ID application and service principal](https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal)). Soda requests the token from `login.microsoftonline.com`, so the tenant ID is required.

{% code title="ds\_config.yml" %}

```yaml
type: databricks
name: my_databricks
connection:
  host: ${env.DATABRICKS_HOST}
  http_path: ${env.DATABRICKS_SQL_HTTP_PATH}
  catalog: ${env.DATABRICKS_CATALOG}

  auth_type: azure-service-principal
  azure_client_id: ${env.DATABRICKS_AZURE_CLIENT_ID}
  azure_client_secret: ${env.DATABRICKS_AZURE_CLIENT_SECRET}
  azure_tenant_id: ${env.DATABRICKS_AZURE_TENANT_ID}
```

{% endcode %}

| Parameter             | Required | Default | Description                                                  |
| --------------------- | -------- | ------- | ------------------------------------------------------------ |
| `auth_type`           | Yes      | —       | Must be `azure-service-principal`.                           |
| `azure_client_id`     | Yes      | —       | Entra ID (Azure AD) service-principal application/client ID. |
| `azure_client_secret` | Yes      | —       | Entra ID (Azure AD) service-principal client secret.         |
| `azure_tenant_id`     | Yes      | —       | Entra ID (Azure AD) directory/tenant ID.                     |

***

### Test the connection

Test the data source connection:

```bash
soda data-source test -ds ds_config.yml
```

{% hint style="warning" %}

#### **Row-level security**

If your data source uses row-level security policies (e.g. Row Access Policies in Snowflake, Row-Level Security in PostgreSQL or SQL Server, Row Filters in Databricks Unity Catalog, or equivalent mechanisms in other data sources), **ensure that the Soda connection** user or role **has been granted the appropriate policy exemptions or access**.

Row-level security policies do not cause connection errors or scan failures, but **they silently filter the rows visible to Soda**. This can produce unexpected results. For example, `dataset_rows_tested: 0` even when the dataset clearly contains rows.
{% endhint %}

<br>

***

{% hint style="info" %}
You are **not logged in to Soda** and are viewing the default public documentation. Learn more about [Licensing & documentation access](/reference/documentation-access-and-licensing.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.soda.io/reference/data-source-reference-for-soda-core/databricks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
