Implementation:Astronomer Astronomer cosmos SnowflakeBaseProfileMapping
| Knowledge Sources | |
|---|---|
| Domains | Profile_Mapping, Snowflake |
| Last Updated | 2026-02-07 17:00 GMT |
Overview
Abstract base class for all Snowflake profile mappings in astronomer-cosmos.
Description
The SnowflakeBaseProfileMapping extends `BaseProfileMapping` and serves as the base class for all Snowflake-specific profile mapping variants (user/password, key pair, etc.). It provides shared utility methods that are common to all Snowflake authentication methods:
- transform_account() -- normalises the Snowflake account identifier by stripping the full URL suffix (e.g. `.snowflakecomputing.com`) so that dbt receives the short account name it expects.
- _decode_private_key_content() -- decodes a base64-encoded private key from the Airflow connection extras, used by key-pair authentication subclasses.
Concrete Snowflake profile mappings inherit from this class rather than directly from `BaseProfileMapping`.
Usage
This class is not used directly. Instead, instantiate one of its concrete subclasses (e.g. `SnowflakeUserPasswordProfileMapping`, `SnowflakeEncryptedPrivateKeyPemProfileMapping`) and assign it to `ProfileConfig(profile_mapping=...)`.
Code Reference
Source Location
- Repository: Astronomer_Astronomer_cosmos
- File: cosmos/profiles/snowflake/base.py
Signature
class SnowflakeBaseProfileMapping(BaseProfileMapping):
airflow_connection_type: str = "snowflake"
dbt_profile_type: str = "snowflake"
Key Methods
def transform_account(self, account: str) -> str:
"""Strip .snowflakecomputing.com suffix from account identifier."""
...
def _decode_private_key_content(self) -> str | None:
"""Decode base64-encoded private key from connection extras."""
...
Import
from cosmos.profiles.snowflake.base import SnowflakeBaseProfileMapping
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| conn_id | str | Yes | Airflow connection ID for Snowflake |
Outputs
| Name | Type | Description |
|---|---|---|
| profile | dict | dbt profile YAML dictionary (provided by subclasses) |
| env_vars | dict | Environment variables for secret fields (provided by subclasses) |
Usage Examples
# SnowflakeBaseProfileMapping is not instantiated directly.
# Use a concrete subclass instead:
from cosmos.config import ProfileConfig
from cosmos.profiles.snowflake import SnowflakeUserPasswordProfileMapping
profile_config = ProfileConfig(
profile_name="default",
target_name="dev",
profile_mapping=SnowflakeUserPasswordProfileMapping(conn_id="snowflake_default"),
)