Skip to content

Commit 846a926

Browse files
authored
Merge pull request #250 from ScalefreeCOM/create-ghost-records-only-when-not-incremental
only create ghost records when it is not an incremental run
2 parents edceed4 + 34098fd commit 846a926

File tree

6 files changed

+12
-20
lines changed

6 files changed

+12
-20
lines changed

macros/staging/bigquery/stage.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ hashed_columns AS (
438438
{%- endif -%}
439439
{%- endif -%}
440440

441-
{% if enable_ghost_records %}
441+
{%- if enable_ghost_records and not is_incremental() %}
442442
{# Creating Ghost Record for unknown case, based on datatype #}
443443
unknown_values AS (
444444

@@ -597,7 +597,7 @@ columns_to_select AS (
597597

598598
FROM {{ last_cte }}
599599

600-
{%- if enable_ghost_records %}
600+
{%- if enable_ghost_records and not is_incremental() %}
601601
UNION ALL
602602

603603
SELECT

macros/staging/exasol/stage.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ hashed_columns AS (
426426
{%- endif -%}
427427
{%- endif -%}
428428

429-
{% if enable_ghost_records %}
429+
{%- if enable_ghost_records and not is_incremental() %}
430430
{# Creating Ghost Record for unknown case, based on datatype #}
431431
unknown_values AS (
432432
SELECT
@@ -580,7 +580,7 @@ columns_to_select AS (
580580

581581
FROM {{ last_cte }}
582582

583-
{%- if enable_ghost_records %}
583+
{%- if enable_ghost_records and not is_incremental() %}
584584
UNION ALL
585585
SELECT
586586

macros/staging/postgres/stage.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ hashed_columns AS (
438438
{%- endif -%}
439439
{%- endif -%}
440440

441-
{%- if enable_ghost_records -%}
441+
{%- if enable_ghost_records and not is_incremental() %}
442442
{# Creating Ghost Record for unknown case, based on datatype #}
443443
unknown_values AS (
444444

@@ -597,7 +597,7 @@ columns_to_select AS (
597597

598598
FROM {{ last_cte }}
599599

600-
{% if enable_ghost_records %}
600+
{%- if enable_ghost_records and not is_incremental() %}
601601
UNION ALL
602602

603603
SELECT

macros/staging/redshift/stage.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ hashed_columns AS (
447447
{%- endif -%}
448448
{%- endif -%}
449449

450-
{%- if enable_ghost_records -%}
450+
{%- if enable_ghost_records and not is_incremental() %}
451451
{# Creating Ghost Record for unknown case, based on datatype #}
452452
unknown_values AS (
453453

@@ -606,7 +606,7 @@ columns_to_select AS (
606606

607607
FROM {{ last_cte }}
608608

609-
{%- if enable_ghost_records %}
609+
{%- if enable_ghost_records and not is_incremental() %}
610610
UNION ALL
611611

612612
SELECT

macros/staging/snowflake/stage.sql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@ hashed_columns AS (
389389
{%- endif -%}
390390
{%- endif -%}
391391

392-
{% if enable_ghost_records %}
393-
{% if not is_incremental() %}
392+
{%- if enable_ghost_records and not is_incremental() %}
394393
{# Creating Ghost Record for unknown case, based on datatype #}
395394
unknown_values AS (
396395

@@ -535,7 +534,6 @@ ghost_records AS (
535534
SELECT * FROM error_values
536535
),
537536
{%- endif %}
538-
{%- endif %}
539537

540538
{%- if not include_source_columns -%}
541539
{% set source_columns_to_select = datavault4dbt.process_columns_to_select(columns_list=source_columns_to_select, exclude_columns_list=derived_column_names) %}
@@ -551,16 +549,14 @@ columns_to_select AS (
551549

552550
FROM {{ last_cte }}
553551

554-
{% if enable_ghost_records %}
555-
{% if not is_incremental() %}
552+
{%- if enable_ghost_records and not is_incremental() %}
556553
UNION ALL
557554

558555
SELECT
559556

560557
{{ datavault4dbt.print_list(datavault4dbt.escape_column_names(final_columns_to_select)) }}
561558

562559
FROM ghost_records
563-
{% endif %}
564560
{% endif %}
565561
)
566562

macros/staging/synapse/stage.sql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ hashed_columns AS (
439439
{% set processed_hash_columns = datavault4dbt.process_hash_column_excludes(hashed_columns) -%}
440440
{%- endif -%}
441441

442-
{% if enable_ghost_records %}
443-
{% if not is_incremental() %}
442+
{%- if enable_ghost_records and not is_incremental() %}
444443
{# Creating Ghost Record for unknown case, based on datatype #}
445444
unknown_values AS (
446445

@@ -585,7 +584,6 @@ ghost_records AS (
585584
SELECT * FROM error_values
586585
),
587586
{%- endif %}
588-
{%- endif %}
589587

590588
{%- if not include_source_columns -%}
591589
{% set final_columns_to_select = datavault4dbt.process_columns_to_select(columns_list=final_columns_to_select, exclude_columns_list=source_columns_to_select) %}
@@ -600,16 +598,14 @@ columns_to_select AS (
600598

601599
FROM {{ last_cte }}
602600

603-
{% if enable_ghost_records %}
604-
{% if not is_incremental() %}
601+
{%- if enable_ghost_records and not is_incremental() %}
605602
UNION ALL
606603

607604
SELECT
608605

609606
{{ datavault4dbt.print_list(datavault4dbt.escape_column_names(final_columns_to_select)) }}
610607

611608
FROM ghost_records
612-
{% endif %}
613609
{% endif %}
614610
)
615611

0 commit comments

Comments
 (0)