Skip to content

Commit

Permalink
[HOTFIX] GPS Validador Van deduplicação (#213)
Browse files Browse the repository at this point in the history
* cria tabelas agregadas e separa gps van

* corrige filtro onibus

* corrige deduplicação
  • Loading branch information
pixuimpou authored Feb 8, 2024
1 parent db02f19 commit c588f5e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
22 changes: 15 additions & 7 deletions models/br_rj_riodejaneiro_bilhetagem/gps_validador.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ SELECT
temperatura,
'{{ var("version") }}' as versao
FROM
{{ ref("gps_validador_aux") }}
WHERE
(
SELECT
*,
ROW_NUMBER() OVER(PARTITION BY id_transmissao_gps ORDER BY datetime_captura DESC) AS rn
FROM
{{ ref("gps_validador_aux") }}

{% if is_incremental() %}
DATE(data) BETWEEN DATE("{{var('date_range_start')}}") AND DATE("{{var('date_range_end')}}")
AND datetime_captura > DATETIME("{{var('date_range_start')}}") AND datetime_captura <= DATETIME("{{var('date_range_end')}}")
AND
{%- endif %}
modo != "Van"
WHERE
DATE(data) BETWEEN DATE("{{var('date_range_start')}}") AND DATE("{{var('date_range_end')}}")
AND datetime_captura > DATETIME("{{var('date_range_start')}}") AND datetime_captura <= DATETIME("{{var('date_range_end')}}")
{% endif %}
)
WHERE
rn = 1
AND modo != "Van"
10 changes: 5 additions & 5 deletions models/br_rj_riodejaneiro_bilhetagem/gps_validador_van.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ FROM
ROW_NUMBER() OVER(PARTITION BY id_transmissao_gps ORDER BY datetime_captura DESC) AS rn
FROM
{{ ref("gps_validador_aux") }}
)
WHERE
{% if is_incremental() %}
DATE(data) BETWEEN DATE("{{var('date_range_start')}}") AND DATE("{{var('date_range_end')}}")
AND datetime_captura > DATETIME("{{var('date_range_start')}}") AND datetime_captura <= DATETIME("{{var('date_range_end')}}")
AND
WHERE
DATE(data) BETWEEN DATE("{{var('date_range_start')}}") AND DATE("{{var('date_range_end')}}")
AND datetime_captura > DATETIME("{{var('date_range_start')}}") AND datetime_captura <= DATETIME("{{var('date_range_end')}}")
{% endif %}
)
WHERE
rn = 1
AND modo = "Van"

Expand Down

0 comments on commit c588f5e

Please sign in to comment.