User16764241763
Databricks Employee
Databricks Employee

You should be able to just pick the version that matches Spark and Scala from maven.

Here is a simple way to get the cluster Spark version

image

The question is about an init script though

Lingesh
Databricks Employee
Databricks Employee

We can infer the cluster DBR version using the env $DATABRICKS_RUNTIME_VERSION. (For the exact spark/scala version mapping, you can refer to the specific DBR release notes)

Sample usage inside a init script,

DBR_10_4_VERSION="10.4"
if [[ "$DATABRICKS_RUNTIME_VERSION" == "$DBR_10_4_VERSION"* ]]; then
  echo "running 10.4 specific commands"
else
  echo "Skipping 10.4 specific commands"
fi