How to make a schema run on a different profile.

Currently I have set-up a medaillon structure in dbt. Using dbt core. I have 3 different catalogs in Databricks for Bronze - Silver - Gold as my target. I have also set-up a containerized instance of dbt that will run the models. However I am not able to set-up multiple commands for that container. So when I execute dbt run on that container on a schedule, it will use the default target. Which is Bronze in this case, specified in the dbt_project.yml

What I want is, that when the Bronze schema are run, it will use profile A, when the silver schema models are run, it will use profile B and when the gold schema runs it will use profile C, which are all defined in the profiles.yml.

I am thinking I should put all schemas into 1 catalog…

But in the article it says:

If you have different data catalogs/schemas for your source data depending on your environment, you can use the target.name to change the data catalog/schema you’re pulling from depending on the environment.

Unfortunately I do not understand how this translates. Because if I look at the example code:

sources:

  • name: source_name
    database: |
    {%- if target.name == “dev” -%} raw_dev
    {%- elif target.name == “qa” -%} raw_qa
    {%- elif target.name == “prod” -%} raw_prod
    {%- else -%} invalid_database
    {%- endif -%}
    schema: source_schema

Database in this case will be catalog. But then I also need to specify a schema.

I know it is possible manually with the -t argument. I am wondering if I can automate this per schema, like how I can specify that everything in bronze needs to be materialized as a table. If I can do this in another way please let me know.

Thanks for your help in advance, I hope I made myself clear :slight_smile: