-
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.
Resolve "Rang de temps del gràfic Evolució mes a mes" (et/somenergia-…
…jardiner!110) Closes #166 Merge branch '166-rang-de-temps-del-grafic-evolucio-mes-a-mes' into 'main'
- Loading branch information
Showing
7 changed files
with
87 additions
and
78 deletions.
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
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
60 changes: 19 additions & 41 deletions
60
dbt_jardiner/models/jardiner/marts/dm_dashboard_overview_monthly.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 |
---|---|---|
@@ -1,47 +1,25 @@ | ||
{{ config(materialized='view') }} | ||
|
||
|
||
with production_target as ( | ||
{# totals do not distinguish by technology, they could #} | ||
with production_monthly_w_target as ( | ||
select | ||
month, | ||
sum(energy_production_target_mwh) as total_energy_production_target_mwh | ||
from {{ ref("int_production_target__monthly") }} | ||
group by month | ||
), production_target_w_cumsum as ( | ||
select | ||
month, | ||
total_energy_production_target_mwh, | ||
sum(total_energy_production_target_mwh) over (order by month) as total_cumsum_energy_production_target_mwh | ||
from production_target | ||
), production_monthly as ( | ||
select | ||
month, | ||
tecnologia, | ||
sum(energia_instantania_inversor_mwh) as total_energia_instantania_inversores_mwh, | ||
sum(energia_exportada_instantania_comptador_mwh) as total_energia_exportada_instantania_comptadores_mwh, | ||
sum(energia_exportada_comptador_mwh) as total_energia_exportada_comptadores_mwh, | ||
sum(energia_esperada_solargis_mwh) as total_energia_esperada_solargis_mwh, | ||
sum(abs(energia_perduda_mwh)) as total_energia_perduda_mwh, | ||
max(preu_omie_eur_mwh) as preu_omie_eur_mwh | ||
from {{ ref("dm_plant_production_monthly") }} | ||
group by month, tecnologia | ||
), | ||
production_with_target as ( | ||
select | ||
production_target_w_cumsum.month, | ||
production_monthly.tecnologia, | ||
production_monthly.total_energia_instantania_inversores_mwh, | ||
production_monthly.total_energia_exportada_instantania_comptadores_mwh, | ||
production_monthly.total_energia_exportada_comptadores_mwh, | ||
sum(production_monthly.total_energia_exportada_comptadores_mwh) over (partition by extract(year from production_monthly.month) order by production_monthly.month) as total_cumsum_energia_exportada_comptadores_mwh, | ||
production_monthly.total_energia_esperada_solargis_mwh, | ||
production_monthly.total_energia_perduda_mwh, | ||
production_target.month as mes, | ||
plant_catalog.plant_name as nom_planta, | ||
plant_catalog.plant_uuid as plant_uuid, | ||
plant_catalog.technology as tecnologia, | ||
production_monthly.energia_instantania_inversor_mwh, | ||
production_monthly.energia_exportada_instantania_comptador_mwh, | ||
production_monthly.energia_exportada_comptador_mwh, | ||
production_monthly.energia_esperada_solargis_mwh, | ||
production_monthly.energia_perduda_mwh, | ||
production_monthly.preu_omie_eur_mwh, | ||
production_target_w_cumsum.total_energy_production_target_mwh as total_energia_objetivo_mwh, | ||
sum(production_target_w_cumsum.total_energy_production_target_mwh) over (partition by extract(year from production_target_w_cumsum.month) order by production_target_w_cumsum.month) as total_cumsum_energy_production_target_mwh | ||
from production_target_w_cumsum | ||
left join production_monthly on production_target_w_cumsum.month = production_monthly.month | ||
order by production_target_w_cumsum.month desc | ||
production_target.energy_production_target_mwh as energia_objectiu_mwh, | ||
sum(production_target.energy_production_target_mwh) | ||
over (partition by plant_uuid, extract(year from month) order by month) | ||
as cumsum_energia_objectiu_mwh | ||
from {{ ref("int_gda_plants__plants_catalog") }} as plant_catalog | ||
left join {{ ref("int_production_target__monthly") }} as production_target using (plant_uuid) | ||
left join {{ ref("dm_plant_production_monthly") }} as production_monthly using (plant_uuid, month) | ||
order by production_target.month desc, plant_catalog.plant_name desc | ||
) | ||
select * from production_with_target | ||
select * from production_monthly_w_target |
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
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