diff --git a/queries/models/transito/CHANGELOG.md b/queries/models/transito/CHANGELOG.md index 4c8dec14..5071ed20 100644 --- a/queries/models/transito/CHANGELOG.md +++ b/queries/models/transito/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog - infracao +## [1.0.1] - 2024-09-04 + +### Corrigido + +- Corrige colunas `status_infracao` e `descricao_situacao_autuacao` e o filtro incremental da tabela altuacao (https://github.com/prefeitura-rio/pipelines_rj_smtr/pull/186/) + ## [1.0.0] - 2024-08-03 ### Adicionado diff --git a/queries/models/transito/autuacao.sql b/queries/models/transito/autuacao.sql index fa6ceb29..c78b19d5 100644 --- a/queries/models/transito/autuacao.sql +++ b/queries/models/transito/autuacao.sql @@ -11,12 +11,12 @@ WITH citran AS ( SELECT - DATE(data) AS data, + data, id_auto_infracao, DATETIME(concat(data,' ',hora,':00')) AS datetime_autuacao, data_limite_defesa_previa, data_limite_recurso, - NULL AS descricao_situacao_autuacao, + situacao_atual AS descricao_situacao_autuacao, IF(status_infracao != "", status_infracao, NULL) AS status_infracao, IF(codigo_enquadramento != "", codigo_enquadramento, NULL) AS codigo_enquadramento, IF(tipificacao_resumida != "", tipificacao_resumida, NULL) AS tipificacao_resumida, @@ -52,7 +52,7 @@ WITH citran AS ( FROM {{ ref('autuacao_citran') }} {% if is_incremental() %} WHERE - data BETWEEN DATE("{var('date_range_start')}") AND DATE("{var('date_range_end')}") + data BETWEEN DATE("{{var('date_range_start')}}") AND DATE("{{var('date_range_end')}}") {% endif %} ) diff --git a/queries/models/transito/staging/autuacao_citran.sql b/queries/models/transito/staging/autuacao_citran.sql index b6e177aa..5e56ba37 100644 --- a/queries/models/transito/staging/autuacao_citran.sql +++ b/queries/models/transito/staging/autuacao_citran.sql @@ -6,13 +6,13 @@ SELECT - data, + DATE(data) AS data, SAFE_CAST(JSON_VALUE(content,'$.Hora') AS STRING) hora, Cod__Detran as id_auto_infracao, IF(JSON_VALUE(content, '$.DtLimDP') != '', SAFE_CAST(PARSE_DATE('%d/%m/%Y', JSON_VALUE(content,'$.DtLimDP')) AS STRING), NULL) data_limite_defesa_previa, IF(JSON_VALUE(content, '$.DtLimR') != '', SAFE_CAST(PARSE_DATE('%d/%m/%Y', JSON_VALUE(content,'$.DtLimR')) AS STRING), NULL) data_limite_recurso, SAFE_CAST(JSON_VALUE(content,'$.Situacao Atual') AS STRING) situacao_atual, - SAFE_CAST(JSON_VALUE(content,'$.St. Infracao') AS STRING) status_infracao, + SAFE_CAST(JSON_VALUE(content,'$."St. Infracao"') AS STRING) status_infracao, SAFE_CAST(JSON_VALUE(content,'$.Multa') AS STRING) codigo_enquadramento, SAFE_CAST(JSON_VALUE(content,'$.DsInf') AS STRING) tipificacao_resumida, SAFE_CAST(JSON_VALUE(content,'$.Po') AS STRING) pontuacao,