-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into world_wb_mides_continuation
- Loading branch information
Showing
22 changed files
with
814 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,10 @@ models: | |
+schema: br_bcb_agencia | ||
br_bcb_estban: | ||
+materialized: table | ||
+schema: br_bcb_estban | ||
+schema: br_bcb_estban | ||
br_bcb_sicor: | ||
+materialized: table | ||
+schema: br_bcb_sicor | ||
br_bcb_taxa_cambio: | ||
+materialized: table | ||
+schema: br_bcb_taxa_cambio | ||
|
@@ -163,6 +166,12 @@ models: | |
+post-hook: | ||
- 'REVOKE `roles/bigquery.dataViewer` ON TABLE {{ this }} FROM "specialGroup:allUsers"' | ||
- 'GRANT `roles/bigquery.dataViewer` ON TABLE {{ this }} TO "group:[email protected]"' | ||
br_mg_belohorizonte_smfa_iptu: | ||
+materialized: table | ||
+schema: br_mg_belohorizonte_smfa_iptu | ||
+post-hook: | ||
- 'REVOKE `roles/bigquery.dataViewer` ON TABLE {{ this }} FROM "specialGroup:allUsers"' | ||
- 'GRANT `roles/bigquery.dataViewer` ON TABLE {{ this }} TO "group:[email protected]"' | ||
br_mp_pep: | ||
+materialized: table | ||
+schema: br_mp_pep | ||
|
@@ -208,6 +217,9 @@ models: | |
br_tse_eleicoes_2022: | ||
+materialized: table | ||
+schema: br_tse_eleicoes_2022 | ||
br_rf_cafir: | ||
+materialized: table | ||
+schema: br_rf_cafir | ||
fundacao_lemann: | ||
+materialized: table | ||
+schema: fundacao_lemann | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{{ config( | ||
alias='microdados', | ||
schema='br_anp_precos_combustiveis', | ||
materialized='table', | ||
materialized='incremental', | ||
partition_by={ | ||
"field": "ano", | ||
"data_type": "int64", | ||
|
@@ -11,9 +11,18 @@ | |
"interval": 1} | ||
}, | ||
cluster_by = ["id_municipio", "sigla_uf"], | ||
labels = {'project_id': 'basedosdados'}) | ||
}} | ||
|
||
labels = {'project_id': 'basedosdados-dev'}, | ||
pre_hook = "DROP ALL ROW ACCESS POLICIES ON {{ this }}", | ||
post_hook = [ | ||
'CREATE OR REPLACE ROW ACCESS POLICY allusers_filter | ||
ON {{this}} | ||
GRANT TO ("allUsers") | ||
FILTER USING (DATE_DIFF(CURRENT_DATE(),DATE(data_coleta), week) > 6)', | ||
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter | ||
ON {{this}} | ||
GRANT TO ("group:[email protected]", "group:[email protected]") | ||
FILTER USING (EXTRACT(YEAR from data_coleta) = EXTRACT(YEAR from CURRENT_DATE()))'])}} | ||
WITH anp AS ( | ||
SELECT | ||
SAFE_CAST(ano AS INT64) ano, | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
|
@@ -29,5 +38,8 @@ INITCAP(produto) AS produto, | |
SAFE_CAST(unidade_medida AS STRING) unidade_medida, | ||
SAFE_CAST(preco_compra AS FLOAT64) preco_compra, | ||
SAFE_CAST(preco_venda AS FLOAT64) preco_venda | ||
FROM basedosdados-staging.br_anp_precos_combustiveis_staging.microdados AS t | ||
WHERE DATE(data_coleta) <= DATE_SUB(CURRENT_DATE, INTERVAL 6 WEEK) | ||
FROM basedosdados-staging.br_anp_precos_combustiveis_staging.microdados AS t) | ||
SELECT * FROM anp | ||
{% if is_incremental() %} | ||
WHERE data_coleta> (SELECT MAX(data_coleta) FROM {{ this }}) | ||
{% endif %} |
34 changes: 0 additions & 34 deletions
34
models/br_anp_precos_combustiveis/br_anp_precos_combustiveis__microdados_atualizado.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
--- registrando novamente o dicionário | ||
{{ config(alias='dicionario', schema='br_b3_cotacoes') }} | ||
|
||
|
||
SELECT | ||
SAFE_CAST(id_tabela AS STRING) id_tabela, | ||
SAFE_CAST(nome_coluna AS STRING) nome_coluna, | ||
SAFE_CAST(chave AS STRING) chave, | ||
SAFE_CAST(cobertura_temporal AS STRING) cobertura_temporal, | ||
SAFE_CAST(valor AS STRING) valor | ||
|
||
FROM basedosdados-staging.br_b3_cotacoes_staging.dicionario AS t | ||
FROM basedosdados-staging.br_b3_cotacoes_staging.dicionario AS t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{ | ||
config( | ||
alias = 'dicionario', | ||
schema='br_bcb_sicor', | ||
materialized='table', | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(id_tabela AS STRING) id_tabela, | ||
SAFE_CAST(nome_coluna AS STRING) nome_coluna, | ||
SAFE_CAST(chave AS STRING) chave, | ||
SAFE_CAST(cobertura_temporal AS STRING) cobertura_temporal, | ||
SAFE_CAST(valor AS STRING) valor | ||
FROM basedosdados-staging.br_bcb_sicor_staging.dicionario AS t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{{ | ||
config( | ||
alias = 'empreendimento', | ||
schema='br_bcb_sicor', | ||
materialized='table', | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(id_empreendimento AS STRING) id_empreendimento, | ||
SAFE_CAST(data_inicio_empreendimento AS DATE) data_inicio, | ||
SAFE_CAST(data_fim_empreendimento AS DATE) data_fim, | ||
SAFE_CAST(finalidade AS STRING) finalidade, | ||
SAFE_CAST(atividade AS STRING) atividade, | ||
SAFE_CAST(modalidade AS STRING) modalidade, | ||
SAFE_CAST(produto AS STRING) produto, | ||
SAFE_CAST(variedade AS STRING) variedade, | ||
SAFE_CAST(cesta_safra AS STRING) cesta_safra, | ||
SAFE_CAST(zoneamento AS STRING) zoneamento, | ||
SAFE_CAST(unidade_medida AS STRING) unidade_medida, | ||
SAFE_CAST(unidade_medida_previsao_producao AS STRING) unidade_medida_previsao_producao, | ||
SAFE_CAST(consorcio AS STRING) consorcio, | ||
SAFE_CAST(cedula_mae AS STRING) cedula_mae, | ||
SAFE_CAST(id_tipo_cultura AS STRING) id_tipo_cultura | ||
FROM basedosdados-staging.br_bcb_sicor_staging.empreendimento AS t |
26 changes: 26 additions & 0 deletions
26
models/br_bcb_sicor/br_bcb_sicor__microdados_liberacao.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{ | ||
config( | ||
alias = 'microdados_liberacao', | ||
schema='br_bcb_sicor', | ||
materialized='table', | ||
partition_by={ | ||
"field": "ano", | ||
"data_type": "int64", | ||
"range": { | ||
"start": 2013, | ||
"end": 2024, | ||
"interval": 1} | ||
}, | ||
cluster_by = ["mes"] | ||
) | ||
}} | ||
|
||
|
||
SELECT | ||
SAFE_CAST(ano AS INT64) ano, | ||
SAFE_CAST(mes AS INT64) mes, | ||
SAFE_CAST(data_liberacao AS DATE) data_liberacao, | ||
SAFE_CAST(id_referencia_bacen AS STRING) id_referencia_bacen, | ||
SAFE_CAST(numero_ordem AS STRING) numero_ordem, | ||
SAFE_CAST(valor_liberado AS FLOAT64) valor_liberado | ||
FROM basedosdados-staging.br_bcb_sicor_staging.microdados_liberacao AS t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{{ | ||
config( | ||
alias = 'microdados_operacao', | ||
schema='br_bcb_sicor', | ||
materialized='table', | ||
partition_by={ | ||
"field": "ano", | ||
"data_type": "int64", | ||
"range": { | ||
"start": 2013, | ||
"end": 2024, | ||
"interval": 1} | ||
}, | ||
cluster_by = ["sigla_uf", "plano_safra_emissao"] | ||
) | ||
}} | ||
|
||
SELECT | ||
SAFE_CAST(ano AS INT64) ano, | ||
SAFE_CAST(mes AS INT64) mes, | ||
SAFE_CAST(data_emissao AS DATE) data_emissao, | ||
SAFE_CAST(ano_vencimento AS INT64) ano_vencimento, | ||
SAFE_CAST(mes_vencimento AS INT64) mes_vencimento, | ||
SAFE_CAST(data_vencimento AS DATE) data_vencimento, | ||
SAFE_CAST(plano_safra_emissao AS STRING) plano_safra_emissao, | ||
SAFE_CAST(plano_safra_vencimento AS STRING) plano_safra_vencimento, | ||
SAFE_CAST(sigla_uf AS STRING) sigla_uf, | ||
SAFE_CAST(id_referencia_bacen AS STRING) id_referencia_bacen, | ||
SAFE_CAST(numero_ordem AS STRING) numero_ordem, | ||
SAFE_CAST(id_categoria_emitente AS STRING) id_categoria_emitente, | ||
SAFE_CAST(id_empreendimento AS STRING) id_empreendimento, | ||
SAFE_CAST(id_fase_ciclo_producao AS STRING) id_fase_ciclo_producao, | ||
SAFE_CAST(id_fonte_recurso AS STRING) id_fonte_recurso, | ||
SAFE_CAST(id_instrumento_credito AS STRING) id_instrumento_credito, | ||
SAFE_CAST(id_programa AS STRING) id_programa, | ||
SAFE_CAST(id_referencia_bacen_investimento AS STRING) id_referencia_bacen_investimento, | ||
SAFE_CAST(id_subprograma AS STRING) id_subprograma, | ||
SAFE_CAST(id_tipo_agricultura AS STRING) id_tipo_agricultura, | ||
SAFE_CAST(id_tipo_cultivo AS STRING) id_tipo_cultivo, | ||
SAFE_CAST(id_tipo_encargo_financeiro AS STRING) id_tipo_encargo_financeiro, | ||
SAFE_CAST(id_tipo_grao_semente AS STRING) id_tipo_grao_semente, | ||
SAFE_CAST(id_tipo_integracao_consorcio AS STRING) id_tipo_integracao_consorcio, | ||
SAFE_CAST(id_tipo_irrigacao AS STRING) id_tipo_irrigacao, | ||
SAFE_CAST(id_tipo_seguro AS STRING) id_tipo_seguro, | ||
SAFE_CAST(cnpj_agente_investimento AS STRING) cnpj_agente_investimento, | ||
SAFE_CAST(cnpj_basico_instituicao_financeira AS STRING) cnpj_basico_instituicao_financeira, | ||
SAFE_CAST(id_contrato_sistema_tesouro_nacional AS STRING) id_contrato_sistema_tesouro_nacional, | ||
SAFE_CAST(cnpj_cadastrante AS STRING) cnpj_cadastrante, | ||
SAFE_CAST(data_fim_colheita AS DATE) data_fim_colheita, | ||
SAFE_CAST(data_fim_plantio AS DATE) data_fim_plantio, | ||
SAFE_CAST(data_inicio_colheita AS DATE) data_inicio_colheita, | ||
SAFE_CAST(data_inicio_plantio AS DATE) data_inicio_plantio, | ||
SAFE_CAST(area_financiada AS FLOAT64) area_financiada, | ||
SAFE_CAST(valor_aliquota_proagro AS FLOAT64) valor_aliquota_proagro, | ||
SAFE_CAST(valor_parcela_credito AS FLOAT64) valor_parcela_credito, | ||
SAFE_CAST(valor_prestacao_investimento AS FLOAT64) valor_prestacao_investimento, | ||
SAFE_CAST(valor_recurso_proprio AS FLOAT64) valor_recurso_proprio, | ||
SAFE_CAST(valor_receita_bruta_esperada AS FLOAT64) valor_receita_bruta_esperada, | ||
SAFE_CAST(valor_recurso_proprio_srv AS FLOAT64) valor_recurso_proprio_srv, | ||
SAFE_CAST(valor_quantidade_itens_financiados AS FLOAT64) valor_quantidade_itens_financiados, | ||
SAFE_CAST(valor_produtividade_obtida AS FLOAT64) valor_produtividade_obtida, | ||
SAFE_CAST(valor_previsao_producao AS FLOAT64) valor_previsao_producao, | ||
SAFE_CAST(taxa_juro AS FLOAT64) taxa_juro, | ||
SAFE_CAST(taxa_juro_encargo_financeiro_posfixado AS FLOAT64) taxa_juro_encargo_financeiro_posfixado, | ||
SAFE_CAST(valor_percentual_custo_efetivo_total AS FLOAT64) valor_percentual_custo_efetivo_total, | ||
SAFE_CAST(valor_percentual_risco_fundo_constitucional AS FLOAT64) valor_percentual_risco_fundo_constitucional, | ||
SAFE_CAST(valor_percentual_risco_stn AS FLOAT64) valor_percentual_risco_stn | ||
FROM basedosdados-staging.br_bcb_sicor_staging.microdados_operacao AS t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{ | ||
config( | ||
alias = 'microdados_saldo', | ||
schema='br_bcb_sicor', | ||
materialized='table', | ||
partition_by={ | ||
"field": "ano", | ||
"data_type": "int64", | ||
"range": { | ||
"start": 2013, | ||
"end": 2024, | ||
"interval": 1} | ||
}, | ||
cluster_by = ["mes"] | ||
) | ||
}} | ||
|
||
SELECT | ||
SAFE_CAST(ano AS INT64) ano, | ||
SAFE_CAST(mes AS INT64) mes, | ||
SAFE_CAST(id_referencia_bacen AS STRING) id_referencia_bacen, | ||
SAFE_CAST(numero_ordem AS STRING) numero_ordem, | ||
SAFE_CAST(id_situacao_operacao AS STRING) id_situacao_operacao, | ||
SAFE_CAST(valor_medio_diario AS FLOAT64) valor_medio_diario, | ||
SAFE_CAST(valor_medio_diario_vincendo AS FLOAT64) valor_medio_diario_vincendo, | ||
SAFE_CAST(valor_ultimo_dia AS FLOAT64) valor_ultimo_dia | ||
FROM basedosdados-staging.br_bcb_sicor_staging.microdados_saldo AS t |
19 changes: 19 additions & 0 deletions
19
models/br_bcb_sicor/br_bcb_sicor__recurso_publico_complemento_operacao.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{ | ||
config( | ||
alias = 'recurso_publico_complemento_operacao', | ||
schema='br_bcb_sicor', | ||
materialized='table', | ||
partition_by = { | ||
"field": "id_municipio", | ||
"data_type": "string" | ||
} | ||
) | ||
}} | ||
|
||
SELECT | ||
SAFE_CAST(id_referencia_bacen AS STRING) id_referencia_bacen, | ||
SAFE_CAST(id_municipio AS STRING) id_municipio, | ||
SAFE_CAST(numero_ordem AS STRING) numero_ordem, | ||
SAFE_CAST(id_referencia_bacen_efetivo AS STRING) id_referencia_bacen_efetivo, | ||
SAFE_CAST(id_agencia AS STRING) id_agencia | ||
FROM basedosdados-staging.br_bcb_sicor_staging.recurso_publico_complemento_operacao AS t |
15 changes: 15 additions & 0 deletions
15
models/br_bcb_sicor/br_bcb_sicor__recurso_publico_cooperado.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ | ||
config( | ||
alias = 'recurso_publico_cooperado', | ||
schema='br_bcb_sicor', | ||
materialized='table', | ||
) | ||
}} | ||
|
||
SELECT | ||
SAFE_CAST(id_referencia_bacen AS STRING) id_referencia_bacen, | ||
SAFE_CAST(numero_ordem AS STRING) numero_ordem, | ||
SAFE_CAST(tipo_cpf_cnpj AS STRING) tipo_cpf_cnpj, | ||
SAFE_CAST(tipo_pessoa AS STRING) tipo_pessoa, | ||
SAFE_CAST(valor_parcela AS FLOAT64) valor_parcela | ||
FROM basedosdados-staging.br_bcb_sicor_staging.recurso_publico_cooperado AS t |
16 changes: 16 additions & 0 deletions
16
models/br_bcb_sicor/br_bcb_sicor__recurso_publico_gleba.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{ | ||
config( | ||
alias = 'recurso_publico_gleba', | ||
schema='br_bcb_sicor', | ||
materialized='table' | ||
) | ||
}} | ||
SELECT | ||
SAFE_CAST(id_referencia_bacen AS STRING) id_referencia_bacen, | ||
SAFE_CAST(numero_ordem AS STRING) numero_ordem, | ||
SAFE_CAST(numero_identificador_gleba AS STRING) numero_identificador_gleba, | ||
SAFE_CAST(indice_indice_gleba AS INT64) indice_gleba, | ||
SAFE_CAST(indice_indice_ponto AS INT64) indice_ponto, | ||
ST_GEOGPOINT(SAFE_CAST(longitude AS FLOAT64),SAFE_CAST(latitude AS FLOAT64)) ponto, | ||
SAFE_CAST(altitude AS FLOAT64) altitude | ||
FROM basedosdados-staging.br_bcb_sicor_staging.recurso_publico_gleba AS t |
Oops, something went wrong.