Skip to content

Replicate to Databricks with Zerobus (beta)

Beta

Replication through Zerobus is in beta in SQDR 7.0, and it can change in a later release. Try it on test data first, and talk to Stelo Support before you use it in production.

Zerobus replicates to Databricks without the Spark connector notebook, so Databricks needs no connection back to the Stelo VM. Stelo Capture streams the rows directly into Databricks tables through Databricks Zerobus Ingest, and merges the changes through a serverless SQL warehouse. To compare the methods, see Choose how rows reach Databricks. This page covers what's specific to Zerobus; the rest is on Set up a Databricks destination.

What you need

Required
Databricks A workspace with Unity Catalog, in a region that supports Zerobus Ingest.
Destination tables Managed Delta tables whose names use only ASCII letters, digits and underscores (a Zerobus Ingest rule).
Compute A serverless SQL warehouse, which runs the merges.
Identity A Databricks service principal with the Workspace access entitlement.
Replication Snapshot and incremental. The source needs a Capture Agent, also for snapshots. A snapshot uses the destination's Default Parameters. Baselines and snapshots of a table with sql_variant, spatial or destination-expression columns go through the ODBC connection instead.
Network Outbound port 443 from the Stelo VM to the workspace and the Zerobus endpoint (see Firewall rules). Nothing connects in to the Stelo VM.

How changes are applied

  • The Replicator Service creates or empties the destination table through the ODBC connection, as the subscription's settings say.
  • Baselines and snapshots: the Capture Agent streams the rows directly into the destination table. Databricks shows streamed rows after a short delay, so a run can finish just before all its rows can be queried. When a column name can't be used in a Zerobus stream, the rows go through a work table, <table>__stelo_baseline.
  • Changes: the Capture Agent streams each batch into a work table, <table>__stelo, waits until Databricks shows all its rows, merges them into the destination table through the SQL warehouse, and drops the work table.

Prepare Databricks

First create the schema and get the credentials of the ODBC connection. Skip the sections marked (Spark connector). The examples use mycatalog, myschema and sqdr_principal (the service principal's application ID).

  1. Create a serverless SQL warehouse, and note its JDBC URL on the Connection details tab.

  2. Create a service principal with an OAuth secret, and give it CAN USE on the SQL warehouse (see Create the service principal). Check that it has the Workspace access entitlement, which Zerobus Ingest requires.

  3. Grant it the privileges in Grant the privileges. It also creates and drops the work tables.

  4. Work out the Zerobus endpoint from the workspace URL: <workspace ID>.zerobus.<region>.azuredatabricks.net. The workspace ID is the number in the URL, without adb- and without the digit after the dot:

    Example
    Workspace URL https://adb-1234567890123456.7.azuredatabricks.net
    Zerobus endpoint (workspace in East US) 1234567890123456.zerobus.eastus.azuredatabricks.net

Create the destination

  1. Store the service principal's OAuth secret as a secret in the Data Replicator Manager (DRM).
  2. Create the Databricks destination with its ODBC connection (see Create the Databricks destination). The connection can use the same service principal. Verify tests only this connection.
  3. In Default Parameters, type the className and the parameters, which the DRM doesn't suggest for Zerobus:

    className=com.starquest.sqdr.apply.zerobus.ZerobusProcessor
    zerobusEndpoint=1234567890123456.zerobus.eastus.azuredatabricks.net
    workspaceUrl=https://adb-1234567890123456.7.azuredatabricks.net
    jdbcUrl=<JDBC URL of the SQL warehouse>
    clientId=<application ID of the service principal>
    clientSecret=$$databricks_oauth_secret$$
    

Parameters

Parameter What to enter
zerobusEndpoint The Zerobus endpoint (see Prepare Databricks).
workspaceUrl The workspace's URL.
jdbcUrl The SQL warehouse's JDBC URL.
clientId, clientSecret The service principal's application ID and OAuth secret.
jdbcClientId, jdbcClientSecret Optional: another service principal for the SQL warehouse. By default, clientId and clientSecret.
stagingWaitSeconds Optional: how long to wait for a batch's rows to appear in the work table (default 500).

Group settings

Follow Group settings for Databricks; there's no Spark connector to start. Give every member a replication key: without one, changes are inserted instead of merged, and the table collects duplicates.

Check the destination

After the first baseline or snapshot, compare a table's row count with the source:

SELECT COUNT(*) FROM mycatalog.myschema.mytable;

Then change a row at the source and check that it arrives after the group's next poll.

If it fails

Message Cause and what to do
Zerobus apply: property <name> is not set A required parameter is missing from the group's Parameters. Add it, or use Load from Destination.
Zerobus apply: zerobusEndpoint <endpoint> is not valid: ... The endpoint doesn't match the workspace URL. The message says what to change (see Prepare Databricks).
Only <n> of <m> rows arrived in <table> within 500 seconds Databricks hadn't shown all the rows of a batch in time. Raise stagingWaitSeconds.
Failed to start incremental processing for : <table> Stelo Capture couldn't create the work table or open the stream. Check the service principal's privileges, and the cause in the Capture Agent's Diagnostics.