-
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.
fix: inverter monthly agg (et/somenergia-jardiner!60)
* add forgotten with in CTE * add max/min signal_value for inverter energy to debug it * split dset_energy_inverter__agg for_om into two models, hourly and monthly * add materialized_at column to be able to debug incremental rows * delete outdated info in afegir planta * fix: wrong capitalization on model
- Loading branch information
Showing
2 changed files
with
41 additions
and
33 deletions.
There are no files selected for viewing
35 changes: 2 additions & 33 deletions
35
dbt_jardiner/models/jardiner/marts/dm_dset_energy_inverter__agg_monthly_for_om.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
39 changes: 39 additions & 0 deletions
39
dbt_jardiner/models/jardiner/marts/int_dset_energy_inverter__agg_hourly_for_om.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,39 @@ | ||
{{ config(materialized='view') }} | ||
|
||
with inverters_energy as ( | ||
select | ||
date_trunc('hour', ts) as start_hour, | ||
plant_name, | ||
device_name, | ||
metric_name, | ||
signal_unit, | ||
signal_value | ||
from {{ ref('int_dset_responses__values_incremental') }} | ||
where device_type in ('inverter') and metric_name = 'energia_activa_exportada' | ||
), production_hourly as ( | ||
select | ||
start_hour, | ||
plant_name, | ||
device_name, | ||
signal_unit, | ||
max(signal_value) as max_abs_inverter_energy, | ||
min(signal_value) as min_abs_inverter_energy, | ||
(extract(hour from start_hour) > 3)::integer * (max(signal_value) - min(signal_value)) as inverter_energy | ||
from inverters_energy | ||
group by start_hour, plant_name, device_name, metric_name, signal_unit | ||
), signal_unit_standardization as ( | ||
select | ||
start_hour, | ||
plant_name, | ||
device_name, | ||
case | ||
when signal_unit = 'MWh' then round(inverter_energy,3) | ||
when signal_unit = 'kWh' then round(inverter_energy/1000,3) | ||
else NULL | ||
end as inverter_energy_mwh, | ||
max_abs_inverter_energy, | ||
min_abs_inverter_energy | ||
from production_hourly | ||
) | ||
select * from signal_unit_standardization | ||
|