Hi, i’m new in dbt .
I want to run different models with different targets at dbt cloud. I saw the command :
" dbt run --select model.sql --target dev "
This command line works in dbt core, but when I tried to do it at dbt cloud , it doesn’t run my model in the target called dev, it takes the default one.
I have tried doing dbt debug --target dev to see the connection but also got errors in dbt cloud (but no at dbt core):
“No matching handler found for rpc method None (which=debug)”
I want to work at dbt cloud because it easier for me to set jobs, so how can I fix it?
Hello,
Modify the value of target in the dbt cloud environments… when you create a new env the target is set to a value equal to default… you can change it to dev
To handle multiple targets in dbt models you need to use jinja macros
First, thank you for your answer but as I said, I´m a new developer on dbt and I´d like to understand better about environments… from what you said, or at least, from what I understood, we can only define one schema target per environment? That is, if I need to work with different taget schemas do I have to create an environment for each schema? On the other hand to work with different targets in the same environment I could use jinja macros… but how can I do this? I looked in the documentation and didn’t find anything about this. Is there some variable environment or similar? I´m sorry if my questions are too basic…
I´ve found a way to solve my problem… first I deleted macro get_custom_schema from macro´s directory. Then I create three different outputs for my target in my profile.yml:
I ´ve created 3 main models: marts, staging and raw. When I run the models from marts, I just pass --target prd. In the case of staging, just add the --target stg parameter to the dbt run. But in the case of raw, I have different datasets with “Raw” as the dataset prefix… like: raw_googleads, raw_facebookads and so on.
In this case, for each submodel created below the Raw model, I define the schema:schema_name and then the dbt understands that I am providing a custom_schema and creates the dataset using the target_name that I defined: Raw, adding the schema_name defined in schema.
I’m sure this might not be the best solution but it’s the one I managed to find and I’m sharing it with you guys. If anyone wants more details or wants to collaborate with other solutions, feel free to comment here.