airflow.contrib.operators.spark_sql_operator

Module Contents

class airflow.contrib.operators.spark_sql_operator.SparkSqlOperator(sql, conf=None, conn_id='spark_sql_default', total_executor_cores=None, executor_cores=None, executor_memory=None, keytab=None, principal=None, master='yarn', name='default-name', num_executors=None, yarn_queue='default', *args, **kwargs)[source]

Bases: airflow.models.BaseOperator

Execute Spark SQL query

Parameters
  • sql (str) – The SQL query to execute. (templated)

  • conf (str (format: PROP=VALUE)) – arbitrary Spark configuration property

  • conn_id (str) – connection_id string

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

  • executor_cores (int) – (Standalone & YARN only) Number of cores per executor (Default: 2)

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

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

  • master (str) – spark://host:port, mesos://host:port, yarn, or local

  • name (str) – Name of the job

  • num_executors (int) – Number of executors to launch

  • verbose (bool) – Whether to pass the verbose flag to spark-sql

  • yarn_queue (str) – The YARN queue to submit to (Default: “default”)

template_fields = ['_sql'][source]
template_ext = ['.sql', '.hql'][source]
execute(self, context)[source]

Call the SparkSqlHook to run the provided sql query

on_kill(self)[source]