Review Databricks spark_submit_task usage

Use a task type suited to the Databricks workload where possible.

Description

Databricks has deprecated spark_submit_task and restricts new use. Legacy tasks require a new cluster and a compatible older Databricks Runtime. They also restrict how you supply libraries and Spark settings.

Potential impact

An unsupported cluster or incompatible arguments can cause the job to fail.

Remediation

Use spark_jar_task for new JVM jobs and migrate existing JVM tasks to it. For other workloads, choose a suitable type such as spark_python_task or notebook_task. Carry over the entry point, arguments, libraries and runtime requirements, then verify the results.

Examples

The first excerpt is a legacy configuration. Its latest data source must resolve to a runtime that still supports Spark Submit. The second runs the same JAR and com.acme.data.Main on an existing shared cluster. The excerpts omit the JAR path variable var.application_jar, the data sources and the shared cluster definition.

Before

hcl
resource "databricks_job" "example" {
  name = "Job with multiple tasks"

  task {
    task_key = "b"
    new_cluster {
      num_workers   = 1
      spark_version = data.databricks_spark_version.latest.id
      node_type_id  = data.databricks_node_type.smallest.id
    }

    spark_submit_task {
      parameters = ["--class", "com.acme.data.Main", var.application_jar]
    }
  }
}

After

hcl
resource "databricks_job" "example" {
  name = "Job with multiple tasks"

  task {
    task_key            = "b"
    existing_cluster_id = databricks_cluster.shared.id

    library {
      jar = var.application_jar
    }

    spark_jar_task {
      main_class_name = "com.acme.data.Main"
    }
  }
}

References