dbt-msft / dbt-sqlserver

dbt adapter for SQL Server and Azure SQL
MIT License
216 stars 101 forks source link

Snapshots which target different databases do not materialize correctly #536

Closed cody-scott closed 2 months ago

cody-scott commented 2 months ago

A snapshot with a config target_database that is different then the profile fails when run.

Temp snapshot view is created in the primary database, but the snapshot expects it in the secondary database, which fails with it being unable to find the temp view.

{% snapshot claims_snapshot %}

{{
   config(
       target_database='TestDB_Secondary',
       target_schema='dbo',
       unique_key='id',

       strategy='timestamp',
       updated_at='updated_at',
   )
}}

select * from {{source('mysource', 'claims')}}

{% endsnapshot %}

In this example mysource is in the primary database, but the snapshot is being created in the secondary TestDB_Secondary

cody-scott commented 2 months ago

https://github.com/dbt-msft/dbt-sqlserver/discussions/516#discussioncomment-10539287