The problem I’m having
I have created a snapshot model. which looks fine. But I need to create another snapshot based on snapshot Already I have created, Question is can I do this, If I do is there any chance to be created duplicate surrogate key or not
The context of why I’m trying to do this
My initial snapshot working fine, I need to create a snapshot model based of category
What I’ve already tried
Already I have created first my snapshot “dim_invoicelinetext” and I have used that snapshot in the current snapshot "dim_invoiceline_category " - My query Is there any chance to be generate duplicate surrogate key in "dim_invoiceline_category "
Some example code or error messages
{% snapshot dim_invoiceline_category %}
{{
config(
target_schema=env_var('TARGET_SCHEMA'),
strategy='check',
unique_key='billlineid',
check_cols=[
'invoicelinecategory',
],
)
}}
select {{ dbt_utils.generate_surrogate_key([
'billlineid',
'invoicelinecategory']) }}
as invoiceline_category_key,
billlineid,
invoicelinecategory
from (
SELECT
billlineid :: int as billlineid,
(
CASE
WHEN item ='Reverse RO in Unit Rate' AND pricename = 'Reverse RO in Unit Rate' THEN 'Renewables Obligation (RO)'
WHEN item = 'Reverse BSUoS in Unit Rate' AND pricename = 'Reverse BSUoS in Unit Rate' THEN 'Balancing Services Use of System (BSUoS)'
ELSE pricename
END
) :: varchar(255) as "invoicelinecategory"
FROM
{{ ref('dim_invoicelinetext') }} ) as dim_invoiceline_category
{% endsnapshot %}```