'dbt depends on a source not found

Could you please help me with this issue?

Encountered an error:
Compilation Error in model metrics_model (models\example\metrics_model.sql)
  Model 'model.test_project.metrics_model' (models\example\metrics_model.sql) depends on a source named 'automate.metrics' which was not found

I am having this monotonous error, which I have not been able to solve.

Many thanks beforehand!

dbt


Solution 1:[1]

This is due to the automate.metrics table missing from the database (either the dbt project’s target database or a different database on the same server). There should be a source.yml or automate.yml file somewhere in your project that defines the source. FYI automate is the schema name and metrics is the table name.

  1. If the source yml file specifies a database for the automate schema, query that database to make sure that the metrics table exists in the automate schema.
  2. If the source yml file doesn’t list a database, then that schema / table should exist in the dbt project’s target database. You can see what the target database is by looking at the profile for your project setup in ~/.dbt/profiles.yml.

Solution 2:[2]

For PostgreSQL database please check if the sources.yml file is defined as follows:

version: 2
sources:
  - name: name_of the source
    schema: name_of_the_schema
    quoting:
      database: false
      schema: false
      identifier: false
    loader: stitch
    tables:
      - name: name_of_table1
      - name: name_of_table2

Solution 3:[3]

Are you seeing this in your dev environment? It's possible that you've not run dbt run after creating the automate.metrics which is preventing metrics_model from referencing it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Philip
Solution 2 Daniel K Malungu
Solution 3 ostrino