please help me resolve this problem: below are my source defined under schema.yml (along with two other models) –>
sources:
- name: src_pizzas
database: test_db
schema: pizza
tables:
- name: src_sqlserver_pizzas
columns:
- name: size
description: "The size of the pizza"
- name: price
.......
then I have this model under models/example directory as tsnfrmed_sqlserver_pizzas.sql :
{{ config(materialized='view') }}
SELECT
UPPER(size) AS size,
UPPER(price) AS price,
UPPER(pizza_id) AS pizza_id,
UPPER(pizza_type_id) AS pizza_type_id
FROM {{ source('src_pizzas', 'src_sqlserver_pizzas') }}
now when I run –>
dbt run --select "tsnfrmed_sqlserver_pizzas"
I get below error (table name and connection are all fine, as I have other models making connections, I cannot rule out typo type problems here):
Model 'model.pizza_data.tsnfrmed_sqlserver_pizzas' (modelsexampletsnfrmed_sqlserver_pizzas.sql) depends on a source named 'pizza.src_sqlserver_pizzas' which was not found
2
Answers
I am posting answer to my own question. but the problem was human error, and others can face it as well. below are three things I was doing wrong caused the issue.
In the model's directory - I had no subdirectories and I was referencing all models to one single schema.yml file like below (I think dbt didn't like both sources and models mentioned in one single schema.yml file - I later created a separate subdirectory for sources and models and had separate schema.yml defined in them for sources and models.
version: 2
sources:
models:
Indentation was causing issues as well in schema.yml
This is dumb but I was making my changes and running dbt test before dbt run. I was of the opinion (and wrong off course) that dbt should allow me to test it first and run it later. DBT runs test against views table, which are created as result of dbt run. so doing that in that order
It appears there isn’t a table named
src_sqlserver_pizzas
in that schema. You’ll want to add anidentifier:
to the YML to specify the table name of the source.