🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Databricks Provider Integration with Airflow

đŸŸĸ Free Lesson

Advertisement

Databricks Provider Integration with Airflow

Airflow-Databricks IntegrationAirflowSchedulerDatabricksHookAPI authREST APIJobs & ClustersClusterCompute layerData LakeS3 / ADLS / GCSSubmitRunOperatorSubmit Spark jobsNotebookOperatorRun notebooksRunNowOperatorTrigger existing jobsJobSensorWait for job completionUse DatabricksSubmitRun for new jobs; RunNow for existing job triggers

Architecture Diagram

Formal Definitions

Detailed Explanation

Databricks Integration Overview

The Databricks provider enables Airflow to orchestrate Spark jobs, notebooks, and cluster operations on Databricks. It abstracts the complexity of the Databricks REST API.

Key Insight: Use DatabricksRunNowOperator for long-running jobs (>30 min) to avoid the 15-minute timeout on SubmitRunOperator.

Operator Selection Guide

OperatorUse CaseCreates ClusterPolling
DatabricksSubmitRunOperatorSubmit new jobYes or existingYes
DatabricksNotebookOperatorRun notebookYes or existingYes
DatabricksRunNowOperatorTrigger existing jobNoOptional
DatabricksJobSensorWait for jobNoYes
DatabricksClusterLifeCycleOperatorStart/stop clusterNoYes

Connection Setup

DatabricksSubmitRunOperator

The primary operator for submitting new Databricks jobs. It creates a new cluster or uses an existing one, submits the job, and monitors until completion.

DatabricksNotebookOperator

Execute Databricks notebooks as part of Airflow workflows.

DatabricksRunNowOperator

Trigger an existing Databricks job by ID.

Sensor for Job Completion

Full ETL Pipeline

Key Concepts Table

OperatorPurposeCreates ClusterPolling
DatabricksSubmitRunOperatorSubmit new jobYes or existingYes
DatabricksNotebookOperatorRun notebookYes or existingYes
DatabricksRunNowOperatorTrigger existing jobNoOptional
DatabricksJobSensorWait for jobNoYes
DatabricksClusterLifeCycleOperatorStart/stop/restart clusterNoYes

Configuration Reference

ParameterDescriptionExample
databricks_conn_idAirflow connection IDdatabricks_default
new_clusterCluster spec for new cluster{'spark_version': '13.3.x', ...}
existing_cluster_idReuse existing cluster0123-456789-abcdef
spark_jar_taskJAR-based job definition{'main_class_name': '...'}
notebook_taskNotebook-based job{'notebook_path': '...'}
timeout_secondsMax wait time3600
polling_period_secondsPoll interval30
json_paramsJob parameters{'key': 'value'}

Best Practices

Cluster Management

  1. Use existing clusters when possible — cluster startup can take 5-10 minutes.
  2. Tag clusters with team/project for cost tracking and management.
  3. Monitor job runs through Databricks job history and Airflow task logs.

Operator Configuration

  1. Set timeout_seconds on all operators to prevent indefinite waits.
  2. Use mode='reschedule' on sensors to free worker slots during waits.
  3. Use libraries for dependency management — wheel files, pip packages, or maven coordinates.

Error Handling

  1. Handle TERMINATED_WITH_ERRORS state with retries and failure callbacks.
  2. Leverage json_params for dynamic job parameterization via Jinja templates.

Cost Optimization

StrategyImpactImplementation
Reuse clusters5-10 min faster startupSet existing_cluster_id
Auto-terminate idle clustersReduce costsConfigure in Databricks
Use spot instances60-70% cost reductionSet in cluster config
Right-size clustersOptimize resource usageMonitor utilization metrics

See Also

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Airflow Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement