Skip to content

Commit

Permalink
Incorpora variável 'encontro_contas_modo' para alterar nome da tabe…
Browse files Browse the repository at this point in the history
…la, de acordo com o modo de execução
  • Loading branch information
eng-rodrigocunha committed Jun 4, 2024
1 parent 8b14934 commit ade87a6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ vars:
### Diretorios ###
ids_consorcios: {"'221000014'": "'6'", "'221000023'": "'4'", "'221000032'": "'3'", "'221000041'": "'5'", "'221000050'": "NULL", "'229000010'": "'1'"}

### Encontro de Contas ###
encontro_contas_modo: ""

models:
+persist_docs:
relation: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% if var("encontro_contas_modo") != "" %}
{{ config(alias=this.name ~ "_" ~ var('encontro_contas_modo')) }}
{% endif %}

select
extract(year from data) as ano,
consorcio,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% if var("encontro_contas_modo") != "" %}
{{ config(alias=this.name ~ "_" ~ var('encontro_contas_modo')) }}
{% endif %}

select
data,
consorcio,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% if var("encontro_contas_modo") != "" %}
{{ config(alias=this.name ~ "_" ~ var('encontro_contas_modo')) }}
{% endif %}

select
extract(year from data) as ano,
consorcio,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% if var("encontro_contas_modo") != "" %}
{{ config(alias=this.name ~ "_" ~ var('encontro_contas_modo')) }}
{% endif %}

-- 0. Lista servicos e dias atípicos (pagos por recurso)
WITH
recursos AS (
Expand Down Expand Up @@ -114,6 +118,7 @@ rdo AS (
group by 1,2,3
),

{% if var("encontro_contas_modo") == "pos_gt" %}
-- 4. Considera os serviços conforme tratamento indicado em resposta aos ofícios MTR-OFI-2024/03024, MTR-OFI-2024/03025, MTR-OFI-2024/03026 e MTR-OFI-2024/03027 (Processo MTR-PRO-2024/06270)
rdo_correcao_servico AS (
SELECT DISTINCT
Expand Down Expand Up @@ -144,6 +149,7 @@ rdo_corrigido AS (
2,
3
),
{% endif %}

parametros as (
SELECT
Expand Down Expand Up @@ -174,7 +180,11 @@ parametros as (
from
km_subsidiada_filtrada ks
left join
{% if var("encontro_contas_modo") == "pos_gt" %}
rdo_corrigido AS rdo
{% else %}
rdo
{% endif %}
using
(data, servico, consorcio)
left join
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% if var("encontro_contas_modo") != "" %}
{{ config(alias=this.name ~ "_" ~ var('encontro_contas_modo')) }}
{% endif %}

WITH
q1 AS (
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Etapa de tratamento com base na resposta aos ofícios MTR-OFI-2024/03024, MTR-OFI-2024/03025, MTR-OFI-2024/03026 e MTR-OFI-2024/03027 (Processo MTR-PRO-2024/06270)
*/

{% if var("encontro_contas_modo") == "pos_gt" %}
{{ config(alias=this.name ~ "_" ~ var('encontro_contas_modo')) }}
SELECT
quinzena,
PARSE_DATE("%m/%d/%Y", data_inicio_quinzena) AS data_inicio_quinzena,
Expand All @@ -22,4 +24,7 @@ SELECT
END
AS servico_corrigido_rioonibus,
FROM
{{ source("projeto_subsidio_sppo_encontro_contas", "rdo_correcao_rioonibus_servico_quinzena") }}
{{ source("projeto_subsidio_sppo_encontro_contas", "rdo_correcao_rioonibus_servico_quinzena") }}
{% else %}
{{ config(enabled=false) }}
{% endif %}

0 comments on commit ade87a6

Please sign in to comment.