Skip to content

Commit

Permalink
Adição de Testes
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-ls committed Oct 25, 2024
1 parent 16a6e6a commit 1d34e89
Show file tree
Hide file tree
Showing 11 changed files with 895 additions and 67 deletions.
18 changes: 15 additions & 3 deletions models/br_rf_arrecadacao/br_rf_arrecadacao__cnae.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
{{ config(alias="cnae", schema="br_rf_arrecadacao") }}
{{
config(
schema="br_rf_arrecadacao",
alias="cnae",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2016, "end": 2024, "interval": 1},
},
cluster_by=["mes"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
safe_cast(secao_sigla as string) secao_sigla,
safe_cast(secao_nome as string) secao_nome,
safe_cast(imposto_importacao as float64) imposto_importacao,
safe_cast(imposto_exportacao as float64) imposto_exportacao,
safe_cast(ipi as float64) ipi,
Expand All @@ -21,4 +33,4 @@ select
safe_cast(pagamento_unificado as float64) pagamento_unificado,
safe_cast(outras_receitas_rfb as float64) outras_receitas_rfb,
safe_cast(demais_receitas as float64) demais_receitas,
from `basedosdados-staging.br_rf_arrecadacao_staging.cnae` as t
from `basedosdados-dev.br_rf_arrecadacao_staging.cnae` as t
17 changes: 15 additions & 2 deletions models/br_rf_arrecadacao/br_rf_arrecadacao__ir_ipi.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
{{ config(alias="ir_ipi", schema="br_rf_arrecadacao") }}
{{
config(
schema="br_rf_arrecadacao",
alias="ir_ipi",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2019, "end": 2024, "interval": 1},
},
cluster_by=["mes"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
Expand All @@ -10,4 +23,4 @@ select
safe_cast(restituicao as float64) restituicao,
safe_cast(outros as float64) outros,
safe_cast(arrecadacao_liquida as float64) arrecadacao_liquida,
from `basedosdados-staging.br_rf_arrecadacao_staging.ir_ipi` as t
from `basedosdados-dev.br_rf_arrecadacao_staging.ir_ipi` as t
23 changes: 18 additions & 5 deletions models/br_rf_arrecadacao/br_rf_arrecadacao__itr.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
{{ config(alias="itr", schema="br_rf_arrecadacao") }}
{{
config(
schema="br_rf_arrecadacao",
alias="itr",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2017, "end": 2024, "interval": 1},
},
cluster_by=["mes"],
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(mes as int64) mes,
safe_cast(nome_uf as string) nome_uf,
safe_cast(regiao_politica as string) regiao_politica,
safe_cast(cidade_uf as string) cidade_uf,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(sigla_regiao as string) sigla_regiao,
safe_cast(cidade as string) cidade,
safe_cast(valor_arrecadado as float64) valor_arrecadado,
from `basedosdados-staging.br_rf_arrecadacao_staging.itr` as t
from `basedosdados-dev.br_rf_arrecadacao_staging.itr` as t
22 changes: 17 additions & 5 deletions models/br_rf_arrecadacao/br_rf_arrecadacao__natureza_juridica.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
{{ config(alias="natureza_juridica", schema="br_rf_arrecadacao") }}
{{
config(
schema="br_rf_arrecadacao",
alias="natureza_juridica",
materialized="table",
partition_by={
"field": "ano",
"data_type": "int64",
"range": {"start": 2016, "end": 2024, "interval": 1},
},
cluster_by=["mes"],
)
}}

with
referencia_codigo as (
select
id_natureza_juridica,
substr(cast(id_natureza_juridica as string), 0, 3) as inicio_codigo
from basedosdados - staging.br_bd_diretorios_brasil.natureza_juridica
from basedosdados - dev.br_bd_diretorios_brasil.natureza_juridica
)
select
safe_cast(t.ano as int64) ano,
safe_cast(t.mes as int64) mes,
safe_cast(
referencia_codigo.id_natureza_juridica as string
) natureza_juridica_codigo,
safe_cast(t.natureza_juridica_nome as string) natureza_juridica_nome,
safe_cast(t.imposto_importacao as float64) imposto_importacao,
safe_cast(t.imposto_exportacao as float64) imposto_exportacao,
safe_cast(t.ipi as float64) ipi,
Expand All @@ -30,6 +42,6 @@ select
safe_cast(t.pagamento_unificado as float64) pagamento_unificado,
safe_cast(t.outras_receitas_rfb as float64) outras_receitas_rfb,
safe_cast(t.demais_receitas as float64) demais_receitas,
from `basedosdados-staging.br_rf_arrecadacao_staging.natureza_juridica` as t
left join
from `basedosdados-dev.br_rf_arrecadacao_staging.natureza_juridica` as t
inner join
referencia_codigo on t.natureza_juridica_codigo = referencia_codigo.inicio_codigo
2 changes: 1 addition & 1 deletion models/br_rf_arrecadacao/br_rf_arrecadacao__uf.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ select
safe_cast(receita_previdenciaria_propria as float64) receita_previdenciaria_propria,
safe_cast(receita_previdenciaria_demais as float64) receita_previdenciaria_demais,
safe_cast(receitas_outros_orgaos as float64) receitas_outros_orgaos,
from `basedosdados-staging.br_rf_arrecadacao_staging.uf` as t
from `basedosdados-dev.br_rf_arrecadacao_staging.uf` as t
Loading

0 comments on commit 1d34e89

Please sign in to comment.