I'm using the command line tool called dbt. The whole project is somewhat complicated, so I'll try to describe the basic layout.
Here's my abbreviated file tree;
dbt_project.yml
.user.yml
dbt_modules
models/baz/subdir/baz_mytable.sql
models/sources/baz/baz_myinfo.sql
profiles.yml
Here are the abbreviated contents of dbt_project.yml
. The directories of both relevant .sql files are referenced, and dependencies within parallel folder structures are being picked up.
name: 'my_proj'
version: '1.0'
source-paths: ["models"]
modules-path: "dbt_modules"
...
models:
my_proj:
...
baz:
subdir:
materialized: table
schema: baz_final
sources:
baz:
materialized: view
schema: baz_cleaned
...
Here are the abbreviated contents of baz_myinfo.sql
;
{{ config(alias='myinfo') }}
SELECT ...
Here are the abbreviated contents of baz_mytable.sql
;
WITH sometable AS (
SELECT ... FROM {{ ref('myinfo') }} ...
Given all this, when I run the dbt command, I get the error Model 'model.my_proj.baz_mytable' depends on model 'myinfo' which was not found or is disabled
None of my models are disabled. Why isn't dbt picking up the dependency?
According to the dbt docs, the call to ref
should use the filename of the model, and not the alias of the model in that file. So the contents of baz_mytable.sql
should look like
WITH sometable AS (
SELECT ... FROM {{ ref('baz_myinfo') }} ...
since the file is named baz_myinfo.sql
.