Skip to content

Commit

Permalink
Merge pull request #333 from basedosdados/staging/br_ons
Browse files Browse the repository at this point in the history
[dbt] br_ons
  • Loading branch information
folhesgabriel authored Oct 23, 2023
2 parents 5d881b4 + 0d33ae7 commit 4f64090
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{ config(
alias='geracao_termica_motivo_despacho',
schema='br_ons_avaliacao_operacao',
materialized = 'incremental',
partition_by={
"field": "ano",
"data_type": "int64",
Expand All @@ -10,6 +11,8 @@
"interval": 1}
})
}}

WITH ons as (
SELECT
SAFE_CAST(data AS DATE) data,
SAFE_CAST(hora AS TIME) hora,
Expand Down Expand Up @@ -46,4 +49,10 @@ SAFE_CAST(geracao_reserva_potencia_verificada AS FLOAT64) geracao_reserva_potenc
SAFE_CAST(geracao_substituicao_verificada AS FLOAT64) geracao_substituicao_verificada,
SAFE_CAST(geracao_unit_commitment_verificada AS FLOAT64) geracao_unit_commitment_verificada,
SAFE_CAST(geracao_constrained_off_verificada AS FLOAT64) geracao_constrained_off_verificada
FROM basedosdados-dev.br_ons_avaliacao_operacao_staging.geracao_termica_motivo_despacho AS t
FROM basedosdados-dev.br_ons_avaliacao_operacao_staging.geracao_termica_motivo_despacho AS t
)
SELECT *
FROM ons
{% if is_incremental() %}
WHERE data > (SELECT max(data) FROM {{ this }} )
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{ config(
alias='geracao_usina',
schema='br_ons_avaliacao_operacao',
materialized = 'incremental',
partition_by={
"field": "ano",
"data_type": "int64",
Expand All @@ -10,6 +11,7 @@
"interval": 1}
})
}}
WITH ons as (
SELECT
SAFE_CAST(data AS DATE) data,
SAFE_CAST(hora AS TIME) hora,
Expand All @@ -24,4 +26,10 @@ SAFE_CAST(tipo_usina AS STRING) tipo_usina,
SAFE_CAST(tipo_modalidade_operacao AS STRING) tipo_modalidade_operacao,
SAFE_CAST(tipo_combustivel AS STRING) tipo_combustivel,
SAFE_CAST(geracao AS FLOAT64) geracao
FROM basedosdados-dev.br_ons_avaliacao_operacao_staging.geracao_usina AS t
FROM basedosdados-dev.br_ons_avaliacao_operacao_staging.geracao_usina AS t
)
SELECT *
FROM ons
{% if is_incremental() %}
WHERE data > (SELECT max(data) FROM {{ this }} )
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{ config(
alias='restricao_operacao_usinas_eolicas',
schema='br_ons_avaliacao_operacao',
materialized = 'incremental',
partition_by={
"field": "ano",
"data_type": "int64",
Expand All @@ -10,6 +11,7 @@
"interval": 1}
})
}}
WITH ons as (
SELECT
SAFE_CAST(data AS DATE) data,
SAFE_CAST(hora AS TIME) hora,
Expand All @@ -28,4 +30,10 @@ SAFE_CAST(geracao_limitada AS FLOAT64) geracao_limitada,
SAFE_CAST(disponibilidade AS FLOAT64) disponibilidade,
SAFE_CAST(geracao_referencia AS FLOAT64) geracao_referencia,
SAFE_CAST(geracao_referencia_final AS FLOAT64) geracao_referencia_final
FROM basedosdados-dev.br_ons_avaliacao_operacao_staging.restricao_operacao_usinas_eolicas AS t
FROM basedosdados-dev.br_ons_avaliacao_operacao_staging.restricao_operacao_usinas_eolicas AS t
)
SELECT *
FROM ons
{% if is_incremental() %}
WHERE data > (SELECT max(data) FROM {{ this }} )
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{{ config(
alias='custo_variavel_unitario_usinas_termicas',
schema='br_ons_estimativa_custos')
schema='br_ons_estimativa_custos',
materialized = 'incremental',
partition_by={
"field": "ano",
"data_type": "int64",
"range": {
"start": 2019,
"end": 2024,
"interval": 1}
})
}}
WITH ons as (
SELECT
SAFE_CAST(data_inicio AS DATE) data_inicio,
SAFE_CAST(ano AS INT64) ano,
Expand All @@ -16,4 +26,10 @@ SAFE_CAST(id_subsistema AS STRING) id_subsistema,
SAFE_CAST(subsistema AS STRING) subsistema,
SAFE_CAST(usina AS STRING) usina,
SAFE_CAST(custo_variavel_unitario AS FLOAT64) custo_variavel_unitario
FROM basedosdados-dev.br_ons_estimativa_custos_staging.custo_variavel_unitario_usinas_termicas AS t
FROM basedosdados-dev.br_ons_estimativa_custos_staging.custo_variavel_unitario_usinas_termicas AS t
)
SELECT *
FROM ons
{% if is_incremental() %}
WHERE data_inicio > (SELECT max(data_inicio) FROM {{ this }} )
{% endif %}

0 comments on commit 4f64090

Please sign in to comment.