-
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 #86 from Opetushallitus/OK-602__pub-kerroksen-korj…
…auksia Muutettu dw_onr_henkilo tauluksi jotta saadaan parempi suorituskyky
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,35 @@ | ||
{# | ||
{%- set stage_model = ref('stg_onr_henkilo') -%} | ||
{%- set key_columns_list = ['henkilo_oid'] -%} | ||
|
||
{{ generate_dw_model_muokattu(stage_model, key_columns_list) }} | ||
|
||
#} | ||
|
||
{{ | ||
config( | ||
materialized = 'table', | ||
indexes = [ | ||
{'columns': ['henkilo_oid']} | ||
] | ||
) | ||
}} | ||
|
||
with raw as ( | ||
select | ||
*, | ||
row_number() over (partition by henkilo_oid order by dw_metadata_stg_stored_at desc) as rownr | ||
from {{ ref('stg_onr_henkilo') }} | ||
), | ||
|
||
final as ( | ||
select | ||
{{ dbt_utils.star(from=ref('stg_onr_henkilo')) }}, | ||
current_timestamp as dw_metadata_dw_stored_at | ||
from raw | ||
where rownr =1 | ||
) | ||
|
||
select * from final | ||
|
||
|