The problem I’m having
Database Error in test not_null_stg_snowflake__ach_detail_log_ach_code (models/staging/snowflake/_db__models.yml) 002003 (42S02): SQL compilation error: Object ‘[mydb].BIDS.stg_snowflake__ach_detail_log’ does not exist or not authorized. compiled code at target/run/[my_project]/models/staging/snowflake/_db__models.yml/not_null_stg_snowflake__ach_detail_log_ach_code.sql
The error above returns when i try to run a test in the deploy area. Tests run fine in the IDE, but when run in prod, the test is pointing to the default schema, as opposed to ‘bids_staging’ where this model actually lives.
The context of why I’m trying to do this
I’m trying to get the tests to flow through to the explore page - they show up as a test, but error out due to the model not existing in the default schema where it is looking.
What I’ve already tried
I’ve tried making the schema bids_staging in the project yml, and the model itself, and the test still fails. I’m not certain what is causing it to look in the target.default schema for the model instead of the location the model actually is in.
This is not an issue for any models that i have tests for that actually exist in my ‘bids’ or default schema. only bids_staging.
Some example code or error messages
models.yml example:
version: 2
models:
- name: stg_snowflake__ach_detail_log
description: '{{ doc("stg_snowflake__ach_detail_log") }}'
columns:
- name: ach_code
data_type: varchar
description: "Primary Key"
tests:
- not_null
- unique
project.yml
models:
my_project:
+materialized: "{{ 'table' if execute or target.name == 'prod' else 'view' }}"
+enabled: true
+tags: "all"
+schema: "{{ 'bids_staging' if target.name =='prod' and tag=='staging' else target.schema }}"
+full_refresh: "{{ false if tag==['noupdate'] else true}}"
staging:
+tags: 'staging'
+schema: "{{ 'bids_staging' if execute or target.name =='prod' else target.schema }}"
+materialized: view