Databricks Configuration
This page discusses how to configure Databricks as an external compute platform.
Page Contents
A Databricks Data Source added in Stardog using the data-source add CLI command or Stardog Studio can be registered as an external compute platform. Add specific properties in the data source definition to configure the Databricks data source as an external compute platform.
Mandatory properties:
| Property | Description | Example |
|---|---|---|
| external.compute | Boolean value for specifying whether or not data-source is registered as an external compute platform. | true |
| external.compute.host.name | Name of the Databricks workspace. | adb-XXXXXXXXXXXXXX.XX.azuredatabricks.net |
| databricks.cluster.id | Databricks compute cluster id. | 0704-XXXXXX-XXXXXdir |
| stardog.host.url | Stardog URL to which Databricks should connect back to write the results. URL should point to the same Stardog server from where external compute operation is triggered. | https://myhost.stardog.cloud:5820 |
Optional properties:
| Property | Description | Default |
|---|---|---|
| stardog.external.jar.path | Path of the released stardog-spark-connector jar file from where the file should transfer to the Databricks cluster.By default it points to Stardog’s public S3 bucket, where the latest released version is available. There are two options for overriding the default path: 1) The jar can be downloaded from another s3 bucket. In this case, this should point to a custom s3 bucket path. 2) The jar can reside locally on the file system where the Stardog server is running. In this case, it should point to the local file system path. The Stardog server will upload the jar to the Databricks cluster if it is not present on the value specified by stardog.external.jar.upload.path property. Download the latest jar from this link | s3://stardog-spark/stardog-spark-connector-3.4.0.jar |
| stardog.external.jar.upload.path | Path of the stardog-spark-connector jar file on Databricks dbfs file system.Should be set both when the jar is uploaded manually by the user and when the jar is uploaded automatically by Stardog. | /FileStore/stardog/ |
| stardog.external.mapping.upload.path | Path on the dbfs where Stardog and spark job will write the temporary files. E.g., in the case of Virtual Graph Materialization operation, the mapping of the virtual graph will be stored here. Stardog and spark jobs will delete these temporary files after completing the process. | /FileStore/stardog/ |
| stardog.external.databricks.job.timeout | Spark job timeout property in seconds. | 86400 |
| stardog.external.databricks.task.timeout | Spark task timeout property in seconds. | 86400 |
| stardog.external.databricks.task.retry.count | The number of retries to attempt before the Spark job fails. Set to zero for a single attempt with no retries. | 3 |
| stardog.external.databricks.task.retry.interval.millis | Time interval after which Spark jobs make a retry attempt in case of an error. | 2000 |
| stardog.external.databricks.is.retry.timeout | Boolean value for specifying whether the Spark job makes a retry attempt or not in case of a timeout error. | false |
| stardog.external.databricks.job.on.start.email.list | Comma-separated list of emails to be notified when the Spark job stars. | |
| stardog.external.databricks.job.on.success.email.list | Comma-separated list of emails to be notified when the Spark job completes. | |
| stardog.external.databricks.job.on.failure.email.list | Comma-separated list of emails to be notified when the Spark job errors out. | |
| spark.dataset.repartition | Refer to spark-docs. Set this value to override the default partition behavior. | |
| external.compute.credentials.from.environment | Boolean value for specifying whether the Spark job reads the source database credential and the Stardog credential from the environment of the cluster it runs on instead of receiving them as job parameters. Requires stardog-spark-connector 3.4.0 or later. See Credentials from the cluster environment. | false |
| external.compute.job.write.buffer | Number of rows the Spark job collects before sending a batch to Stardog while writing results. Each Spark write partition opens one Stardog transaction and commits it when the partition finishes, so this controls how often rows are sent, not how often they are committed. A batch is held in memory by each running Spark task, so lower it when tasks run out of memory on wide rows, and raise it when the server is handling many small batches. | 500000 |
Credentials from the cluster environment
Stardog passes the Stardog credential and the source database password to the Databricks job as job parameters. Set external.compute.credentials.from.environment to true on the external compute data source to leave them out. The job then reads them from environment variables on the cluster, which you populate from a Databricks secret scope.
This requires stardog-spark-connector 3.4.0 or later.
Store the credentials in a secret scope
The job writes back to Stardog as a Stardog user. It can authenticate either with that user’s name and password, or with a token. Store one or the other: a job that finds both fails, because it cannot tell which to use.
A token is generated with the user token CLI command:
$ stardog-admin user token -u etl-service -p "..."
Create a scope in the Databricks workspace and put the Stardog credential and the source database credentials in it:
$ databricks secrets create-scope stardog-external-compute
$ databricks secrets put-secret stardog-external-compute stardog-token --string-value "eyJhbGciOiJIUzI1NiJ9..."
$ databricks secrets put-secret stardog-external-compute jdbc-user --string-value "reporting"
$ databricks secrets put-secret stardog-external-compute jdbc-password --string-value "..."
To authenticate with a password instead of a token, store stardog-username and stardog-password in the scope and leave stardog-token out.
Map the secrets into the cluster environment
On the cluster, under Advanced options > Spark > Environment variables, reference the secrets. The same values can be set through the spark_env_vars field of the Clusters API:
STARDOG_TOKEN={{secrets/stardog-external-compute/stardog-token}}
STARDOG_JDBC_USER={{secrets/stardog-external-compute/jdbc-user}}
STARDOG_JDBC_PASSWORD={{secrets/stardog-external-compute/jdbc-password}}
With a password instead of a token, set STARDOG_USERNAME and STARDOG_PASSWORD from the scope in place of STARDOG_TOKEN.
These are the variables the connector reads:
| Variable | Supplies |
|---|---|
STARDOG_USERNAME | The Stardog user name, used together with STARDOG_PASSWORD. |
STARDOG_PASSWORD | A Stardog credential that authenticates as a password. |
STARDOG_TOKEN | A Stardog credential that authenticates as a bearer token. |
STARDOG_JDBC_USER | The user name for the source database. |
STARDOG_JDBC_PASSWORD | The password for the source database. |
The variable that holds the credential decides how the job authenticates. A token authenticates as its own owner, so STARDOG_USERNAME is needed only alongside STARDOG_PASSWORD.
An environment value is used as it stands and is never decoded, so store each credential exactly as it was issued.
Databricks substitutes a {{secrets/scope/key}} reference when the cluster starts, so a rotated secret reaches the job only after the cluster is restarted. The substitution works in the cluster specification fields only, never in job parameters.
Spark’s spark.redaction.regex masks values whose key contains secret, password or token. The variable names above already match it, which keeps the values out of the Environment tab of the Spark UI.
Enable the property on the data source
Add the property to the external compute data source:
external.compute=true
external.compute.host.name=adb-XXXXXXXXXXXXXX.XX.azuredatabricks.net
databricks.cluster.id=0704-XXXXXX-XXXXXdir
stardog.host.url=https://myhost.stardog.cloud:5820
external.compute.credentials.from.environment=true
$ stardog-admin data-source add databricks.properties
The job authenticates to Stardog as the identity held in the secret scope rather than as the user who triggered the operation, so the write back to Stardog carries that identity’s permissions rather than the triggering user’s. Grant it only what the target database requires.