-
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.
change: duplicate dbt models so that legacy and jardiner tags don't c…
…ross (et/somenergia-jardiner!30) * change: duplicate models so that legacy and jardiner tags don't cross
- Loading branch information
1 parent
4bd01b5
commit 488f04c
Showing
7 changed files
with
93 additions
and
12 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
35 changes: 35 additions & 0 deletions
35
dbt_jardiner/models/legacy/operational/plant/gestio_actius_plant_parameters__raw_legacy.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,35 @@ | ||
{{ config(materialized="view") }} | ||
|
||
with | ||
current_data as ( | ||
select | ||
plant_id::numeric, | ||
plant_uuid::uuid, | ||
case | ||
when planta = 'Vallehermoso' then 'Alcolea' | ||
when planta = 'Tahal' then 'Terborg' | ||
else planta | ||
end as plant_name, | ||
latitud::numeric as latitude, | ||
longitut::numeric as longitude, | ||
municipi as municipality, | ||
provincia as province, | ||
tecnologia as technology, | ||
data_connexio::date as connection_date, | ||
potencia_nominal_kw::numeric as nominal_power_kw, | ||
potencia_pic_kw::numeric as peak_power_kw, | ||
"owner", | ||
n_strings_plant::numeric, | ||
n_modules_string::numeric, | ||
n_strings_inverter::numeric, | ||
esquema_unifilar, | ||
layout, | ||
data_actualitzacio::date as gestio_actius_updated_at, | ||
dbt_updated_at::date as dbt_updated_at, | ||
dbt_valid_from::date as dbt_valid_from, | ||
coalesce(dbt_valid_to::date, '2050-01-01'::date)::date as dbt_valid_to | ||
from {{ ref("snapshot_plant_parameters") }} as pl | ||
) | ||
select * | ||
from current_data | ||
where dbt_valid_from::date <= current_date and current_date < dbt_valid_to::date |
17 changes: 17 additions & 0 deletions
17
dbt_jardiner/models/legacy/operational/solargis/satellite_readings__denormalized_legacy.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,17 @@ | ||
{{ config(materialized='view') }} | ||
|
||
select | ||
sg.start_hour, | ||
sg.plant_id, | ||
plant_name, | ||
request_time, | ||
horizontal_irradiation_wh_m2, | ||
tilted_irradiation_wh_m2, | ||
module_temperature_dc, | ||
energy_output_kwh | ||
from {{ ref("solargis_satellite_readings__temp_and_pv_energy_legacy") }} sg | ||
left join {{ref('gestio_actius_plant_parameters__raw_legacy')}} p on p.plant_id = sg.plant_id | ||
|
||
-- SolarGis PVOUT (aquí photovoltaic_energy_output_wh) retorna l'energia en kwh però plantmonitor per error ho registra com a wh sense fer cap transformació. | ||
-- Entenem que al redash s'està corregint a mà abans de mostrar el valor. | ||
-- Aquí canviem el nom perquè s'ajusti a la realitat del valor. |
24 changes: 24 additions & 0 deletions
24
dbt_jardiner/models/legacy/operational/solargis/satellite_readings__hourly_legacy.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,24 @@ | ||
{{ config( | ||
materialized = 'view' | ||
) }} | ||
|
||
WITH satellite AS ( | ||
|
||
SELECT | ||
*, | ||
ROW_NUMBER() OVER ( | ||
PARTITION BY plant_id, | ||
start_hour | ||
ORDER BY | ||
request_time DESC | ||
) AS ranking | ||
FROM | ||
{{ ref('satellite_readings__denormalized_legacy') }} | ||
) | ||
|
||
SELECT | ||
* | ||
FROM | ||
satellite | ||
WHERE | ||
ranking = 1 |
15 changes: 15 additions & 0 deletions
15
...ls/legacy/operational/solargis/solargis_satellite_readings__temp_and_pv_energy_legacy.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,15 @@ | ||
{{ config(materialized='view') }} | ||
|
||
select | ||
date_trunc('hour', "time") as start_hour, | ||
plant as plant_id, | ||
request_time as request_time, | ||
global_horizontal_irradiation_wh_m2 as horizontal_irradiation_wh_m2, | ||
global_tilted_irradiation_wh_m2 as tilted_irradiation_wh_m2, | ||
module_temperature_dc as module_temperature_dc, | ||
photovoltaic_energy_output_wh as energy_output_kwh | ||
from {{ source('solargis','satellite_readings') }} sg | ||
|
||
-- SolarGis PVOUT (aquí photovoltaic_energy_output_wh) retorna l'energia en kwh però plantmonitor per error ho registra com a wh sense fer cap transformació. | ||
-- Entenem que al redash s'està corregint a mà abans de mostrar el valor. | ||
-- Aquí canviem el nom perquè s'ajusti a la realitat del valor. |