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

Luotu Organisaation pub-taulut #70

Merged
merged 1 commit into from
Nov 26, 2024
Merged
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
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
Loading