diff --git a/models/world_wb_mides/world_wb_mides__empenho.sql b/models/world_wb_mides/world_wb_mides__empenho.sql index d509d78e..a739de5d 100644 --- a/models/world_wb_mides/world_wb_mides__empenho.sql +++ b/models/world_wb_mides/world_wb_mides__empenho.sql @@ -107,7 +107,7 @@ from safe_cast(codigo_elemento_despesa as int64) as string ) as modalidade_despesa, round(safe_cast(valor_empenhado as float64), 2) as valor_inicial, - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_ce` e + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_ce` e ), anulacao_ce as ( select @@ -129,7 +129,7 @@ from round( sum(safe_cast(valor_anulacao as float64)), 2 ) as valor_anulacao - from `basedosdados-dev.world_wb_mides_staging.raw_anulacao_ce` + from `basedosdados-staging.world_wb_mides_staging.raw_anulacao_ce` group by 1 ), frequencia_ce as ( @@ -240,7 +240,7 @@ from ), 2 ) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_mg` + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_mg` ), dlic as ( select @@ -419,15 +419,15 @@ from cd_elemento ) as elemento_despesa, safe_cast(vl_empenho as float64) as valor_inicial - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_pb` e + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_pb` e left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_pb` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_pb` m on e.cd_ugestora = safe_cast(m.id_unidade_gestora as string) left join - `basedosdados-dev.world_wb_mides_staging.aux_funcao` f + `basedosdados-staging.world_wb_mides_staging.aux_funcao` f on e.de_funcao = f.nome_funcao left join - `basedosdados-dev.world_wb_mides_staging.aux_subfuncao` sf + `basedosdados-staging.world_wb_mides_staging.aux_subfuncao` sf on e.de_subfuncao = sf.nome_subfuncao ), anulacao_pb as ( @@ -444,9 +444,9 @@ from ) as string ) as id_empenho_bd, sum(safe_cast(vl_estorno as float64)) as valor_anulacao - from `basedosdados-dev.world_wb_mides_staging.raw_estorno_pb` a + from `basedosdados-staging.world_wb_mides_staging.raw_estorno_pb` a left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_pb` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_pb` m on a.cd_ugestora = safe_cast(m.id_unidade_gestora as string) group by 1 ), @@ -848,12 +848,12 @@ from round(safe_cast(0 as float64), 2) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(valorempenhado as float64), 2) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_pe` e + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_pe` e left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_pe` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_pe` m on e.nomeunidadegestora = m.nomeunidadegestora left join - `basedosdados-dev.world_wb_mides_staging.aux_funcao` fun + `basedosdados-staging.world_wb_mides_staging.aux_funcao` fun on upper( trim( replace( @@ -867,7 +867,7 @@ from ) = upper(nome_funcao) left join - `basedosdados-dev.world_wb_mides_staging.aux_subfuncao` sub + `basedosdados-staging.world_wb_mides_staging.aux_subfuncao` sub on upper(trim(e.subfuncao)) = upper(nome_subfuncao) ), empenho_pr as ( @@ -910,7 +910,7 @@ from - ifnull(safe_cast(vlestornoempenho as float64), 0), 2 ) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_pr` e + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_pr` e left join basedosdados.br_bd_diretorios_brasil.municipio m on e.cdibge = m.id_municipio_6 @@ -959,9 +959,9 @@ from replace(cd_elemento, '.', '') as string ) as elemento_despesa, safe_cast(vl_empenho as float64) as valor_inicial - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_rs` as c + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_rs` as c left join - `basedosdados-dev.world_wb_mides_staging.aux_orgao_rs` as a + `basedosdados-staging.world_wb_mides_staging.aux_orgao_rs` as a on c.cd_orgao = a.cd_orgao left join `basedosdados.br_bd_diretorios_brasil.municipio` m @@ -1009,9 +1009,9 @@ from ) as string ) as id_empenho_bd, -1 * sum(safe_cast(vl_empenho as float64)) as valor_anulacao - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_rs` as c + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_rs` as c left join - `basedosdados-dev.world_wb_mides_staging.aux_orgao_rs` as a + `basedosdados-staging.world_wb_mides_staging.aux_orgao_rs` as a on c.cd_orgao = a.cd_orgao left join `basedosdados.br_bd_diretorios_brasil.municipio` m @@ -1252,15 +1252,15 @@ from safe_cast(safe_cast(cd_acao as int64) as string) as acao, safe_cast((left(ds_elemento, 8)) as string) as elemento_despesa, safe_cast(replace(vl_despesa, ',', '.') as float64) as valor_inicial - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_sp` e + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_sp` e left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_sp` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_sp` m on m.ds_orgao = e.ds_orgao left join - `basedosdados-dev.world_wb_mides_staging.aux_funcao` + `basedosdados-staging.world_wb_mides_staging.aux_funcao` on ds_funcao_governo = upper(nome_funcao) left join - `basedosdados-dev.world_wb_mides_staging.aux_subfuncao` + `basedosdados-staging.world_wb_mides_staging.aux_subfuncao` on ds_subfuncao_governo = upper(nome_subfuncao) where tp_despesa = 'Empenhado' ), @@ -1286,9 +1286,9 @@ from sum( safe_cast(replace(vl_despesa, ',', '.') as float64) ) as valor_anulacao - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_sp` a + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_sp` a left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_sp` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_sp` m on m.ds_orgao = a.ds_orgao where tp_despesa = 'Anulação' group by 1 @@ -1309,9 +1309,9 @@ from sum( safe_cast(replace(vl_despesa, ',', '.') as float64) ) as valor_reforco - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_sp` r + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_sp` r left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_sp` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_sp` m on m.ds_orgao = r.ds_orgao where tp_despesa = 'Reforço' group by 1 @@ -1537,7 +1537,7 @@ from 2 ) as valor_final, from - `basedosdados-dev.world_wb_mides_staging.raw_despesa_sp_municipio` + `basedosdados-staging.world_wb_mides_staging.raw_despesa_sp_municipio` ), empenhado_municipio_rj_v1 as ( select @@ -1608,7 +1608,7 @@ from ) as modalidade_despesa, round(safe_cast(valor_empenhado as float64), 2) as valor_final, from - `basedosdados-dev.world_wb_mides_staging.raw_despesa_rj_municipio` + `basedosdados-staging.world_wb_mides_staging.raw_despesa_rj_municipio` where (safe_cast(exercicio_empenho as int64)) < 2017 ), frequencia_rj_v1 as ( @@ -1791,7 +1791,7 @@ from ) as string ) as elemento_despesa, round(safe_cast(valor as float64), 2) as valor_inicial, - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_ato_rj_municipio` + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_ato_rj_municipio` where tipoato = 'EMPENHO' ), anulacao_municipio_rj_v2 as ( @@ -1810,7 +1810,7 @@ from ) as string ) as id_empenho_bd, round(sum(safe_cast(valor as float64)), 2) as valor_anulacao, - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_ato_rj_municipio` + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_ato_rj_municipio` where tipoato = 'CANCELAMENTO EMPENHO' group by 1 ), @@ -1883,7 +1883,7 @@ from safe_cast(atividade as string) as acao, safe_cast(elemento_despesa as string) as elemento_despesa, round(safe_cast(valor as float64), 2) as valor_inicial, - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_rj` + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_rj` where numero_empenho is not null ), anulacao_rj as ( @@ -1900,7 +1900,7 @@ from ) as string ) as id_empenho_bd, round(safe_cast(valor as float64), 2) as valor_anulacao, - from `basedosdados-dev.world_wb_mides_staging.raw_anulacao_rj` + from `basedosdados-staging.world_wb_mides_staging.raw_anulacao_rj` where despesa_liquidada = 'NÃO' and numero_empenho is not null ), empenho_rj as ( @@ -2028,7 +2028,7 @@ from round(safe_cast(0 as float64), 2) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(replace (valor_final, ',', '.') as float64), 2) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_df` + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_df` ), empenhado_sc AS ( select @@ -2070,7 +2070,7 @@ from round(safe_cast (0 as float64),2) as valor_anulacao, round(safe_cast (0 as float64),2) as valor_ajuste, round(safe_cast (valor_empenho as float64),2) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_sc` + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_sc` ), frequencia_sc as ( select id_empenho_bd, count(id_empenho_bd) as frequencia_id diff --git a/models/world_wb_mides/world_wb_mides__liquidacao.sql b/models/world_wb_mides/world_wb_mides__liquidacao.sql index de5e046f..def7c00c 100644 --- a/models/world_wb_mides/world_wb_mides__liquidacao.sql +++ b/models/world_wb_mides/world_wb_mides__liquidacao.sql @@ -82,9 +82,9 @@ from round(safe_cast(0 as float64), 2) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(valor_liquidado as float64), 2) as valor_final, - from `basedosdados-dev.world_wb_mides_staging.raw_liquidacao_ce` l + from `basedosdados-staging.world_wb_mides_staging.raw_liquidacao_ce` l left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_ce` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_ce` m on l.codigo_municipio = m.codigo_municipio ), liquidacao_mg as ( @@ -161,9 +161,9 @@ from - ifnull(safe_cast(valor_anulado as float64), 0), 2 ) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_liquidacao_mg` as l + from `basedosdados-staging.world_wb_mides_staging.raw_liquidacao_mg` as l left join - `basedosdados-dev.world_wb_mides_staging.raw_rsp_mg` as r + `basedosdados-staging.world_wb_mides_staging.raw_rsp_mg` as r on l.id_rsp = r.id_rsp ), liquidacao_pb as ( @@ -206,9 +206,9 @@ from round(safe_cast(0 as float64), 2) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(vl_liquidacao as float64), 2) as valor_final, - from `basedosdados-dev.world_wb_mides_staging.raw_liquidacao_pb` l + from `basedosdados-staging.world_wb_mides_staging.raw_liquidacao_pb` l left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_pb` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_pb` m on l.cd_ugestora = safe_cast(m.id_unidade_gestora as string) ), liquidacao_pr as ( @@ -241,12 +241,12 @@ from ) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(vlliquidacaoliquido as float64), 2) as valor_final, - from `basedosdados-dev.world_wb_mides_staging.raw_liquidacao_pr` l + from `basedosdados-staging.world_wb_mides_staging.raw_liquidacao_pr` l left join basedosdados.br_bd_diretorios_brasil.municipio m on cdibge = id_municipio_6 left join - `basedosdados-dev.world_wb_mides_staging.raw_empenho_pr` e + `basedosdados-staging.world_wb_mides_staging.raw_empenho_pr` e on l.idempenho = e.idempenho ), liquidacao_pe as ( @@ -271,9 +271,9 @@ from round(safe_cast(0 as float64), 2) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(valor as float64), 2) as valor_final, - from `basedosdados-dev.world_wb_mides_staging.raw_liquidacao_pe` l + from `basedosdados-staging.world_wb_mides_staging.raw_liquidacao_pe` l left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_pe` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_pe` m on l.id_unidade_gestora = safe_cast(m.id_unidadegestora as string) ), liquidado_rs as ( @@ -324,9 +324,9 @@ from safe_cast(null as string) as documento_responsavel, safe_cast(null as bool) as indicador_restos_pagar, safe_cast(vl_liquidacao as float64) as valor_inicial - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_rs` as c + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_rs` as c left join - `basedosdados-dev.world_wb_mides_staging.aux_orgao_rs` as a + `basedosdados-staging.world_wb_mides_staging.aux_orgao_rs` as a on c.cd_orgao = a.cd_orgao left join `basedosdados.br_bd_diretorios_brasil.municipio` m @@ -348,9 +348,9 @@ from ) as string ) as id_empenho_bd, -1 * sum(safe_cast(vl_liquidacao as float64)) as valor_anulacao - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_rs` as c + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_rs` as c left join - `basedosdados-dev.world_wb_mides_staging.aux_orgao_rs` as a + `basedosdados-staging.world_wb_mides_staging.aux_orgao_rs` as a on c.cd_orgao = a.cd_orgao left join `basedosdados.br_bd_diretorios_brasil.municipio` m @@ -509,15 +509,15 @@ from safe_cast(cd_acao as string) as acao, safe_cast((left(ds_elemento, 8)) as string) as elemento_despesa, safe_cast(replace(vl_despesa, ',', '.') as float64) as valor_inicial - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_sp` e + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_sp` e left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_sp` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_sp` m on m.ds_orgao = e.ds_orgao left join - `basedosdados-dev.world_wb_mides_staging.aux_funcao` + `basedosdados-staging.world_wb_mides_staging.aux_funcao` on ds_funcao_governo = upper(nome_funcao) left join - `basedosdados-dev.world_wb_mides_staging.aux_subfuncao` + `basedosdados-staging.world_wb_mides_staging.aux_subfuncao` on ds_subfuncao_governo = upper(nome_subfuncao) where tp_despesa = 'Valor Liquidado' ), @@ -684,7 +684,7 @@ from round(safe_cast(0 as float64), 2) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(liquidado as float64), 2) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_sp_municipio` + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_sp_municipio` ), liquidado_municipio_rj_v1 as ( select @@ -722,7 +722,7 @@ from round(safe_cast(0 as float64), 2) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(valor_liquidado as float64), 2) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_rj_municipio` + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_rj_municipio` where (safe_cast (exercicio_empenho as int64)) < 2017 ), frequencia_rj_v1 as ( @@ -808,7 +808,7 @@ from safe_cast(null as bool) as indicador_restos_pagar, round(safe_cast(valor as float64), 2) as valor_inicial from - `basedosdados-dev.world_wb_mides_staging.raw_despesa_ato_rj_municipio` + `basedosdados-staging.world_wb_mides_staging.raw_despesa_ato_rj_municipio` where tipoato = 'LIQUIDACAO' ), anulacao_municipio_rj_v2 as ( @@ -829,7 +829,7 @@ from ) as id_empenho_bd, sum(safe_cast(valor as float64)) as valor_anulacao, from - `basedosdados-dev.world_wb_mides_staging.raw_despesa_ato_rj_municipio` + `basedosdados-staging.world_wb_mides_staging.raw_despesa_ato_rj_municipio` where tipoato in ( 'CANCELAMENTO LIQUIDACAO', @@ -908,7 +908,7 @@ from round(safe_cast(0 as float64), 2) as valor_anulacao, round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(valor as float64), 2) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_liquidacao_rj` + from `basedosdados-staging.world_wb_mides_staging.raw_liquidacao_rj` where numero_empenho is not null ), liquidacao_df as ( @@ -963,7 +963,7 @@ from round( safe_cast(replace(valor, ',', '.') as float64), 2 ) as valor_inicial, - from `basedosdados-dev.world_wb_mides_staging.raw_liquidacao_df` + from `basedosdados-staging.world_wb_mides_staging.raw_liquidacao_df` ), liquidado_sc as ( select @@ -996,7 +996,7 @@ from round(safe_cast (0 as float64),2) as valor_anulacao, round(safe_cast (0 as float64),2) as valor_ajuste, round(safe_cast (valor_liquidacao as float64),2) as valor_final - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_sc` + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_sc` ), frequencia_sc as ( select id_empenho_bd, count(id_empenho_bd) as frequencia_id diff --git a/models/world_wb_mides/world_wb_mides__orgao_unidade_gestora.sql b/models/world_wb_mides/world_wb_mides__orgao_unidade_gestora.sql index 536a46d7..948a5819 100644 --- a/models/world_wb_mides/world_wb_mides__orgao_unidade_gestora.sql +++ b/models/world_wb_mides/world_wb_mides__orgao_unidade_gestora.sql @@ -16,6 +16,6 @@ select safe_cast(id_unidade_gestora as string) id_unidade_gestora, safe_cast(nome_unidade_gestora as string) nome_unidade_gestora, safe_cast(esfera as string) esfera -from `basedosdados-dev.world_wb_mides_staging.orgao_unidade_gestora` as t +from `basedosdados-staging.world_wb_mides_staging.orgao_unidade_gestora` as t -- contém 10 UFs: CE, DF, MG, PB, PE, PR, RJ, RS, SC, SP diff --git a/models/world_wb_mides/world_wb_mides__pagamento.sql b/models/world_wb_mides/world_wb_mides__pagamento.sql index 7621520d..1cdc7820 100644 --- a/models/world_wb_mides/world_wb_mides__pagamento.sql +++ b/models/world_wb_mides/world_wb_mides__pagamento.sql @@ -65,9 +65,9 @@ from ) as string ) as documento_credor, safe_cast(safe_cast(codigo_fonte_ as int64) as string) as fonte, - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_ce` e + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_ce` e left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_ce` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_ce` m on e.codigo_municipio = m.codigo_municipio ), pago_ce as ( @@ -136,9 +136,9 @@ from round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(valor_nota_pagamento as float64), 2) as valor_final, round(safe_cast(0 as float64), 2) as valor_liquido_recebido, - from `basedosdados-dev.world_wb_mides_staging.raw_pagamento_ce` p + from `basedosdados-staging.world_wb_mides_staging.raw_pagamento_ce` p left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_ce` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_ce` m on p.codigo_municipio = m.codigo_municipio ), frequencia_ce as ( @@ -296,9 +296,9 @@ from - ifnull(safe_cast(vlr_ret_fonte as float64), 0), 2 ) as valor_liquido_recebido, - from `basedosdados-dev.world_wb_mides_staging.raw_pagamento_mg` as p + from `basedosdados-staging.world_wb_mides_staging.raw_pagamento_mg` as p left join - `basedosdados-dev.world_wb_mides_staging.raw_rsp_mg` as r + `basedosdados-staging.world_wb_mides_staging.raw_rsp_mg` as r on p.id_rsp = r.id_rsp ), pago_pb as ( @@ -364,15 +364,15 @@ from - safe_cast(vl_retencao as float64), 2 ) as valor_liquido_recebido, - from `basedosdados-dev.world_wb_mides_staging.raw_pagamento_pb` p + from `basedosdados-staging.world_wb_mides_staging.raw_pagamento_pb` p left join - `basedosdados-dev.world_wb_mides_staging.raw_empenho_pb` e + `basedosdados-staging.world_wb_mides_staging.raw_empenho_pb` e on p.nu_empenho = e.nu_empenho and p.cd_ugestora = e.cd_ugestora and p.de_uorcamentaria = e.de_uorcamentaria and p.dt_ano = e.dt_ano left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_pb` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_pb` m on safe_cast(e.cd_ugestora as string) = safe_cast(m.id_unidade_gestora as string) ), @@ -455,9 +455,9 @@ from 2 ) as valor_final, round(safe_cast(0 as float64), 2) as valor_liquido_recebido, - from `basedosdados-dev.world_wb_mides_staging.raw_pagamento_pe` p + from `basedosdados-staging.world_wb_mides_staging.raw_pagamento_pe` p inner join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_pe` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_pe` m on safe_cast(p.id_unidade_gestora as string) = safe_cast(m.id_unidadegestora as string) ), @@ -496,9 +496,9 @@ from round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(p.cdibge as float64), 2) as valor_final, round(safe_cast(0 as float64), 2) as valor_liquido_recebido, - from `basedosdados-dev.world_wb_mides_staging.raw_pagamento_pr` p + from `basedosdados-staging.world_wb_mides_staging.raw_pagamento_pr` p left join - `basedosdados-dev.world_wb_mides_staging.raw_empenho_pr` e + `basedosdados-staging.world_wb_mides_staging.raw_empenho_pr` e on p.idempenho = e.idempenho left join basedosdados.br_bd_diretorios_brasil.municipio m @@ -572,9 +572,9 @@ from safe_cast(null as bool) as indicador_restos_pagar, safe_cast(null as string) as fonte, safe_cast(vl_pagamento as float64) as valor_inicial - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_rs` as c + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_rs` as c left join - `basedosdados-dev.world_wb_mides_staging.aux_orgao_rs` as a + `basedosdados-staging.world_wb_mides_staging.aux_orgao_rs` as a on c.cd_orgao = a.cd_orgao left join `basedosdados.br_bd_diretorios_brasil.municipio` m @@ -617,9 +617,9 @@ from ) as string ) as id_empenho_bd, -1 * sum(safe_cast(vl_pagamento as float64)) as valor_anulacao - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_rs` as c + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_rs` as c left join - `basedosdados-dev.world_wb_mides_staging.aux_orgao_rs` as a + `basedosdados-staging.world_wb_mides_staging.aux_orgao_rs` as a on c.cd_orgao = a.cd_orgao left join `basedosdados.br_bd_diretorios_brasil.municipio` m @@ -877,15 +877,15 @@ from safe_cast(cd_acao as string) as acao, safe_cast((left(ds_elemento, 8)) as string) as elemento_despesa, safe_cast(replace(vl_despesa, ',', '.') as float64) as valor_inicial - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_sp` e + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_sp` e left join - `basedosdados-dev.world_wb_mides_staging.aux_municipio_sp` m + `basedosdados-staging.world_wb_mides_staging.aux_municipio_sp` m on m.ds_orgao = e.ds_orgao left join - `basedosdados-dev.world_wb_mides_staging.aux_funcao` + `basedosdados-staging.world_wb_mides_staging.aux_funcao` on ds_funcao_governo = upper(nome_funcao) left join - `basedosdados-dev.world_wb_mides_staging.aux_subfuncao` + `basedosdados-staging.world_wb_mides_staging.aux_subfuncao` on ds_subfuncao_governo = upper(nome_subfuncao) where tp_despesa = 'Valor Pago' ), @@ -1123,7 +1123,7 @@ from round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(pago as float64), 2) as valor_final, round(safe_cast(pago as float64), 2) as valor_liquido_recebido, - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_sp_municipio` + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_sp_municipio` ), pago_municipio_rj_v1 as ( select @@ -1166,7 +1166,7 @@ from round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(valor_pago as float64), 2) as valor_final, round(safe_cast(valor_pago as float64), 2) as valor_liquido_recebido - from `basedosdados-dev.world_wb_mides_staging.raw_despesa_rj_municipio` + from `basedosdados-staging.world_wb_mides_staging.raw_despesa_rj_municipio` ), frequencia_rj_v1 as ( select id_empenho_bd, count(id_empenho_bd) as frequencia_id @@ -1274,7 +1274,7 @@ from safe_cast(fonterecursos as string) as fonte, round(safe_cast(valor as float64), 2) as valor_inicial, from - `basedosdados-dev.world_wb_mides_staging.raw_despesa_ato_rj_municipio` + `basedosdados-staging.world_wb_mides_staging.raw_despesa_ato_rj_municipio` where tipoato = 'PAGAMENTO' ), anulacao_municipio_rj_v2 as ( @@ -1295,7 +1295,7 @@ from ) as id_empenho_bd, sum(safe_cast(valor as float64)) as valor_anulacao, from - `basedosdados-dev.world_wb_mides_staging.raw_despesa_ato_rj_municipio` + `basedosdados-staging.world_wb_mides_staging.raw_despesa_ato_rj_municipio` where tipoato in ( 'CANCEL.PAGAMENTO RET.DOTAÇÃO', @@ -1390,7 +1390,7 @@ from round(safe_cast(0 as float64), 2) as valor_ajuste, round(safe_cast(valor as float64), 2) as valor_final, round(safe_cast(valor as float64), 2) as valor_liquido_recebido, - from `basedosdados-dev.world_wb_mides_staging.raw_pagamento_rj` + from `basedosdados-staging.world_wb_mides_staging.raw_pagamento_rj` where numero_empenho is not null ), pagamento_df as ( @@ -1489,7 +1489,7 @@ from - safe_cast(replace(valor_cancelado, ',', '.') as float64), 2 ) as valor_liquido_recebido, - from `basedosdados-dev.world_wb_mides_staging.raw_pagamento_df` + from `basedosdados-staging.world_wb_mides_staging.raw_pagamento_df` ), pago_sc AS ( select @@ -1518,7 +1518,7 @@ from round(safe_cast (0 as float64),2) as valor_ajuste, round(safe_cast (valor_pagamento as float64),2) as valor_final, round(safe_cast (valor_pagamento as float64),2) as valor_liquido_recebido - from `basedosdados-dev.world_wb_mides_staging.raw_empenho_sc` + from `basedosdados-staging.world_wb_mides_staging.raw_empenho_sc` ), frequencia_sc as ( select id_empenho_bd, count(id_empenho_bd) as frequencia_id