The error
Database Error in model section2 (models\example\section2.sql)
column "section1" does not exist
LINE 9: FROM ref( section1 ) S1
^
My project directory
/dbtxyz/models/example/section1.sql
/dbtxyz/models/example/section2.sql
/dbtxyz/project.yml
/dbtxyz/profile.yml
My profile.yml
default:
outputs:
dev:
type: "postgres"
host: "localhost"
user: "postgres"
password: "password"
port: 5432
dbname: "myprojectdata"
schema: "myprojectdataschema"
target: "dev"
My project.yml
analysis-paths:
- analyses
clean-targets:
- target
- dbt_packages
config-version: 2
macro-paths:
- macros
model-paths:
- models
models:
dbtsample:
example:
+materialized: view
name: dbtxyz
profile: default
seed-paths:
- seeds
snapshot-paths:
- snapshots
test-paths:
- tests
vars:
leverage: 123
version: 1.0.0
The section1.sql
{{ config(materialized='table') }}
{% set leverage= var('leverage') %}
WITH
section1 AS (
SELECT
T0.* FROM table0 T0
WHERE T0."leverage" > {{ leverage }}
)
SELECT * FROM section1
This is section2.sql
{{ config(materialized='table') }}
WITH
section2 AS (
SELECT
T1.*,
S1.*
FROM
ref( {{section1}} ) S1
JOIN table1 T1
ON S1."id" = T1."id"
)
SELECT * FROM section2
Because section1 is the first model in my chain of models, and now broken, it's backlogging everything.
This is the first time this has happened to me. I've never done dbt with postgresql before, so there's probably new things I'm not aware of.
Has anyone gotten this before as well?
Your syntax in section2.sql
is a bit tangled. Try:
{{ ref('section1') }}