Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Astronomer Astronomer cosmos DatabricksOauthProfileMapping

From Leeroopedia


Knowledge Sources
Domains Profile_Mapping, Databricks
Last Updated 2026-02-07 17:00 GMT

Overview

Concrete tool for mapping Airflow databricks connections to dbt databricks profiles (OAuth method) provided by astronomer-cosmos.

Description

The DatabricksOauthProfileMapping maps an Airflow databricks connection to a dbt databricks profile using OAuth authentication. It translates connection parameters (host, extras containing http_path, client_id, client_secret) into the YAML structure that dbt expects in `profiles.yml`. OAuth credentials are treated as secret fields and passed via environment variables at runtime.

Usage

Use this profile mapping when configuring Cosmos to run dbt commands against a Databricks backend with OAuth (M2M or U2M) authentication. Assign it to `ProfileConfig(profile_mapping=...)` when the target Airflow connection uses the `databricks` connection type.

Code Reference

Source Location

Signature

class DatabricksOauthProfileMapping(BaseProfileMapping):
    airflow_connection_type: str = "databricks"
    dbt_profile_type: str = "databricks"

Import

from cosmos.profiles.databricks import DatabricksOauthProfileMapping

I/O Contract

Inputs

Name Type Required Description
conn_id str Yes Airflow connection ID for Databricks

Outputs

Name Type Description
profile dict dbt profile YAML dictionary
env_vars dict Environment variables for secret fields

Usage Examples

from cosmos.config import ProfileConfig
from cosmos.profiles.databricks import DatabricksOauthProfileMapping

profile_config = ProfileConfig(
    profile_name="default",
    target_name="dev",
    profile_mapping=DatabricksOauthProfileMapping(conn_id="databricks_default"),
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment