Skip to content
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
15 changes: 14 additions & 1 deletion macros/tables/bigquery/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ current_status AS (
{{ is_active_alias }},
{{ src_rsrc }}
FROM {{ this }}
QUALIFY
WHERE {{ src_ldts }} NOT IN ({{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }}, {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }})
QUALIFY
ROW_NUMBER() OVER(PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) = 1

),
Expand Down Expand Up @@ -321,6 +322,18 @@ records_to_insert AS (
) disappeared_hashkeys
{%- endif %}

UNION ALL
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ({{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }}, {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }})

)

SELECT
Expand Down
15 changes: 14 additions & 1 deletion macros/tables/databricks/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ current_status AS (
{{ is_active_alias }},
{{ src_rsrc }}
FROM {{ this }}
QUALIFY
WHERE {{ src_ldts }} NOT IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')
QUALIFY
ROW_NUMBER() OVER(PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) = 1

),
Expand Down Expand Up @@ -315,6 +316,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

)

SELECT
Expand Down
15 changes: 14 additions & 1 deletion macros/tables/exasol/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ current_status AS (
{{ is_active_alias }},
{{ src_rsrc }}
FROM {{ this }}
QUALIFY
WHERE {{ src_ldts }} NOT IN ({{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }}, {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }})
QUALIFY
ROW_NUMBER() OVER(PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) = 1

),
Expand Down Expand Up @@ -313,6 +314,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ({{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }}, {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }})

)

SELECT
Expand Down
13 changes: 13 additions & 0 deletions macros/tables/fabric/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ current_status_prep AS (
{{ src_rsrc }},
ROW_NUMBER() OVER (PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) as rn
FROM {{ this }}
WHERE {{ src_ldts }} NOT IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

),

Expand Down Expand Up @@ -349,6 +350,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

)

SELECT
Expand Down
13 changes: 13 additions & 0 deletions macros/tables/oracle/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ current_status_prep AS (
{{ src_rsrc }},
ROW_NUMBER() OVER (PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) as rn
FROM {{ this }}
WHERE {{ src_ldts }} NOT IN ({{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }}, {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }})

),

Expand Down Expand Up @@ -349,6 +350,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ({{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }}, {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }})

)

SELECT
Expand Down
13 changes: 13 additions & 0 deletions macros/tables/postgres/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ current_status_prep AS (
{{ src_rsrc }},
ROW_NUMBER() OVER (PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) as rn
FROM {{ this }}
WHERE {{ src_ldts }} NOT IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

),

Expand Down Expand Up @@ -349,6 +350,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

)

SELECT
Expand Down
15 changes: 14 additions & 1 deletion macros/tables/redshift/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ current_status AS (
{{ is_active_alias }},
{{ src_rsrc }}
FROM {{ this }} redshift_requires_an_alias_if_the_qualify_is_directly_after_the_from
QUALIFY ROW_NUMBER() OVER(PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) = 1
WHERE {{ src_ldts }} NOT IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')
QUALIFY ROW_NUMBER() OVER(PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) = 1

),
{% endif %}
Expand Down Expand Up @@ -319,6 +320,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

)

SELECT
Expand Down
15 changes: 14 additions & 1 deletion macros/tables/snowflake/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ current_status AS (
{{ is_active_alias }},
{{ src_rsrc }}
FROM {{ this }}
WHERE {{ src_ldts }} NOT IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')
QUALIFY
ROW_NUMBER() OVER(PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) = 1

Expand Down Expand Up @@ -319,6 +320,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

)

SELECT
Expand All @@ -340,4 +353,4 @@ WHERE NOT EXISTS (
)
{% endif %}

{%- endmacro -%}
{%- endmacro -%}
13 changes: 13 additions & 0 deletions macros/tables/sqlserver/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ current_status_prep AS (
{{ src_rsrc }},
ROW_NUMBER() OVER (PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) as rn
FROM {{ this }}
WHERE {{ src_ldts }} NOT IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

),

Expand Down Expand Up @@ -349,6 +350,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

)

SELECT
Expand Down
13 changes: 13 additions & 0 deletions macros/tables/synapse/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ current_status_prep AS (
{{ src_rsrc }},
ROW_NUMBER() OVER (PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) as rn
FROM {{ this }}
WHERE {{ src_ldts }} NOT IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

),

Expand Down Expand Up @@ -349,6 +350,18 @@ records_to_insert AS (

{%- endif %}

UNION
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ('{{ datavault4dbt.beginning_of_all_times() }}', '{{ datavault4dbt.end_of_all_times() }}')

)

SELECT
Expand Down
13 changes: 13 additions & 0 deletions macros/tables/trino/eff_sat_v0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ current_status AS (
{{ src_rsrc }},
ROW_NUMBER() OVER(PARTITION BY {{ tracked_hashkey }} ORDER BY {{ src_ldts }} DESC) as rn
FROM {{ this }}
WHERE {{ src_ldts }} NOT IN ({{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }}, {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }})
) t
WHERE rn = 1

Expand Down Expand Up @@ -331,6 +332,18 @@ records_to_insert AS (
) disappeared_hashkeys
{%- endif %}

UNION ALL
SELECT
{{ tracked_hashkey }},
{% for col in additional_columns -%}
{{ col }},
{% endfor -%}
{{ src_ldts }},
{{ src_rsrc }},
1 as {{ is_active_alias }}
Comment thread
tkiehn marked this conversation as resolved.
FROM {{ source_relation }} src
WHERE {{ src_ldts }} IN ({{ datavault4dbt.string_to_timestamp(timestamp_format, beginning_of_all_times) }}, {{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }})

)

SELECT
Expand Down
Loading