Reputation: 41
Is there a way to change the target dataset on BigQuery based on the file path location with dbt?
For example:
project models contextA contextB
There are two datasets on BigQuery: datasetA and datasetB
I would like to save the models inside folder contextA in the dataset called datasetA and the ones inside contextB in the dataset contextB dynamically, without considering the target in profiles.yml.
I've tried to do it with that macro called generate_alias_name, but without success.
Upvotes: 1
Views: 1460
Reputation: 2332
You can do this in dbt_project.yml
. In the models folder, you will have folders contextA
and contextB
. Then in dbt_project.yml
, you will add this:
models:
project_name:
contextA:
schema: datasetA
contextB:
schema: datasetB
You can do this even with nested folders:
contextA:
schema: datasetA
another_folder_in_contextA_that_saves_models_to_a_different_dataset:
schema: another_dataset
contextB:
schema: datasetB
Upvotes: 1