Skip to content

Commit

Permalink
uhhhhh more diffs I guess?
Browse files Browse the repository at this point in the history
  • Loading branch information
edgao committed Dec 27, 2021
1 parent 62fb232 commit 026f3bb
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ input_data as (
-- NESTED_STREAM_WITH_COMPLEX_COLUMNS_RESULTING_INTO_LONG_NAMES from "AIRBYTE_DATABASE".TEST_NORMALIZATION._AIRBYTE_RAW_NESTED_STREAM_WITH_COMPLEX_COLUMNS_RESULTING_INTO_LONG_NAMES
),

input_data_with_active_row_num as (
select *,
row_number() over (
partition by ID
order by
DATE is null asc,
DATE desc,
_AIRBYTE_EMITTED_AT desc
) as _airbyte_active_row_num
from input_data
),
scd_data as (
-- SQL model to build a Type 2 Slowly Changing Dimension (SCD) table for each record identified by their primary key
select
Expand All @@ -31,17 +42,11 @@ scd_data as (
DATE desc,
_AIRBYTE_EMITTED_AT desc
) as _AIRBYTE_END_AT,
case when row_number() over (
partition by ID
order by
DATE is null asc,
DATE desc,
_AIRBYTE_EMITTED_AT desc
) = 1 then 1 else 0 end as _AIRBYTE_ACTIVE_ROW,
case when _airbyte_active_row_num = 1 then 1 else 0 end as _AIRBYTE_ACTIVE_ROW,
_AIRBYTE_AB_ID,
_AIRBYTE_EMITTED_AT,
_AIRBYTE_NESTED_STREAM_WITH_COMPLEX_COLUMNS_RESULTING_INTO_LONG_NAMES_HASHID
from input_data
from input_data_with_active_row_num
),
dedup_data as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ input_data as (
-- NESTED_STREAM_WITH_COMPLEX_COLUMNS_RESULTING_INTO_LONG_NAMES from {{ source('TEST_NORMALIZATION', '_AIRBYTE_RAW_NESTED_STREAM_WITH_COMPLEX_COLUMNS_RESULTING_INTO_LONG_NAMES') }}
),
{% endif %}
input_data_with_active_row_num as (
select *,
row_number() over (
partition by ID
order by
DATE is null asc,
DATE desc,
_AIRBYTE_EMITTED_AT desc
) as _airbyte_active_row_num
from input_data
),
scd_data as (
-- SQL model to build a Type 2 Slowly Changing Dimension (SCD) table for each record identified by their primary key
select
Expand All @@ -69,17 +80,11 @@ scd_data as (
DATE desc,
_AIRBYTE_EMITTED_AT desc
) as _AIRBYTE_END_AT,
case when row_number() over (
partition by ID
order by
DATE is null asc,
DATE desc,
_AIRBYTE_EMITTED_AT desc
) = 1 then 1 else 0 end as _AIRBYTE_ACTIVE_ROW,
case when _airbyte_active_row_num = 1 then 1 else 0 end as _AIRBYTE_ACTIVE_ROW,
_AIRBYTE_AB_ID,
_AIRBYTE_EMITTED_AT,
_AIRBYTE_NESTED_STREAM_WITH_COMPLEX_COLUMNS_RESULTING_INTO_LONG_NAMES_HASHID
from input_data
from input_data_with_active_row_num
),
dedup_data as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ input_data as (
-- DEDUP_EXCHANGE_RATE from "AIRBYTE_DATABASE".TEST_NORMALIZATION._AIRBYTE_RAW_DEDUP_EXCHANGE_RATE
),

input_data_with_active_row_num as (
select *,
row_number() over (
partition by ID, CURRENCY, cast(NZD as
varchar
)
order by
DATE is null asc,
DATE desc,
_AIRBYTE_EMITTED_AT desc
) as _airbyte_active_row_num
from input_data
),
scd_data as (
-- SQL model to build a Type 2 Slowly Changing Dimension (SCD) table for each record identified by their primary key
select
Expand Down Expand Up @@ -42,19 +55,11 @@ scd_data as (
DATE desc,
_AIRBYTE_EMITTED_AT desc
) as _AIRBYTE_END_AT,
case when row_number() over (
partition by ID, CURRENCY, cast(NZD as
varchar
)
order by
DATE is null asc,
DATE desc,
_AIRBYTE_EMITTED_AT desc
) = 1 then 1 else 0 end as _AIRBYTE_ACTIVE_ROW,
case when _airbyte_active_row_num = 1 then 1 else 0 end as _AIRBYTE_ACTIVE_ROW,
_AIRBYTE_AB_ID,
_AIRBYTE_EMITTED_AT,
_AIRBYTE_DEDUP_EXCHANGE_RATE_HASHID
from input_data
from input_data_with_active_row_num
),
dedup_data as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ input_data as (
-- DEDUP_EXCHANGE_RATE from {{ source('TEST_NORMALIZATION', '_AIRBYTE_RAW_DEDUP_EXCHANGE_RATE') }}
),
{% endif %}
input_data_with_active_row_num as (
select *,
row_number() over (
partition by ID, CURRENCY, cast(NZD as {{ dbt_utils.type_string() }})
order by
DATE is null asc,
DATE desc,
_AIRBYTE_EMITTED_AT desc
) as _airbyte_active_row_num
from input_data
),
scd_data as (
-- SQL model to build a Type 2 Slowly Changing Dimension (SCD) table for each record identified by their primary key
select
Expand All @@ -78,17 +89,11 @@ scd_data as (
DATE desc,
_AIRBYTE_EMITTED_AT desc
) as _AIRBYTE_END_AT,
case when row_number() over (
partition by ID, CURRENCY, cast(NZD as {{ dbt_utils.type_string() }})
order by
DATE is null asc,
DATE desc,
_AIRBYTE_EMITTED_AT desc
) = 1 then 1 else 0 end as _AIRBYTE_ACTIVE_ROW,
case when _airbyte_active_row_num = 1 then 1 else 0 end as _AIRBYTE_ACTIVE_ROW,
_AIRBYTE_AB_ID,
_AIRBYTE_EMITTED_AT,
_AIRBYTE_DEDUP_EXCHANGE_RATE_HASHID
from input_data
from input_data_with_active_row_num
),
dedup_data as (
select
Expand Down

0 comments on commit 026f3bb

Please sign in to comment.