Integrating Cloudera Workflow Orchestrator with Livy

Create a connection to Cloudera Workflow Orchestrator with Livy.

For information about Apache Livy operators, see Apache Livy Operators documentation.
  • An existing Livy server is active and available.
  • Spark job files must be remotely accessible or present on the Livy server. Unlike spark-submit, Livy does not support uploading Spark job files from local storage. Therefore, you store these files in a remote location (for example, through S3, HDFS, or HTTP/HTTPS).
  1. Add the Airflow connection.

    Execute the following command using the command line in an Airflow pod to add the livy_default connection:

    airflow connections add 'livy_default' \
        --conn-type 'livy' \
        --conn-host '{[***URL-OF-THE-LIVY-SERVER***]}' \
        --conn-port '{[***PORT-OF-THE-LIVY-SERVER***]}' \
        --conn-login '{[***USERNAME-FOR-THE-LIVY-SERVER***]}' \
        --conn-password '{[***PASSWORD-FOR-THE-LIVY-SERVER***]}'
  2. Run a DAG from Airflow to start the Spark job.

    Example,

    from datetime import datetime
    from airflow import DAG
    from airflow.providers.apache.livy.operators.livy import LivyOperator
    
    with DAG(
        dag_id="test_provider_livy",
        default_args={"args": [10]},
        schedule=None,
        start_date=datetime(2026, 1, 1),
        catchup=False,
    ) as dag:
        livy_python_task = LivyOperator(
            task_id="pi_python_task", file="hdfs:///spark/jobs/pi.py", polling_interval=60
        )