-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from Opetushallitus/OK-729__SUREn-siirtotiedos…
…toja Luotu Organisaation pub-taulut
- Loading branch information
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
dbt/models/int/int_yleiskayttoiset/int_organisaatio_rakenne.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |