Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to execute spark job using SparkSubmitOperator

Tags:

airflow

I am able to run Spark job using BashOperator but I want to use SparkSubmitOperator for it using Spark standalone mode.


Here's my DAG for SparkSubmitOperator and stack-trace

args = {
    'owner': 'airflow',
    'start_date': datetime(2018, 5, 24)
}
dag = DAG('spark_job', default_args=args, schedule_interval="*/10 * * * *")

operator = SparkSubmitOperator(
    task_id='spark_submit_job',
    application='/home/ubuntu/test.py',
    total_executor_cores='1',
    executor_cores='1',
    executor_memory='2g',
    num_executors='1',
    name='airflow-spark',
    verbose=False,
    driver_memory='1g',
    conf={'master':'spark://xx.xx.xx.xx:7077'},
    dag=dag,
)

Looking at source for spark_submit_hook it seems _resolve_connection() always sets master=yarn. How can I change master properties value by Spark standalone master URL? Which properties I can set to run Spark job in standalone mode?

like image 408
mandar Avatar asked May 25 '18 15:05

mandar


1 Answers

You can either create a new connection using the Airflow Web UI or change the spark-default connection.

Change Spark-default connection in Airflo

Master can be local, yarn, spark://HOST:PORT, mesos://HOST:PORT and k8s://https://<HOST>:<PORT>.

You can also supply the following commands in the extras:

{"queue": "root.default", "deploy_mode": "cluster", "spark_home": "", "spark_binary": "spark-submit", "namespace": "default"}

Airflow Spark Submit Extras

Either the "spark-submit" binary should be in the PATH or the spark-home is set in the extra on the connection.

like image 90
kaxil Avatar answered Oct 06 '22 07:10

kaxil