Skip to content

Commit

Permalink
fixing some queries
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciacatandi committed Aug 20, 2024
1 parent df04bde commit 7d89ff6
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 34 deletions.
37 changes: 23 additions & 14 deletions pipelines/sislic/dump_db_sislic/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@
""",
"biglake_table": True,
},
"tipo_licenca_acao_prefeitura_1": {
"tipo_licenca_acao_prefeitura_2": {
"materialize_after_dump": True,
"materialization_mode": "prod",
"dump_mode": "overwrite",
Expand All @@ -922,7 +922,7 @@
""",
"biglake_table": True,
},
"tipo_licenca_acao_prefeitura_2": {
"tipo_licenca_acao_prefeitura_1": {
"materialize_after_dump": True,
"materialization_mode": "prod",
"dump_mode": "overwrite",
Expand All @@ -934,18 +934,6 @@
""",
"biglake_table": True,
},
"tipo_licenca_acao_prefeitura_3": {
"materialize_after_dump": True,
"materialization_mode": "prod",
"dump_mode": "overwrite",
"execute_query": """
SELECT
cod_lic,
descr_lic
FROM SMU_PRD.dbo.tbLic_DescricoesLicencas
""",
"biglake_table": True,
},
"tipo_licenca_acao_prefeitura_4": {
"materialize_after_dump": True,
"materialization_mode": "prod",
Expand All @@ -965,6 +953,7 @@
"dump_mode": "overwrite",
"execute_query": """
SELECT
Cod_Unidade,
Desc_Unidade,
Desc_unidade_Plural
FROM SMU_PRD.dbo.tbLIC_Unidades
Expand Down Expand Up @@ -1071,6 +1060,26 @@
""",
"biglake_table": True,
},
"georeferencia_endereco_obra_processo": {
"materialize_after_dump": True,
"materialization_mode": "prod",
"dump_mode": "overwrite",
"execute_query": """
SELECT
id_processo,
id_processo_sislic,
nu_processo,
cd_logradouro,
nu_porta,
nu_pal,
id_bairro_sislic,
id_ra_sislic,
no_bairro,
shape
FROM SMU_PRD.dbo.tbGEOSISLIC_processo
""",
"biglake_table": True,
},
}

sislic_clocks = generate_dump_db_schedules(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CAST(area_acrescida AS FLOAT64) AS Area_Acrescida,
CAST(area_reduzida AS FLOAT64) AS Area_Reduzida,
CAST(area_util AS FLOAT64) AS Area_Util,
CAST(AREA_TOTAL_EDIFICADA AS FLOAT64) AS Area_Total_Edificada,
CAST(AREA_EXISTENTE_DECLARADA_RESPONSAVEL AS FLOAT64) AS Area_Existente_Declarada_Responsavel,
CAST(AREA_EXISTENTE_DECLARADA_RESPONSAVEL AS BOOL) AS Area_Existente_Declarada_Responsavel,
CAST(AreaTotal_Loteamento AS FLOAT64) AS Area_Total_Loteamento,
CAST(MetrosLineares_ObrasUrbanizacao AS FLOAT64) AS Metros_Lineares_Obras_Urbanizacao,
CAST(CAST(VagasExternasDescobertas AS FLOAT64) AS INT64) AS Vagas_Externas_Descobertas,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
SELECT
ID_AREA_PROTECAO_CULTURAL AS id_area_protecao_cultural,
DS_AREA_PROTECAO_CULTURAL AS nome_area_arotecao_ambiental
REGEXP_REPLACE(
NORMALIZE(UPPER(DS_AREA_PROTECAO_CULTURAL), NFD),
r'\p{M}',
''
) AS nome_area_protecao_ambiental
FROM `rj-smdue.adm_licenca_urbanismo_staging.area_protecao_cultural`
6 changes: 3 additions & 3 deletions queries/models/adm_licenca_urbanismo/assunto_processo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ SELECT
codAssunto AS id_assunto,
Status AS status,
codAssunto_ReqOnLine AS id_assunto_requerimento_online,
CAST(CAST(Exige_Endereco AS FLOAT64) AS INT64) AS exige_endereco,
CAST(CAST(Exige_ProcessoConstrucao AS FLOAT64) AS INT64) AS exige_processo_construcao,
CAST(CAST(Exige_CPF_CNPJ_Requerente AS FLOAT64) AS INT64) AS exige_CPF_CNPJ_requerente,
CAST(Exige_Endereco AS BOOL) AS exige_endereco,
CAST(Exige_ProcessoConstrucao AS BOOL) AS exige_processo_construcao,
CAST(Exige_CPF_CNPJ_Requerente AS BOOL) AS exige_CPF_CNPJ_requerente,
AssuntoProcessoRio AS assunto_processo_rio
FROM `rj-smdue.adm_licenca_urbanismo_staging.assunto_processo`
6 changes: 6 additions & 0 deletions queries/models/adm_licenca_urbanismo/bairro.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT
CAST(codBairro AS STRING) AS id_bairro,
CAST(nomBairro AS STRING) AS nome_bairro,
CAST(codRA AS STRING) AS id_regiao_administrativa,
CAST(codOrgaoSMU AS STRING) AS id_orgao_SMU,
FROM `rj-smdue.adm_licenca_urbanismo_staging.bairro`
4 changes: 2 additions & 2 deletions queries/models/adm_licenca_urbanismo/certidao_aceitacao.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ SELECT
Num_Aceitacao AS id_aceitacao,
Num_Proc AS numero_processo,
Num_Lic AS id_licenciamento,
Cod_DLF AS id_orgao_SISLIC,
Cod_DLF AS id_orgao_sislic,
CAST(Dt_Emissao AS DATETIME) AS data_emissao,
CAST(Dt_Certidao AS DATETIME) AS data_certidao,
Matricula_RGI AS matricula_rgi,
Nr_Oficio_RGI AS numero_oficio_rgi,
PAL AS numero_PAL,
PAL AS numero_pal,
Mat_Tec_Resp AS matricula_tecnico_responsavel,
CAST(Cancelado AS BOOL) AS cancelado,
Obs AS observacao
Expand Down
4 changes: 2 additions & 2 deletions queries/models/adm_licenca_urbanismo/certidao_habite_se.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ SELECT
Num_Hab AS id_habite_se,
Num_Proc AS numero_processo,
Num_Lic AS id_licenciamento,
Cod_DLF AS id_orgao_SISLIC,
Cod_DLF AS id_orgao_sislic,
CAST(Dt_Emissao AS DATETIME) AS data_emissao,
CAST(Dt_Certidao AS DATETIME) AS data_certidao,
Matricula_RGI AS matricula_rgi,
Nr_Oficio_RGI AS numero_oficio_rgi,
Pal AS numero_PAL,
Pal AS numero_pal,
DescricaoLote AS descricao_lote,
Numeracao_Habitavel AS endereco_habitavel,
Mat_Tec_Resp AS matricula_tecnico_responsavel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
cod_Edif AS id_tipo_edificacao,
cod_compl_TpEdificacao AS id_compl_tipo_edficacao,
cod_compl_tpEdificacao2 AS id_compl_tipo_edficacao_2,
cod_compl_TpEdificacao AS id_compl_tipo_edificacao,
cod_compl_tpEdificacao2 AS id_compl_tipo_edificacao_2,
Compl2 AS nome_tipo_edificacao
FROM `rj-smdue.adm_licenca_urbanismo_staging.compl_2_tipo_edificacao`
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ SELECT
COD_LIC AS id_licenca,
COD_COMPL_LIC AS id_complemento_tipo_licenca,
COMPL AS complemento,
GRATIS
GRATIS AS gratis
FROM `rj-smdue.adm_licenca_urbanismo_staging.compl_tipo_licenca_acao_requerente`
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ CAST(id_bairro_sislic AS STRING) AS Id_Bairro_SISLIC,
CAST(id_ra_sislic AS STRING) AS Id_RA_SISLIC,
CAST(no_bairro AS STRING) AS Nome_Bairro,
CAST(shape AS GEOGRAPHY) AS Coordenadas
FROM `rj-smdue.adm_licenca_urbanismo_staging.georeferenciamento_endereco_obra`
FROM `rj-smdue.adm_licenca_urbanismo_staging.georeferencia_endereco_obra_processo`
2 changes: 1 addition & 1 deletion queries/models/adm_licenca_urbanismo/logradouro.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
codLogra AS AS Id_Logradouro,
codLogra AS Id_Logradouro,
codLograSMF AS codigo_Lograuro_SMF,
codTipoLogra AS Tipo_Logradouro,
codNobreza AS Codigo_Nobreza,
Expand Down
4 changes: 2 additions & 2 deletions queries/models/adm_licenca_urbanismo/profissao_preo_prpa.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT
ID_PROFISSAO AS id_profissão,
DS_PROFISSAO AS nome_profissão
ID_PROFISSAO AS id_profissao,
DS_PROFISSAO AS nome_profissao
FROM `rj-smdue.adm_licenca_urbanismo_staging.profissao_preo_prpa`

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT
cod_lic AS id_licenca,
descr_lic AS nome_licenca
FROM `rj-smdue.adm_licenca_urbanismo_staging.tipo_licenca_acao_prefeitura_3`

0 comments on commit 7d89ff6

Please sign in to comment.