This article covers:

  1. How to set up a connection to a Databricks database
  2. How to add datasets
  3. How to do connection overrides on a Databricks connection
  4. The supported Databricks data types and the respective Luzmo data type they are mapped to

1. How to setup a Databricks connection

Go to the Connections page and select New connection, then select the Databricks connector. Open Authentication and choose one of these methods.

  • Personal access token. You create this token yourself in Databricks.

    1. Click your username in the top right and select Settings.
    2. Select Developer and click Manage next to Access tokens.
    3. Click Generate new token and copy the value.
    4. In Luzmo, paste that value into Token.
  • OAuth2 machine-to-machine. Choose this when the connection should belong to a service principal rather than a person.

    1. In Databricks, an account or workspace admin creates a service principal and assigns it to the workspace.
    2. Click your username in the top right and select Settings.
    3. Open Identity and access and click Manage next to Service principals.
    4. Open the service principal, open Secrets, and click Generate secret.
    5. Choose the all-apis scope. Luzmo requests that scope when it fetches a token, so a secret limited to sql won't connect.
    6. Copy the Client ID and the secret. Databricks shows the secret only once.
    7. Grant the service principal permission to use the SQL warehouse and to read the tables you want in Luzmo.
    8. In Luzmo, paste the client ID into Client ID and the secret into Client secret.

Both modes also need the warehouse connection details. In Databricks, open SQL Warehouses, select the warehouse, and copy the values from the connection details.

  • Server hostname: for example abc-12345678-abcd.cloud.databricks.com
  • HTTP path: for example /sql/1.0/warehouses/xxxxxxxxxxx

Select Connect. You can then select and visualize your Databricks data.

Please refer to the examples in our developer documentation to find out how to create a connection to Databricks via our API. Put the connection fields inside properties. For a personal access token, set serverHostname, httpPath, and token. For a service principal, set serverHostname, httpPath, authType to oauth-m2m, clientId, and clientSecret.

Notes: If your Databricks server blocks external connections, whitelist Luzmo's IP addresses as described in connect a database by whitelisting our IP addresses.

2. How to add datasets

Once you have connected your Databricks, you can add datasets. You can select one or multiple datasets as available in your Databricks and link them in Luzmo to ensure they can be used together in a dashboard. Also make sure to check out this article on Preparing your data for analytics.

To find out how to add datasets using our API, please refer to this example in our developer documentation.

3. Databricks Connection Overrides

When you create an embed token, you can override the Databricks connection properties for that session. Find out more about connection overrides.

Put overrides inside properties, using the same field names as the connection. Luzmo matches those names without regard to capitalization, so serverHostname and serverhostname refer to the same field. To find the connection ID, see retrieving a connection ID in our developer documentation.

For a personal access token connection, you can override serverHostname, httpPath, and token. For a service principal connection, you can override serverHostname, httpPath, authType, clientId, and clientSecret. Set authType to oauth-m2m when you send client credentials.

You can also override the table address per dataset. Databricks uses a three-part address: catalog, schema, and table. Set schema to the new catalog. Set table to the schema and table joined by a dot, such as schema.table.

Our developer documentation has more info about connection overrides and an example of a Databricks connection override.

Override a personal access token connection

{
 "account_overrides": {
   "< connection id >": {
     "properties": {
       "serverHostname": "Override Server Host Name",
       "httpPath": "Override HTTP Path",
       "token": "Override Token"
     }
   }
 }
}

Override a service principal connection

{
 "account_overrides": {
   "< connection id >": {
     "properties": {
       "serverHostname": "Override Server Host Name",
       "httpPath": "Override HTTP Path",
       "authType": "oauth-m2m",
       "clientId": "Override Client ID",
       "clientSecret": "Override Client Secret"
     }
   }
 }
}

Override the table address

{
 "account_overrides": {
   "< connection id >": {
     "datasets": {
       "< dataset id >": {
         "schema": "< Override Databricks Catalog >",
         "table": "< Override Databricks Schema >.< Override Databricks Table >"
       }
     }
   }
 }
}

4. Supported Data Types

Data Type in Databricks Data Type in Luzmo
BIGINT numeric
BINARY numeric
DECIMAL(p,s) numeric
DOUBLE numeric
FLOAT numeric
INT numeric
SMALLINT numeric
TINYINT numeric
TIMESTAMP datetime
TIMESTAMP_NTZ datetime
DATE datetime
INTERVAL datetime
BOOLEAN hierarchy
VOID hierarchy
STRING hierarchy

Need more information?

Do you still have questions? Let us know how we can help.
Send us feedback!