-
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.
new: add new plants (contd. from !26) (et/somenergia-jardiner!29)
* chore: bump format and add context * change: remove unused seed * dev: add .prettierrc.yaml config file * change: update outdated metric value in WHERE clause * new: add dbt tests for raw data from dset * chore: minor formatting * change: set snapshot target schema to lake * change: add type casting to raw model * dev: add .editorconfig * change: remove outdated columns and minor formatting * change: refactor snapshots - set source name to airbyte for schema airbyte_imported instead of plantlake, since it was confusing - rename models to signal_denormalized instead of signal__denormalized (double underscore) because it was confusing - change destination schema to dbt_snapshots as per dbt recommendation to not mix dbt models and snapshots in the same schema - create snapshot for signal_denormalized * change: minor housekeeping * chore:add some source docs * fix: metrics have been renamed, fragile pivoting * finish plant_uuid support, plant_id is spreaded like a virus, we'll leave it until we deprecate plantmonitor * fix: propagate plant_uuid, start replacing plant_id by plant_plantmonitor_id * dev: update .gitignore with duckdb and dbt internals * new: add snapshot as source for signal__normalized also replace signal_normalized for signal__normalized for consistency * fix: migrate references from seed to snapshot * change: migrate seed associating signals and devices to a table this changes the models currently pointing to a seed and points them to a sql table instead. it also creates the source definition in yaml files and ports the descriptions from the previous seed. * dev: merge duplicate keys in .sqlfluff
- Loading branch information
1 parent
3be1953
commit 72d49d7
Showing
29 changed files
with
286 additions
and
866 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = true | ||
|
||
[*.sql] | ||
indent_size = 2 | ||
|
||
[*.yaml, *.yml] | ||
indent_size = 2 |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
semi: false | ||
overrides: | ||
- files: "*.js" | ||
options: | ||
semi: true | ||
- files: | ||
- "*.html" | ||
options: | ||
tabWidth: 2 |
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,13 +1,11 @@ | ||
[sqlfluff] | ||
exclude_rules = layout.indent, layout.cte_bracket, layout.select_targets | ||
exclude_rules = layout.indent, layout.cte_bracket, layout.select_targets, LT05 | ||
# set max_line_length to whatever you set in sqlfmt | ||
max_line_length = 120 | ||
# don't check for line length, let sqlfmt do that | ||
exclude_rules = LT05 | ||
|
||
[sqlfluff:rules] | ||
capitalisation_policy = lower | ||
extended_capitalisation_policy = lower | ||
|
||
[sqlfluff:rules:convention.terminator] | ||
multiline_newline = True | ||
multiline_newline = True |
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
4 changes: 2 additions & 2 deletions
4
...rdiner/models/jardiner/intermediate/dset/int_signal_device_relation__distinct_devices.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,5 +1,5 @@ | ||
{{ config(materialized="table") }} | ||
|
||
select distinct plant, device, device_uuid, device_type, device_parent | ||
from {{ ref("seed_signals__with_devices") }} | ||
select distinct plant, plant_uuid, device, device_uuid, device_type, device_parent | ||
from {{ ref('raw_gestio_actius__signal_denormalized') }} | ||
order by plant, device |
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
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
87 changes: 85 additions & 2 deletions
87
dbt_jardiner/models/jardiner/raw/gestio_actius/_raw_gestio_actius__models.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 |
---|---|---|
@@ -1,8 +1,91 @@ | ||
version: 2 | ||
|
||
models: | ||
|
||
- name: raw_gestio_actius_production_target | ||
description: > | ||
Conté la taula incremental que es crea mitjançant el snapshot (al schema lake) | ||
que llegueix la source del drive importada per airbyte (al schema airbyte_imported) | ||
que llegueix la source del drive importada per airbyte (al schema airbyte_imported) | ||
- name: raw_gestio_actius__signal_denormalized | ||
description: > | ||
Taula amb la llista de devices, els seus uuids i si tenen un parent. | ||
Conté la relació entre signal_description de l'API de DSET (un UUID | ||
imputat per nosaltres en el document de maping que se'ls envia) amb un device_uuid | ||
també imputat per nosaltres que es correspon amb la columna homònima de la taula | ||
d'aparell que correspongui ja sigui inverter, string, sensor, plant, etc. | ||
Aquesta taula equival al 'seed' data/seed_signals__with_devices.csv que es carrega | ||
a la taula utilitzant l'script scripts/file_to_sql.py. | ||
Exemple del maping enviat per [Llanillos](https://docs.google.com/spreadsheets/d/1op_WHvGZNyDdkBD7EOXK-CPU5-aGjK3r/edit#gid=629299947) | ||
columns: | ||
- name: signal_id | ||
description: id intern de la db | ||
- name: plant_uuid | ||
description: uuid4 de la planta | ||
- name: plant | ||
description: nom de la planta | ||
- name: signal | ||
description: nom del senyal | ||
- name: metric | ||
description: nom de la metrica | ||
tests: | ||
- accepted_values: | ||
config: | ||
severity: error | ||
error_if: ">0" | ||
values: | ||
- "comunicacio_ok" | ||
- "energia_activa_exportada" | ||
- "energia_activa_importada" | ||
- "energia_reactiva_q1" | ||
- "energia_reactiva_q2" | ||
- "energia_reactiva_q3" | ||
- "energia_reactiva_q4" | ||
- "frecuencia" | ||
- "intensitat_bt_fase_r" | ||
- "intensitat_bt_fase_s" | ||
- "intensitat_bt_fase_t" | ||
- "intensitat_dc" | ||
- "irradiancia" | ||
- "potencia_activa" | ||
- "potencia_activa_fase_r" | ||
- "potencia_activa_fase_s" | ||
- "potencia_activa_fase_t" | ||
- "temperatura_ambient" | ||
- "temperatura_dispositiu" | ||
- "temperatura_pv_modul" | ||
- "temperatura_superficie" | ||
- "voltatge_bt_fase_r" | ||
- "voltatge_bt_fase_s" | ||
- "voltatge_bt_fase_t" | ||
- "voltatge_dc" | ||
- "voltatge_mt_fase_r" | ||
- "voltatge_mt_fase_s" | ||
- "voltatge_mt_fase_t" | ||
- name: device | ||
description: nom del device | ||
- name: device_type | ||
description: tipus de device | ||
tests: | ||
- accepted_values: | ||
values: | ||
["meter", "inverter", "sensor", "plant", "string", "module"] | ||
- name: device_parent | ||
description: device parent del device. e.g. un string té l'inversor1 com a pare | ||
- name: signal_uuid | ||
description: | ||
UUID del senyal present a la columns signal_UUID del maping. Es assignada manualment amb | ||
cada nou mapeig de GA. | ||
tests: | ||
- unique | ||
- name: device_uuid | ||
description: | ||
Imputat per nosaltres que es correspon amb la columna homònima de la | ||
taula d'aparell que correspongui ja sigui inverter, string, sensor, plant, etc. | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
config: | ||
severity: error | ||
combination_of_columns: | ||
- plant_uuid | ||
- device_uuid | ||
- signal_uuid |
20 changes: 20 additions & 0 deletions
20
dbt_jardiner/models/jardiner/raw/gestio_actius/raw_gestio_actius__signal_denormalized.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,20 @@ | ||
{{ config(materialized='view') }} | ||
|
||
WITH fresh AS ( | ||
SELECT * | ||
FROM {{ ref("snapshot_signal_denormalized") }} sn | ||
WHERE sn.dbt_valid_to IS NULL | ||
) | ||
SELECT | ||
plant_uuid::uuid, | ||
plant::text, | ||
signal::text, | ||
metric::text, | ||
device::text, | ||
device_type::text, | ||
device_uuid::uuid, | ||
device_parent::text, | ||
signal_uuid::uuid, | ||
inserted_at::timestamptz, | ||
updated_at::timestamptz | ||
FROM fresh |
Oops, something went wrong.