leoflow_runtime.dbt

Map a managed Dexaflow/Airflow connection URI to a dbt profile (ADR 0043, #2).

Connections are delivered to the task pod as AIRFLOW_CONN_<ID> (an Airflow connection URI). A dbt task generates its profiles.yml from that at runtime, so no warehouse credential is baked into the image. Supports postgres, snowflake, bigquery, databricks (the official dbt-databricks adapter), and duckdb (embedded, for zero-server local development).

def dbt_profile_from_uri(uri: str) -> dict:

Map an Airflow connection URI to a dbt outputs.<target> block, dispatching by connection type. Supports postgres, snowflake, bigquery (google_cloud_platform), databricks, and duckdb; any other type is a loud error.

def write_dbt_profile( conn_id: str, profile_name: str, profiles_dir: str, env=None, schema=None) -> str:

Generate <profiles_dir>/profiles.yml from the AIRFLOW_CONN_<conn_id> the agent delivered, under the dbt project's profile_name. Written as JSON, which is valid YAML, so dbt reads it without us depending on PyYAML. Returns the written path; a missing connection is a loud error.

def write_dbt_default_duckdb(profile_name: str, profiles_dir: str, db_path: str = '') -> str:

Write a default duckdb profiles.yml, Dexaflow's zero-server local warehouse when a dbt group has no managed connection (Lite). An empty db_path is in-memory. Written as JSON (valid YAML) so dbt reads it with no PyYAML dependency.