Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refkey not null patch #189

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions macros/tables/bigquery/ref_hub.sql
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,19 @@ WITH
{{ src_ldts }},
{{ src_rsrc }}
FROM {{ ref(source_model.name) }} src

WHERE NOT (
{% for ref_key in source_model['ref_keys'] -%}
{{ ref_key}} IS NULL {%- if not loop.last %} AND {% endif -%}
{% endfor -%} )

{%- if is_incremental() and ns.has_rsrc_static_defined and ns.source_included_before[source_number] %}
INNER JOIN max_ldts_per_rsrc_static_in_target max ON
({%- for rsrc_static in rsrc_statics -%}
max.rsrc_static = '{{ rsrc_static }}'
{%- if not loop.last -%} OR
{% endif -%}
{%- endfor %})
WHERE src.{{ src_ldts }} > max.max_ldts
AND src.{{ src_ldts }} > max.max_ldts
{%- endif %}

{%- set ns.last_cte = "src_new_{}".format(source_number) %}
Expand Down
8 changes: 6 additions & 2 deletions macros/tables/exasol/ref_hub.sql
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,19 @@ WITH
{{ src_ldts }},
{{ src_rsrc }}
FROM {{ ref(source_model.name) }} src

WHERE NOT (
{% for ref_key in source_model['ref_keys'] -%}
{{ ref_key}} IS NULL {%- if not loop.last %} AND {% endif -%}
{% endfor -%} )

{%- if is_incremental() and ns.has_rsrc_static_defined and ns.source_included_before[source_number] %}
INNER JOIN max_ldts_per_rsrc_static_in_target max ON
({%- for rsrc_static in rsrc_statics -%}
max.rsrc_static = '{{ rsrc_static }}'
{%- if not loop.last -%} OR
{% endif -%}
{%- endfor %})
WHERE src.{{ src_ldts }} > max.max_ldts
AND src.{{ src_ldts }} > max.max_ldts
{%- endif %}

{%- set ns.last_cte = "src_new_{}".format(source_number) %}
Expand Down
6 changes: 5 additions & 1 deletion macros/tables/postgres/ref_hub.sql
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ WITH
{{ src_ldts }},
{{ src_rsrc }}
FROM {{ ref(source_model.name) }} src
WHERE NOT (
{% for ref_key in source_model['ref_keys'] -%}
{{ ref_key}} IS NULL {%- if not loop.last %} AND {% endif -%}
{% endfor -%} )

{%- if is_incremental() and ns.has_rsrc_static_defined and ns.source_included_before[source_number] %}
INNER JOIN max_ldts_per_rsrc_static_in_target max ON
Expand All @@ -149,7 +153,7 @@ WITH
{%- if not loop.last -%} OR
{% endif -%}
{%- endfor %})
WHERE src.{{ src_ldts }} > max.max_ldts
AND src.{{ src_ldts }} > max.max_ldts
{%- endif %}

{%- set ns.last_cte = "src_new_{}".format(source_number) %}
Expand Down
6 changes: 5 additions & 1 deletion macros/tables/redshift/ref_hub.sql
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ WITH
{{ src_ldts }},
{{ src_rsrc }}
FROM {{ ref(source_model.name) }} src
WHERE NOT (
{% for ref_key in source_model['ref_keys'] -%}
{{ ref_key}} IS NULL {%- if not loop.last %} AND {% endif -%}
{% endfor -%} )

{%- if is_incremental() and ns.has_rsrc_static_defined and ns.source_included_before[source_number] %}
INNER JOIN max_ldts_per_rsrc_static_in_target max ON
Expand All @@ -149,7 +153,7 @@ WITH
{%- if not loop.last -%} OR
{% endif -%}
{%- endfor %})
WHERE src.{{ src_ldts }} > max.max_ldts
AND src.{{ src_ldts }} > max.max_ldts
{%- endif %}

{%- set ns.last_cte = "src_new_{}".format(source_number) %}
Expand Down
6 changes: 5 additions & 1 deletion macros/tables/snowflake/ref_hub.sql
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ WITH
{{ src_ldts }},
{{ src_rsrc }}
FROM {{ ref(source_model.name) }} src
WHERE NOT (
{% for ref_key in source_model['ref_keys'] -%}
{{ ref_key}} IS NULL {%- if not loop.last %} AND {% endif -%}
{% endfor -%} )

{%- if is_incremental() and ns.has_rsrc_static_defined and ns.source_included_before[source_number] %}
INNER JOIN max_ldts_per_rsrc_static_in_target max ON
Expand All @@ -149,7 +153,7 @@ WITH
{%- if not loop.last -%} OR
{% endif -%}
{%- endfor %})
WHERE src.{{ src_ldts }} > max.max_ldts
AND src.{{ src_ldts }} > max.max_ldts
{%- endif %}

{%- set ns.last_cte = "src_new_{}".format(source_number) %}
Expand Down
8 changes: 6 additions & 2 deletions macros/tables/synapse/ref_hub.sql
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ WITH
{{ src_ldts }},
{{ src_rsrc }}
FROM {{ ref(source_model.name) }} src
WHERE NOT (
{% for ref_key in source_model['ref_keys'] -%}
{{ ref_key}} IS NULL {%- if not loop.last %} AND {% endif -%}
{% endfor -%} )

{%- if is_incremental() and ns.has_rsrc_static_defined and ns.source_included_before[source_number|int] and not disable_hwm %}
INNER JOIN max_ldts_per_rsrc_static_in_target max ON
Expand All @@ -152,9 +156,9 @@ WITH
{%- if not loop.last -%} OR
{% endif -%}
{%- endfor %})
WHERE src.{{ src_ldts }} > max.max_ldts
AND src.{{ src_ldts }} > max.max_ldts
{%- elif is_incremental() and source_models | length == 1 and not ns.has_rsrc_static_defined and not disable_hwm %}
WHERE src.{{ src_ldts }} > (
AND src.{{ src_ldts }} > (
SELECT COALESCE(MAX({{ src_ldts }}), {{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }})
FROM {{ this }}
WHERE {{ src_ldts }} != {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }}
Expand Down