airflow.providers.apache.spark.hooks.spark_submit

Module Contents

Classes

SparkSubmitHook

Wrap the spark-submit binary to kick off a spark-submit job; requires "spark-submit" binary in the PATH.

Attributes

ALLOWED_SPARK_BINARIES

airflow.providers.apache.spark.hooks.spark_submit.ALLOWED_SPARK_BINARIES = ['spark-submit', 'spark2-submit', 'spark3-submit'][source]
class airflow.providers.apache.spark.hooks.spark_submit.SparkSubmitHook(conf=None, conn_id='spark_default', files=None, py_files=None, archives=None, driver_class_path=None, jars=None, java_class=None, packages=None, exclude_packages=None, repositories=None, total_executor_cores=None, executor_cores=None, executor_memory=None, driver_memory=None, keytab=None, principal=None, proxy_user=None, name='default-name', num_executors=None, status_poll_interval=1, application_args=None, env_vars=None, verbose=False, spark_binary=None)[source]

Bases: airflow.hooks.base.BaseHook, airflow.utils.log.logging_mixin.LoggingMixin

Wrap the spark-submit binary to kick off a spark-submit job; requires “spark-submit” binary in the PATH.

Parameters
  • conf (dict[str, Any] | None) – Arbitrary Spark configuration properties

  • spark_conn_id – The spark connection id as configured in Airflow administration. When an invalid connection_id is supplied, it will default to yarn.

  • files (str | None) – Upload additional files to the executor running the job, separated by a comma. Files will be placed in the working directory of each executor. For example, serialized objects.

  • py_files (str | None) – Additional python files used by the job, can be .zip, .egg or .py.

  • archives (str | None) – Archives that spark should unzip (and possibly tag with #ALIAS) into the application working directory.

  • driver_class_path (str | None) – Additional, driver-specific, classpath settings.

  • jars (str | None) – Submit additional jars to upload and place them in executor classpath.

  • java_class (str | None) – the main class of the Java application

  • packages (str | None) – Comma-separated list of maven coordinates of jars to include on the driver and executor classpaths

  • exclude_packages (str | None) – Comma-separated list of maven coordinates of jars to exclude while resolving the dependencies provided in ‘packages’

  • repositories (str | None) – Comma-separated list of additional remote repositories to search for the maven coordinates given with ‘packages’

  • total_executor_cores (int | None) – (Standalone & Mesos only) Total cores for all executors (Default: all the available cores on the worker)

  • executor_cores (int | None) – (Standalone, YARN and Kubernetes only) Number of cores per executor (Default: 2)

  • executor_memory (str | None) – Memory per executor (e.g. 1000M, 2G) (Default: 1G)

  • driver_memory (str | None) – Memory allocated to the driver (e.g. 1000M, 2G) (Default: 1G)

  • keytab (str | None) – Full path to the file that contains the keytab

  • principal (str | None) – The name of the kerberos principal used for keytab

  • proxy_user (str | None) – User to impersonate when submitting the application

  • name (str) – Name of the job (default airflow-spark)

  • num_executors (int | None) – Number of executors to launch

  • status_poll_interval (int) – Seconds to wait between polls of driver status in cluster mode (Default: 1)

  • application_args (list[Any] | None) – Arguments for the application being submitted

  • env_vars (dict[str, Any] | None) – Environment variables for spark-submit. It supports yarn and k8s mode too.

  • verbose (bool) – Whether to pass the verbose flag to spark-submit process for debugging

  • spark_binary (str | None) – The command to use for spark submit. Some distros may use spark2-submit or spark3-submit.

conn_name_attr = 'conn_id'[source]
default_conn_name = 'spark_default'[source]
conn_type = 'spark'[source]
hook_name = 'Spark'[source]
static get_ui_field_behaviour()[source]

Returns custom field behaviour.

get_conn()[source]

Returns connection for the hook.

submit(application='', **kwargs)[source]

Remote Popen to execute the spark-submit job.

Parameters
  • application (str) – Submitted application, jar or py file

  • kwargs (Any) – extra arguments to Popen (see subprocess.Popen)

on_kill()[source]

Kill Spark submit command.

Was this entry helpful?