I cannot figure out why the source will not find the table in my database. How do I fix this error?
Context:
I have a table in the postgres database: Let's say it's called "my_table". It is in "my_schema".
When I try to select from the table by using the sql code below, but it produces an error.
select * from {{source('my_schema', 'my_table')}}
Compilation Error in model my_data (models\source\my_data.sql)
Model 'model.testdbt.my_data' (models\source\my_data.sql) depends on a source named 'my_schema.my_table' which was not found
I did actually make a .yml file to handle this.
sources.yml
version: 2
sources:
- name: my_database
schema: my_schema
tables:
- name: my_table
Two things here:
So if you have the folllowing:
# This is your source.yml file
version: 2
sources:
- name: my_source_name
database: my_database
schema: my_schema
tables:
- name: my_table
Then your model should look like this:
with source as (
select * from {{ source('my_source_name', 'my_table') }}
)
[...]