-
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.
Split waters for legacy and jardiner (et/somenergia-jardiner!104)
Merge branch 'fix/legacy-water-split' into 'main'
- Loading branch information
Showing
12 changed files
with
85 additions
and
23 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
6 changes: 3 additions & 3 deletions
6
dbt_jardiner/models/jardiner/raw/plantmonitor_erp/raw_plantmonitor_plants.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,10 +1,10 @@ | ||
{{ config(materialized='view') }} | ||
|
||
SELECT | ||
select | ||
plant.id as plant_id, | ||
plant.name as plant_name, | ||
plant.codename as plant_codename, | ||
plant.description as plant_description, | ||
device_uuid as plant_uuid | ||
FROM {{source('plantmonitor_legacy','plant')}} | ||
plant.device_uuid as plant_uuid | ||
from {{ source('plantmonitor_jardiner','plant') }} as plant | ||
where plant.description != 'SomRenovables' |
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
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
8 changes: 8 additions & 0 deletions
8
dbt_jardiner/models/legacy/operational/external_data/_raw_meteologica__sources.yaml
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,8 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: meteologica_legacy | ||
schema: public | ||
tables: | ||
- name: forecast | ||
- name: forecastmetadata |
12 changes: 12 additions & 0 deletions
12
dbt_jardiner/models/legacy/operational/external_data/_raw_solar_events_ephem__sources.yaml
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,12 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: plantmonitor_legacy | ||
schema: public | ||
tables: | ||
- name: solarevent | ||
columns: | ||
- name: id | ||
- name: plant | ||
- name: sunrise | ||
- name: sunset |
29 changes: 29 additions & 0 deletions
29
...s/legacy/operational/external_data/energy_forecasts__denormalized_from_plantmonitordb.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,29 @@ | ||
{{ config( | ||
materialized = 'view' | ||
) }} | ||
|
||
WITH forecast_denormalized AS ( | ||
|
||
SELECT | ||
forecast.time AS "time", | ||
forecastmetadata.plant AS plant_id, | ||
forecastmetadata.forecastdate AS forecastdate, | ||
ROUND( | ||
forecast.percentil50 / 1000.0, | ||
2 | ||
) AS energy_kwh | ||
FROM | ||
{{ source( | ||
'meteologica_legacy', | ||
'forecast' | ||
) }} | ||
LEFT JOIN {{ source( | ||
'meteologica_legacy', | ||
'forecastmetadata' | ||
) }} | ||
ON forecastmetadata.id = forecast.forecastmetadata | ||
) | ||
SELECT | ||
* | ||
FROM | ||
forecast_denormalized |
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
13 changes: 13 additions & 0 deletions
13
dbt_jardiner/models/legacy/operational/external_data/plantmonitordb_solarevent__generous.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,13 @@ | ||
{{ config(materialized='view') }} | ||
|
||
|
||
select | ||
plant as plant_id, | ||
date_trunc('day', sunrise) as day, | ||
sunrise as sunrise_real, | ||
sunset as sunset_real, | ||
sunrise + interval '2 hours' as sunrise_generous, | ||
sunset - interval '2 hours' as sunset_generous, | ||
round(EXTRACT(EPOCH FROM (sunset - sunrise))::numeric/3600,2) as solar_hours_real, | ||
round(EXTRACT(EPOCH FROM (sunset - interval '2 hours') - (sunrise + interval '2 hours'))::numeric/3600,2) as solar_hours_minimum | ||
from {{source('plantmonitor_legacy', 'solarevent')}} |