Closed jack-cook-repo closed 4 months ago
Thanks for opening this issue @jack-cook-repo! Sorry for the late reply but I've only just found the time to fix this properly. Really appreciate all the extra detail you included, it helped me to hone in on the problem much quicker 🙌
I'll try open a PR and release a new version of the package tomorrow. You're welcome to upgrade and try it or continue as-is with your workaround.
I use env schemas, and implemented this package by updating the
generate_schema_name
macro. But, it seemed to not work in models where I was callingref
against a snapshot.This is how my variables were set up in
dbt_project.yml
:This is how my macro was set up:
All of our snapshots have this in the config block at the top:
When I tried to
dbt run
a model that had aref()
pointing at a snapshot,raise_ref_not_found_error
raised this:From inspecting it, it looked like it was resolving
{{ ref('snapshot__...') }}
tomy_project.dbt_production.snapshot__...
rather than resolving it to the config value oftarget_schema
. I needed the ref to resolve tomy_project.snapshots.snapshot__...
.As a hacky workaround, I added this clause to the top of my
generate_schema_name
macro:This got everything working again. I'm not exactly sure why my new configuration including
is_upstream_prod
broke the step in dbt core where it forces the schema to be written totarget_schema
.