cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Spark & Scala version in Cluster node initialization script

ahuarte
New Contributor III

Hi there,

I am developing a Cluster node initialization script (https://docs.gcp.databricks.com/clusters/init-scripts.html#environment-variables) in order to install some custom libraries.

Reading the docs of Databricks we can get some environment variables with data related with the current running cluster node.

But I need to figure out what Spark & Scala version is currently been deployed. Is this possible?

Thanks in advance

Regards

18 REPLIES 18

Anonymous
Not applicable

Thank you so much! Would you be happy to mark whichever answer is best in your mind? That will help new members know which is the most effective.

User16764241763
Honored Contributor

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

sean_owen
Honored Contributor II
Honored Contributor II

The question is about an init script though

Lingesh
New Contributor III

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