Skip to content

Commit

Permalink
bug on first launch
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoN7 committed May 12, 2023
1 parent 03d14ab commit 88c2631
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions macros/materializations/incremental_stream.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ DROP STREAM IF EXISTS {{target_stream}};
{#-- CREATE OBJECTS (STREAM, TABLE) IF NOT EXISTS --#}
CREATE STREAM IF NOT EXISTS {{target_stream}} ON TABLE {{source_table}} APPEND_ONLY=TRUE;

CREATE TABLE IF NOT EXISTS {{ this }} AS SELECT * FROM {{target_view}};

{%- set v_count = 0 -%}
{%- if full_refresh_mode %}
{% set relation_exists = load_relation(this) is not none %}
{%- if full_refresh_mode or not relation_exists%}
CREATE OR REPLACE VIEW {{target_view}}
AS ({{ sql }});
INSERT INTO {{this}} SELECT * FROM {{target_view}};
CREATE TABLE IF NOT EXISTS {{ this }} AS SELECT * FROM {{target_view}};
{%- else -%}
{#-- Check the presence of records to merge --#}
{%- set v_count -%}
Expand All @@ -53,7 +52,6 @@ INSERT INTO {{this}} SELECT * FROM {{target_view}};
{%- set v_count = 0 -%}
{%- endif -%}


{{ log(" => " +v_count | string + " record(s) to merge" , info=True) }}
{%- endif -%}

Expand Down

0 comments on commit 88c2631

Please sign in to comment.