Implementation:Astronomer Astronomer cosmos DatabricksTokenProfileMapping
| 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 (token method) provided by astronomer-cosmos.
Description
The DatabricksTokenProfileMapping maps an Airflow databricks connection to a dbt databricks profile using personal access token authentication. It translates the connection host, password (used as the token), and extras (http_path, schema) into the YAML structure that dbt expects in `profiles.yml`. The token is treated as a secret field and passed via an environment variable at runtime.
Usage
Use this profile mapping when configuring Cosmos to run dbt commands against a Databricks backend with token-based authentication. Assign it to `ProfileConfig(profile_mapping=...)` when the target Airflow connection uses the `databricks` connection type.
Code Reference
Source Location
- Repository: Astronomer_Astronomer_cosmos
- File: cosmos/profiles/databricks/token.py
Signature
class DatabricksTokenProfileMapping(BaseProfileMapping):
airflow_connection_type: str = "databricks"
dbt_profile_type: str = "databricks"
Import
from cosmos.profiles.databricks import DatabricksTokenProfileMapping
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 DatabricksTokenProfileMapping
profile_config = ProfileConfig(
profile_name="default",
target_name="dev",
profile_mapping=DatabricksTokenProfileMapping(conn_id="databricks_default"),
)