Databricks - Load data - Apache Airflow Load Control
Applies to
Platform: Databricks
Load the deployed Databricks solution with Apache Airflow by running the DAG that the generator writes. The DAG has one task per loader, runs them in dependency order and starts for each one a Databricks job that runs the loader notebook. Afterwards the Graph of the run shows the state of every loader task.
The DAG is written for Apache Airflow 2. It uses DatabricksRunNowOperator of the provider apache-airflow-providers-databricks and the Airflow connection databricks_default.
Prerequisites
- LoadControl Options contains
Airflow, and Configure LoadControl istrue. - The
databricks_jobplaceholders are replaced, see Databricks - Placeholder values, and the artifacts are deployed without errors. - An Airflow 2 environment with the Databricks provider, for example the one of Apache Airflow - Load control environment.
- A Databricks personal access token of the user the jobs run as.
Create the Databricks jobs
The folder LoadControl of the artifacts holds one job file <loader>_Loader_Job.json per loader. The DAG starts these jobs by name.
- Download deploy_jobs.ps1 into the artifacts folder, next to
LoadControl:
- Open PowerShell 7 in the artifacts folder and run:
.\deploy_jobs.ps1 -databricksAccountName <workspace host> ` -jobsFolderName LoadControl -databricksToken <token>
Here<workspace host>is the host name of the workspace URL withouthttps://, and<token>the personal access token. - Check the output. For each job file, the script prints
creating job <job name>. A job with the same name is deleted first:job already present, removing <job name>.
Run the DAG
- Copy
LoadControl\<project>_dag.pyinto the folderdagsof Airflow.<project>is the project name in lower case without spaces, with underscores for dots; the DAG ID is the file name without_dag.py. - In the Airflow UI, open Admin, choose Connections and select + (Add a new record).


- Enter the connection:
- Connection Id:
databricks_default - Connection Type: Databricks
- Host: the workspace URL,
https://<workspace host> - Login: leave it empty
- Password: the personal access token

- Connection Id:
- Select Test; it shows
Connection successfully testedwhen Airflow reaches the workspace. Then select Save.


- Open DAGs and switch on the toggle left of the DAG.

- Select Trigger DAG in the column Actions.

All tasks of a DAG run pass the same load timestamp to their loaders: the logical date of the run. The DAG has no schedule; it runs when you trigger it. After each loader task, a task log_<loader> prints the result of the Databricks job run.
Check the result
Select the DAG, then the run, and open the tab Graph. The run succeeded when every task shows the state success:

The log of each log_<loader> task prints the link to the Databricks job run. In Databricks, the result views show the rows, for example SELECT COUNT(*), MAX(bg_loadtimestamp) FROM <catalog>.rawvault.rdv_hub_<hub>_result;.
Example
The DAG test_vaultandmart_spark_databricks of a Data Vault and Mart project has one task per loader between the tasks begin and end:
run_rdv_hub_bdc_customer_loader = DatabricksRunNowOperator(
task_id='RDV_HUB_BDC_CUSTOMER_Loader',
databricks_conn_id='databricks_default',
job_name='RDV_HUB_BDC_CUSTOMER_Loader_Job',
notebook_params={'bg_loadtimestamp':
"{{ logical_date.strftime('%Y-%m-%d %H:%M:%S.%f') }}"}
)
Its job RDV_HUB_BDC_CUSTOMER_Loader_Job runs the notebook <notebook_task_path>RDV_HUB_BDC_CUSTOMER_Loader on the cluster of existing_cluster_id.
Failure symptoms and recovery
A task fails because the job does not exist
Cause: deploy_jobs.ps1 did not run, or ran in another workspace than the connection names.
Fix: Run it as in Create the Databricks jobs, then clear the failed task and its downstream tasks in the Graph.
The job does not find the loader notebook
Cause: notebook_task_path does not point to the folder Jupyter of the uploaded artifacts, or lacks the trailing slash.
Fix: Correct notebook_task_path in replacement_config.json, unzip the artifacts again, replace the placeholders and rerun deploy_jobs.ps1.
The DAG shows an import error
Cause: The Airflow environment has no Databricks provider, or it runs Airflow 3, which no longer accepts the DAG parameters schedule_interval and concurrency.
Fix: Use an Airflow 2 environment with apache-airflow-providers-databricks, as described in Apache Airflow - Load control environment.
For failures in other steps, see Troubleshoot generation, deployment and load failures.
Related articles
- Previous: Databricks - Deployment, Apache Airflow - Load control environment
- Reference: LoadControl Options (Project), Configure LoadControl (Project), Databricks - Placeholder values
- See also: Understand Load Control, Databricks - Load data - Native Load Control, Databricks - Artifacts