Building models against multiple environments.
creating models against different source databases and tables.
Hello,
I have a simple model that needs to run against different environs.
SELECT a.id, b.date
FROM {{ source(var('environment'), 'TABLE_A' ) }} a
INNER JOIN {{ source(var('environment'), 'TABLE_B') }} b
ON a.id = b.table_a_id
I have a simple sources.yaml
version: 2
sources:
- name: staging
database: staging
schema: finance
tables:
-name: table_a
## what I would think should work?
schema: sales
tables:
-name: table_b
when I call dbt run -m my_cool_model --vars "{'environment': 'staging'}"
I get an error saying that my model expects a reference for table B that does not exist.
Am I doing something stupid or is this a limitation that I need to work around?
essentially I want to have a var for staging, qa, pre-prod & prod
that I flip to hit multiple tables in different schemas but referenced from a single source.
any help would be much appreciated.