Using the connection in a DAG
Use the CdeTriggerRunOperator operator from the
cloudera-airflow-provider-awc package (pre-installed in the Cloudera Workflow Orchestrator image). This operator triggers an existing job in the Cloudera Data Engineering engine and returns the run ID.
The CdeTriggerRunOperator triggers a run of a Cloudera Data Engineering job on a compute cluster within a Cloudera Data Engineering engine in Cloudera Anywhere Cloud through the Cloudera Data Engineering Job Management API. The job and its associated resources must
already be created using the Cloudera Data Engineering UI or the Job Management API.
The following table describes the arguments supported by
CdeTriggerRunOperator:
| Argument | Type | Description |
|---|---|---|
cde_conn_id |
str |
The Airflow connection ID for a Cloudera Data Engineering
connection in Anywhere Cloud. The default value is
awc_cde_default. |
job_name |
str |
Required. The name of the target job in the Cloudera Data Engineering service. This job must already exist in Cloudera Data Engineering. This field is templated. |
compute_id |
str |
Optional. The ID of the compute cluster on which the job runs. If
omitted, the operator uses the compute_id extra
configuration from the connection. If that is also missing, Cloudera Data Engineering runs it on the job's default compute
cluster. This field is templated. |
overrides |
dict |
Optional. A dictionary of job configuration values to override for
this run. The default value is {} (an empty
dictionary). This field is templated. For example, Cloudera Data Engineering validates these overrides upon submission. |
wait |
bool |
If set to True, the operator waits for the job run
to complete, and the task exit status reflects the status of the
completed run. If set to False, the task exit status
reflects only whether the run was triggered successfully. The default
value is True. |
timeout |
int |
The maximum time, in seconds, to wait for the job run to complete
when wait=True. If set to None,
0, or a negative number, the task never times out.
The job run is canceled when the timeout is reached. This timeout is
enforced by the operator (or by the trigger in deferrable mode)
independently of Airflow's execution_timeout parameter.
The default value is 0. |
job_poll_interval |
int |
The interval, in seconds, at which the operator polls the job run
status. The default value is 10. |
deferrable |
bool |
If set to True (and wait=True), the
operator submits the job run and defers execution so that a triggerer
polls the run asynchronously, freeing up the worker slot. At least one
Airflow triggerer service must be running. The default value is
False or the value of
operators.default_deferrable in
airflow.cfg. If the task is manually killed while
deferred, the Cloudera Data Engineering job continues running
in Airflow versions earlier than 3.3. |
durable |
bool |
If set to True, a retry of the task reconnects to
the run from the previous attempt instead of starting a new run. It
requires Airflow 3.3 or later. The default value is
True. |
The following examples provides different ways to use the Cloudera Data Engineering connection in your DAGs:
- Classic example: Trigger an existing Cloudera Data Engineering job on a specific compute cluster using
CdeTriggerRunOperator.from airflow.sdk import DAG from cloudera.awc.airflow.operators.cde import CdeTriggerRunOperator from pendulum import datetime with DAG( dag_id="cde_operator", start_date=datetime(2026, 1, 1, tz="UTC"), schedule=None, catchup=False, ): CdeTriggerRunOperator( task_id="run_cde_job", job_name="sparkpi", cde_conn_id="cde_connection", compute_id="cde-cluster-cde-compute", ) - Reusing one connection across compute clusters: Use a single
connection to run jobs on different compute clusters within the same Cloudera Data Engineering
engine.
from airflow.sdk import DAG from cloudera.awc.airflow.operators.cde import CdeTriggerRunOperator from pendulum import datetime with DAG( dag_id="cde_two_computes", start_date=datetime(2026, 1, 1, tz="UTC"), schedule=None, catchup=False, ): ingest = CdeTriggerRunOperator( task_id="ingest", job_name="ingest-job", cde_conn_id="cde_connection", compute_id="etl-compute", ) report = CdeTriggerRunOperator( task_id="report", job_name="report-job", cde_conn_id="cde_connection", compute_id="reporting-compute", timeout=3600, # cancel the run if it takes longer than an hour deferrable=True, ) ingest >> report - TaskFlow API example: Use the
@task.awc_cdedecorator to turn a Python function into aCdeTriggerRunOperatortask. When the task starts, the function runs and its return value (a job name string or a dictionary of operator arguments) sets the job configuration.from airflow.sdk import dag, task from pendulum import datetime @dag( dag_id="cde_taskflow", start_date=datetime(2026, 1, 1, tz="UTC"), schedule=None, catchup=False, ) def cde_taskflow(): # Every argument is set on the decorator; the function only names the job. @task.awc_cde(cde_conn_id="cde_connection", compute_id="etl-compute") def run_sparkpi() -> str: return "sparkpi" # The function picks the compute cluster and the Spark settings when the task runs. @task.awc_cde(cde_conn_id="cde_connection", deferrable=True) def run_report(logical_date=None) -> dict: weekend = logical_date is not None and logical_date.weekday() >= 5 return { "job_name": "report-job", "compute_id": "reporting-compute" if weekend else "etl-compute", "overrides": {"executorMemory": "8g" if weekend else "4g"}, } run_sparkpi() >> run_report() cde_taskflow()
