Prerequisites
- A JDK installation
- The JDBC URL for the Databricks SQL warehouse
Setup
Environment Variables
Add the following to a.env file in your Cube project:
Service principal (OAuth M2M)
To connect as a Databricks service principal instead of with a personal access token, set the OAuth client ID and secret of the service principal. The service principal needsCAN USE on the SQL
warehouse in the JDBC URL and access to the data Cube queries (with Unity
Catalog, USE CATALOG, USE SCHEMA and SELECT). Requires Cube v1.3.20 or
later.
CUBEJS_DB_DATABRICKS_OAUTH_CLIENT_ID
is set, Cube authenticates with OAuth and ignores
CUBEJS_DB_DATABRICKS_TOKEN.
With OAuth, Cube ignores AuthMech, UID and PWD in the JDBC URL and
configures authentication itself, so set both environment variables and leave
OAuth2ClientID, OAuth2Secret and Auth_Flow out of the URL.
Cube cloud platform
The Databricks data source form sets the client ID, client secret and JDBC URL for you. It is shown when you create a deployment and on the deployment’s Settings → Data Sources page:- Select Service principal (OAuth M2M) authentication. Access token authentication is the default.
- Enter the OAuth client ID and OAuth client secret of the service principal.
- Enter the Databricks JDBC URL and, optionally, the Databricks Catalog.
Docker
Create a.env file as above, then extend the
cubejs/cube:jdk Docker image tag to build a Cube image with the JDBC driver:
Environment Variables
Pre-Aggregation Feature Support
count_distinct_approx
Measures of typecount_distinct_approx can
be used in pre-aggregations when using Databricks as a source database. To learn
more about Databricks’s support for approximate aggregate functions, click
here.
Pre-Aggregation Build Strategies
To learn more about pre-aggregation build strategies, head
here.
By default, Databricks JDBC uses a simple strategy to
build pre-aggregations.
Simple
No extra configuration is required to configure simple pre-aggregation builds for Databricks.Export Bucket
Databricks supports using both AWS S3 and Azure Blob Storage for export bucket functionality.AWS S3
To use AWS S3 as an export bucket, first complete the Databricks guide on connecting to cloud object storage using Unity Catalog.Ensure the AWS credentials are correctly configured in IAM to allow reads and
writes to the export bucket in S3.
Google Cloud Storage
When using an export bucket, remember to assign the Storage Object Admin
role to your Google Cloud credentials (
CUBEJS_DB_EXPORT_GCS_CREDENTIALS).