Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alterações para reprocessamento do recurso SMTR202404004977 #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions queries/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ models:
rj_smtr:
projeto_subsidio_sppo:
+materialized: view
+schema: projeto_subsidio_sppo
+schema: SMTR202404004977_reprocessamento_projeto_subsidio_sppo
deprecated:
+materialized: view
+schema: projeto_subsidio_sppo
+schema: SMTR202404004977_reprocessamento_projeto_subsidio_sppo
br_rj_riodejaneiro_sigmob:
+materialized: view
+schema: br_rj_riodejaneiro_sigmob
Expand All @@ -207,16 +207,16 @@ models:
+schema: br_rj_riodejaneiro_veiculos
dashboard_subsidio_sppo:
+materialized: view
+schema: dashboard_subsidio_sppo
+schema: SMTR202404004977_reprocessamento_dashboard_subsidio_sppo
dashboard_subsidio_sppo_staging:
+materialized: view
+schema: dashboard_subsidio_sppo_staging
+schema: SMTR202404004977_reprocessamento_dashboard_subsidio_sppo_staging
veiculo:
+materialized: view
+schema: veiculo
+schema: SMTR202404004977_reprocessamento_veiculo
staging:
+materialized: view
+schema: veiculo_staging
+schema: SMTR202404004977_reprocessamento_veiculo_staging
br_rj_riodejaneiro_rdo:
+materialized: view
+schema: br_rj_riodejaneiro_rdo
Expand Down
3 changes: 2 additions & 1 deletion queries/models/dashboard_subsidio_sppo/sumario_dia.sql
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ WITH
SELECT
*
FROM
{{ ref("subsidio_data_versao_efetiva") }} -- `rj-smtr`.`projeto_subsidio_sppo`.`subsidio_data_versao_efetiva`
-- {{ ref("subsidio_data_versao_efetiva") }}
`rj-smtr`.`projeto_subsidio_sppo`.`subsidio_data_versao_efetiva`
WHERE
data >= "2022-06-01"
AND data < DATE( "{{ var("DATA_SUBSIDIO_V2_INICIO") }}" )) AS v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ WITH
{{ ref("viagem_planejada") }} AS v
-- `rj-smtr`.`projeto_subsidio_sppo`.`viagem_planejada` AS v
LEFT JOIN
{{ ref("subsidio_data_versao_efetiva") }}
-- rj-smtr.projeto_subsidio_sppo.subsidio_data_versao_efetiva
-- {{ ref("subsidio_data_versao_efetiva") }}
`rj-smtr.projeto_subsidio_sppo.subsidio_data_versao_efetiva`
USING
(data)
LEFT JOIN
{{ ref("ordem_servico_gtfs") }} AS o
-- rj-smtr.gtfs.ordem_servico AS o
-- {{ ref("ordem_servico_gtfs") }} AS o
`rj-smtr.gtfs.ordem_servico` AS o
USING
(feed_start_date, servico, tipo_os)
WHERE
Expand Down
10 changes: 5 additions & 5 deletions queries/models/dashboard_subsidio_sppo/viagens_remuneradas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}}

{%- if execute %}
{% set query = "SELECT DISTINCT COALESCE(feed_start_date, data_versao_trips, data_versao_shapes, data_versao_frequencies) FROM " ~ ref('subsidio_data_versao_efetiva') ~ " WHERE data BETWEEN DATE('" ~ var('start_date') ~ "') AND DATE('" ~ var("end_date") ~ "')"%}
{% set query = "SELECT DISTINCT COALESCE(feed_start_date, data_versao_trips, data_versao_shapes, data_versao_frequencies) FROM rj-smtr.projeto_subsidio_sppo.subsidio_data_versao_efetiva WHERE data BETWEEN DATE('" ~ var('start_date') ~ "') AND DATE('" ~ var("end_date") ~ "')"%}
{{- log(query, info=True) -}}
{% set feed_start_dates = run_query(query).columns[0].values() %}
{{- log(feed_start_dates, info=True) -}}
Expand Down Expand Up @@ -44,8 +44,8 @@ WITH
partidas_volta,
tipo_os,
FROM
{{ ref("ordem_servico_gtfs") }}
-- rj-smtr.gtfs.ordem_servico
-- {{ ref("ordem_servico_gtfs") }}
`rj-smtr.gtfs.ordem_servico`
WHERE
feed_start_date IN ('{{ feed_start_dates|join("', '") }}')
),
Expand All @@ -56,8 +56,8 @@ WITH
tipo_os,
COALESCE(feed_start_date, data_versao_trips, data_versao_shapes, data_versao_frequencies) AS feed_start_date
FROM
{{ ref("subsidio_data_versao_efetiva") }}
-- rj-smtr.projeto_subsidio_sppo.subsidio_data_versao_efetiva (alterar também query no bloco execute)
-- {{ ref("subsidio_data_versao_efetiva") }}
`rj-smtr.projeto_subsidio_sppo.subsidio_data_versao_efetiva` -- (alterar também query no bloco execute)
WHERE
data BETWEEN DATE("{{ var("start_date") }}")
AND DATE( "{{ var("end_date") }}" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ contents as (
DATE(data_versao) AS data_versao
FROM
{{ var("subsidio_shapes") }} s
{% if is_incremental() %}

WHERE
data_versao in (select data_versao_shapes from data_versao)
{% endif %}

),
pts as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ WITH
FROM
dates AS d
LEFT JOIN
{{ ref('feed_info_gtfs') }} AS i
-- {{ ref('feed_info_gtfs') }} AS i
`rj-smtr.gtfs.feed_info`
USING
(feed_version)
WHERE
Expand All @@ -387,7 +388,8 @@ SELECT
FROM
data_versao_efetiva_manual AS d
LEFT JOIN
{{ ref('feed_info_gtfs') }} AS i
-- {{ ref('feed_info_gtfs') }} AS i
`rj-smtr.gtfs.feed_info`
ON
(data BETWEEN i.feed_start_date AND i.feed_end_date
OR (data >= i.feed_start_date AND i.feed_end_date IS NULL))
Expand Down
3 changes: 2 additions & 1 deletion queries/models/projeto_subsidio_sppo/viagem_planejada.sql
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ SELECT
FROM
data_versao_efetiva AS d
LEFT JOIN
{{ ref("ordem_servico_trips_shapes_gtfs") }} AS o
-- {{ ref("ordem_servico_trips_shapes_gtfs") }} AS o
`rj-smtr.gtfs.ordem_servico_trips_shapes`
USING
(feed_start_date,
feed_version,
Expand Down
1 change: 1 addition & 0 deletions queries/models/sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ sources:
- name: sppo_licenciamento_solicitacao
- name: sppo_licenciamento
- name: sppo_licenciamento_stu
# - name: sppo_vistoria_tr_subtt_cmo_recurso_SMTR202404004977

- name: dashboard_subsidio_sppo_staging
database: rj-smtr-staging
Expand Down
6 changes: 4 additions & 2 deletions queries/models/veiculo/sppo_veiculo_dia.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ WITH
DISTINCT data,
id_veiculo
FROM
{{ ref("gps_sppo") }} -- `rj-smtr.br_rj_riodejaneiro_veiculos.gps_sppo`
-- {{ ref("gps_sppo") }}
`rj-smtr.br_rj_riodejaneiro_veiculos.gps_sppo`
WHERE
data = DATE("{{ var('run_date') }}") ),
autuacoes AS (
Expand All @@ -60,7 +61,8 @@ WITH
id_veiculo,
TRUE AS indicador_registro_agente_verao_ar_condicionado
FROM
{{ ref("sppo_registro_agente_verao") }}
-- {{ ref("sppo_registro_agente_verao") }}
`rj-smtr.veiculo.sppo_registro_agente_verao`
WHERE
data = DATE("{{ var('run_date') }}") ),
autuacao_ar_condicionado AS (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ FROM
ano_ultima_vistoria,
FROM
{{ ref("sppo_vistoria_tr_subtt_cglf_pendentes_2024_staging") }}
UNION ALL
SELECT
data,
id_veiculo,
placa,
ano_ultima_vistoria,
FROM
{{ ref("sppo_vistoria_tr_subtt_cmo_recurso_SMTR202404004977_staging") }}
)
GROUP BY
1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

SELECT
SAFE_CAST(data AS DATE) AS data,
SAFE_CAST(id_veiculo AS STRING) AS id_veiculo,
SAFE_CAST(placa AS STRING) AS placa,
SAFE_CAST(empresa AS STRING) AS empresa,
SAFE_CAST(ano_ultima_vistoria AS INT64) AS ano_ultima_vistoria,
FROM
`rj-smtr-dev.veiculo_staging.sppo_vistoria_tr_subtt_cmo_recurso_SMTR202404004977`
Loading