Skip to content

Commit

Permalink
Merge pull request #81 from Opetushallitus/OK-773__korjattu-stg-malleja
Browse files Browse the repository at this point in the history
Ok 773  korjattu stg malleja
  • Loading branch information
razze76 authored Dec 18, 2024
2 parents 9afb0b2 + 51f65fa commit d71f761
Show file tree
Hide file tree
Showing 48 changed files with 100 additions and 82 deletions.
2 changes: 2 additions & 0 deletions dbt/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
target/
dbt_packages/
logs/
.*
!.gitignore
2 changes: 1 addition & 1 deletion dbt/models/int/int_organisaatio.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int as (
org1.oppilaitosnumero,
org1.alkupvm,
org1.lakkautuspvm
from organisaatio as org1
from organisaatio as org1
left join ylempi_toimipiste as ylto on org1.ylempi_organisaatio = ylto.organisaatio_oid
),

Expand Down
4 changes: 1 addition & 3 deletions dbt/models/int/int_sure/int_sure_arvosana.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ with raw as (
),

int as (
select
*
from raw
select * from raw
where row_nr = 1
),

Expand Down
4 changes: 1 addition & 3 deletions dbt/models/int/int_sure/int_sure_ensikertalainen.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
}}

with int as (
select
*
from {{ ref('dw_sure_ensikertalainen') }}
select * from {{ ref('dw_sure_ensikertalainen') }}
),

final as (
Expand Down
4 changes: 1 addition & 3 deletions dbt/models/int/int_sure/int_sure_opiskelija.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ with raw as (
),

int as (
select
*
from raw
select * from raw
where row_nr = 1
),

Expand Down
4 changes: 1 addition & 3 deletions dbt/models/int/int_sure/int_sure_opiskeluoikeus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ with raw as (
),

int as (
select
*
from raw
select * from raw
where row_nr = 1
),

Expand Down
4 changes: 1 addition & 3 deletions dbt/models/int/int_sure/int_sure_suoritus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ with raw as (
),

int as (
select
*
from raw
select * from raw
where row_nr = 1
),

Expand Down
42 changes: 21 additions & 21 deletions dbt/models/int/int_valintaperusteet_valintatapajono.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ existing_rows as (
select * from {{ this }}
where hakukohde_oid in (select hakukohde_oid from valintatapajonoja)
{% else %}
select
null as jono_id,
null as valinnanvaihe_id,
null as hakukohde_oid,
null as nimi,
null as kuvaus,
null::int as aloituspaikat,
null as tyyppi_uri,
null::int as prioriteetti,
null::boolean as siirretaan_sijoitteluun,
null as tasasijasaanto,
null::timestamptz as ei_lasketa_paivamaaran_jalkeen,
null::boolean as ei_varasijatayttoa,
null::boolean as merkitse_myoh_auto,
null::boolean as poissa_oleva_taytto,
null::boolean as kaikki_ehdon_tayttavat_hyvaksytaan,
null::boolean as kaytetaan_valintalaskentaa,
null::boolean as valmis_sijoiteltavaksi,
null::boolean as valisijoittelu,
null::boolean as poistetaanko_hylatyt,
null::jsonb as jarjestyskriteerit
select
null as jono_id,
null as valinnanvaihe_id,
null as hakukohde_oid,
null as nimi,
null as kuvaus,
null::int as aloituspaikat,
null as tyyppi_uri,
null::int as prioriteetti,
null::boolean as siirretaan_sijoitteluun,
null as tasasijasaanto,
null::timestamptz as ei_lasketa_paivamaaran_jalkeen,
null::boolean as ei_varasijatayttoa,
null::boolean as merkitse_myoh_auto,
null::boolean as poissa_oleva_taytto,
null::boolean as kaikki_ehdon_tayttavat_hyvaksytaan,
null::boolean as kaytetaan_valintalaskentaa,
null::boolean as valmis_sijoiteltavaksi,
null::boolean as valisijoittelu,
null::boolean as poistetaanko_hylatyt,
null::jsonb as jarjestyskriteerit
{% endif %}
)

Expand Down
4 changes: 2 additions & 2 deletions dbt/models/pub/pub_dim_ensikertalainen.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int as (
isensikertalainen,
menettamisenperuste,
menettamisenpaivamaara
from ensikertalainen
from ensikertalainen
)

select * from int
select * from int
4 changes: 2 additions & 2 deletions dbt/models/pub/pub_dim_organisaatio.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}}

with source as (
select * from {{ ref('int_organisaatio') }}
select * from {{ ref('int_organisaatio') }}
),

final as (
Expand All @@ -27,4 +27,4 @@ final as (
from source
)

select * from final
select * from final
8 changes: 4 additions & 4 deletions dbt/models/pub/pub_dim_yo_arvosana.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}}

with arvosana as (
select * from {{ ref('int_sure_arvosana') }} where asteikko='YO'
select * from {{ ref('int_sure_arvosana') }} where asteikko = 'YO'
),

suoritus as (
Expand All @@ -32,10 +32,10 @@ int as (
arvosana.source,
arvosana.jarjestys,
arvosana.arvot,
suoritus.henkilooid as henkilooid,
suoritus.tila as tila,
suoritus.henkilooid,
suoritus.tila,
suoritus.valmistuminen as pvm
from arvosana
from arvosana
left join suoritus on arvosana.suoritus = suoritus.resourceid
)

Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_ataru_hakemus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_ataru_lomake.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ with source as (
select * from {{ source('ovara', 'ataru_lomake') }}

{% if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})
{% endif %}
),

Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_hakukohderyhmapalvelu_ryhma.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_ammattinimike.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_asiasana.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_haku.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_hakukohde.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_koulutus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_oppilaitoksetjaosat.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
4 changes: 3 additions & 1 deletion dbt/models/stg/stg_kouta_pistehistoria.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ with source as ( --noqa: PRS
select * from {{ source('ovara', 'kouta_pistehistoria') }}

{%- if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }} )

where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif -%}
),

Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_sorakuvaus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_toteutus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_kouta_valintaperuste.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/stg/stg_ohjausparametrit_parameter.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
4 changes: 3 additions & 1 deletion dbt/models/stg/stg_sure_arvosana.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ with source as (
select * from {{ source('ovara', 'sure_arvosana') }}

{% if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})

where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),

Expand Down
4 changes: 3 additions & 1 deletion dbt/models/stg/stg_sure_ensikertalainen.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ with source as (
select * from {{ source('ovara', 'sure_ensikertalainen') }}

{% if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})

where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),

Expand Down
4 changes: 3 additions & 1 deletion dbt/models/stg/stg_sure_harkinnanvaraisuus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ with source as (
select * from {{ source('ovara', 'sure_harkinnanvaraisuus') }}

{% if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})

where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),

Expand Down
4 changes: 3 additions & 1 deletion dbt/models/stg/stg_sure_opiskelija.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ with source as (
select * from {{ source('ovara', 'sure_opiskelija') }}

{% if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})

where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),

Expand Down
4 changes: 3 additions & 1 deletion dbt/models/stg/stg_sure_opiskeluoikeus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ with source as (
select * from {{ source('ovara', 'sure_opiskeluoikeus') }}

{% if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})

where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),

Expand Down
4 changes: 3 additions & 1 deletion dbt/models/stg/stg_sure_proxysuoritus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ with source as (
select * from {{ source('ovara', 'sure_proxysuoritus') }}

{% if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})

where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),

Expand Down
4 changes: 3 additions & 1 deletion dbt/models/stg/stg_sure_suoritus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ with source as (
select * from {{ source('ovara', 'sure_suoritus') }}

{% if is_incremental() %}
where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})

where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with source as (

{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ with source as (
select * from {{ source('ovara', 'valintalaskenta_valintalaskennan_tulos') }}
{% if is_incremental() %}

where dw_metadata_dbt_copied_at > (select max(dw_metadata_dbt_copied_at) from {{ this }})
where dw_metadata_dbt_copied_at > (select coalesce(max(dw_metadata_dbt_copied_at), '1899-12-31') from {{ this }})

{% endif %}

Expand Down
Loading

0 comments on commit d71f761

Please sign in to comment.