Databricks

Databricks is a data and AI platform built on the lakehouse architecture. Weld connects to it through a SQL warehouse and reads the tables and views governed by Unity Catalog.

Databricks runs on AWS, Microsoft Azure and Google Cloud, and Weld supports all three. A common setup is to build models in Databricks, for example with dbt, and use Weld to sync them into another warehouse such as Redshift, BigQuery or Snowflake.

In addition to its role as a destination, Databricks can be used as an ELT source. One connection can serve both.

Features

Feature nameSupported
Column HashingTrueColumn level
BlockingTrueColumn level
IncrementalTrue
Custom dataTrue
HistoryFalse
ReSyncTrueTable level
TemplatesFalse

🔧 Setup Guide

Weld connects as a service principal with OAuth machine-to-machine credentials. It needs four things in your workspace: the service principal itself, the Databricks SQL access entitlement, permission to use a SQL warehouse, and read access to the catalogs you want to sync.

Step 1 - Create a service principal

  1. In your Databricks workspace, go to Settings → Identity and access → Service principals → Manage.

  2. Press Add service principal → Add new, choose Databricks managed, give it a name such as weld-service-principal and press Add.

  3. Open the service principal and go to Configurations. Make sure Databricks SQL access is checked.

  4. Go to Secrets and press Generate secret. If you are asked to choose scopes, keep the default. Note down the Client ID and the Secret; the secret is only shown once.

Step 2 - Give it a SQL warehouse

Every sync runs its queries on a SQL warehouse you choose.

  1. Go to SQL Warehouses and pick an existing warehouse, or create one. A serverless warehouse is recommended: it starts in seconds and stops itself when idle. 2X-Small is enough to start with.
  2. Under Permissions, add the service principal with Can use.
  3. Under Connection details, note down the Server hostname and HTTP path.

Step 3 - Grant read access

Run the following in the SQL editor, replacing the catalog name and the service principal's Client ID:

Grant read access

GRANT USE CATALOG ON CATALOG analytics TO `<client-id>`;
GRANT USE SCHEMA ON CATALOG analytics TO `<client-id>`;
GRANT SELECT ON CATALOG analytics TO `<client-id>`;

Privileges granted on a catalog also cover the schemas, tables and views created in it later, such as new dbt models. To limit Weld to a single schema, grant USE CATALOG on the catalog and USE SCHEMA and SELECT on that schema instead.

Repeat for every catalog you want Weld to be able to sync from.

Step 4 - Connector Configuration

In Weld, add a Databricks connection and pick the form for your cloud: Databricks on AWS, Databricks on Azure or Databricks on Google Cloud.

FieldValue
Server HostnameFrom the warehouse's connection details. The workspace URL also works.
HTTP PathFrom the warehouse's connection details, like /sql/1.0/warehouses/1a2b3c
OAuth Client IDThe service principal's Client ID (Application ID)
OAuth Client SecretThe secret generated in step 1
Unity Catalog VolumeLeave empty, unless you also use Databricks as a destination

The hostname looks different on each cloud:

CloudServer hostname
AWSdbc-a1b2c3d4-e5f6.cloud.databricks.com
Azureadb-1234567890123456.7.azuredatabricks.net
Google Cloud1234567890123456.7.gcp.databricks.com

Once connected, Weld lists the catalogs the service principal can see. Select the ones to sync from. Every table and view in them becomes available to sync, named catalog.schema.table.

Step 5 - Data To Sync

  1. Select the tables and views you wish to include in the sync.
    You can view the schema, remove columns or hash sensitive information.
  2. Update Sync mode, which can be set to:
    • Incremental Sync: pick a column that changes whenever a row does, such as updated_at or an auto-incrementing id. Each sync fetches only the rows added or changed since the last one. Deleted rows are not removed from the destination.
    • Full Sync: each sync replaces the destination table, so deleted rows disappear too. This suits dbt models materialized as table.
    • Append Only: rows are added to the destination table and never updated. This suits event and log tables.

Step 6 - Configure Sync

  1. Select how often you would like the data to sync.
  2. Check the Destination schema name, which is where the tables land in your warehouse, and click Start Initial Sync.

Weld will take over from here and commence syncing data from your Databricks workspace.

Was this page helpful?