Skip to content

Commit

Permalink
Merge pull request #70 from Opetushallitus/OK-729__SUREn-siirtotiedos…
Browse files Browse the repository at this point in the history
…toja

Luotu Organisaation pub-taulut
  • Loading branch information
razze76 authored Nov 26, 2024
2 parents 75645ac + f903764 commit 7932da7
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dbt/models/int/int_yleiskayttoiset/int_organisaatio_rakenne.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{
config(
materialized = 'table',
indexes = [
{'columns':['parent_oid']}
]
)
}}

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

org (parent_oid, child_oid) as (
select
ylempi_organisaatio as parent_oid,
organisaatio_oid as child_oid
from organisaatio

union all

select
orga.parent_oid,
org2.organisaatio_oid as child_oid
from organisaatio as org2
inner join org as orga on orga.child_oid = org2.ylempi_organisaatio
)

select
parent_oid,
child_oid
from org
29 changes: 29 additions & 0 deletions dbt/models/pub/_pub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,32 @@ models:
- name: kansalaisuusluokka
description: "Kenttä kansalaisuuden filtteröintiin. Arvot: 1 = Suomi, 2 = EU/ETA, 3 = muut"
data_type: integer
- name: pub_dim_organisaatio
description: Tämä taului sisältää organisaation tiedot
columns:
- name: organisaatio_oid
data_type: text
description: Organisaation oid
data_tests:
- dbt_constraints.primary_key
- name: organisaatio_nimi
description: Organisaation lokalisoidut nimet
data_type: jsonb
- name: sijaintikunta
data_type: text
- name: sijaintikunta_nimi
data_type: jsonb
- name: opetuskielet
data_type: jsonb
- name: organisaatiotyypit
data_type: jsonb
- name: tila
data_type: text
- name: pub_dim_organisaatio_rakenne
description:
Tämä taulu sisältää kaikki organisaatiot, ja kaikki hierarkiassa niiden alla olevat organisaatiot riippumatta tasosta.
columns:
- name: parent_oid
data_type: text
- name: child_oid
data_type: text
26 changes: 26 additions & 0 deletions dbt/models/pub/pub_dim_organisaatio.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{
config(
materialized = 'table',
indexes = [
{'columns':['organisaatio_oid']}
]
)
}}

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

final as (
select
organisaatio_oid,
organisaatio_nimi,
sijaintikunta,
sijaintikunta_nimi,
opetuskielet,
organisaatiotyypit,
tila
from source
)

select * from final
17 changes: 17 additions & 0 deletions dbt/models/pub/pub_dim_organisaatio_rakenne.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{
config(
materialized = 'table',
indexes = [
{'columns':['parent_oid']}
]
)
}}

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

select
parent_oid,
child_oid
from source

0 comments on commit 7932da7

Please sign in to comment.