Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dbt] br_bcb_agencia #125

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion models/br_bcb_agencia/br_bcb_agencia__agencia.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{ config(alias = 'agencia', schema = 'br_bcb_agencia')}}
{{ config(
alias = 'agencia',
schema = 'br_bcb_agencia')
}}

SELECT
SAFE_CAST(ano AS INT64) ano,
Expand All @@ -20,3 +23,4 @@ SAFE_CAST(ddd AS STRING) ddd,
SAFE_CAST(fone AS STRING) fone,
SAFE_CAST(id_instalacao AS STRING) id_instalacao
FROM basedosdados-staging.br_bcb_agencia_staging.agencia AS t
WHERE DATE(CAST(ano AS INT64),CAST(mes AS INT64),1)<= DATE(2023,2,1)
30 changes: 30 additions & 0 deletions models/br_bcb_agencia/br_bcb_agencia__agencia_atualizado.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{ config(
alias = 'agencia_atualizado',
schema = 'br_bcb_agencia',
post_hook=[
'REVOKE `roles/bigquery.dataViewer` ON TABLE {{ this }} FROM "specialGroup:allUsers"',
'GRANT `roles/bigquery.dataViewer` ON TABLE {{ this }} TO "group:bd-pro@basedosdados.org"'])
}}



SELECT
SAFE_CAST(ano AS INT64) ano,
SAFE_CAST(mes AS INT64) mes,
SAFE_CAST(sigla_uf AS STRING) sigla_uf,
SAFE_CAST(id_municipio AS STRING) id_municipio,
SAFE_CAST(data_inicio AS DATE) data_inicio,
SAFE_CAST(cnpj AS STRING) cnpj,
SAFE_CAST(nome_agencia AS STRING) nome_agencia,
SAFE_CAST(instituicao AS STRING) instituicao,
SAFE_CAST(segmento AS STRING) segmento,
SAFE_CAST(id_compe_bcb_agencia AS STRING) id_compe_bcb_agencia,
SAFE_CAST(id_compe_bcb_instituicao AS STRING) id_compe_bcb_instituicao,
SAFE_CAST(cep AS STRING) cep,
SAFE_CAST(endereco AS STRING) endereco,
SAFE_CAST(complemento AS STRING) complemento,
SAFE_CAST(bairro AS STRING) bairro,
SAFE_CAST(ddd AS STRING) ddd,
SAFE_CAST(fone AS STRING) fone,
SAFE_CAST(id_instalacao AS STRING) id_instalacao
FROM basedosdados-staging.br_bcb_agencia_staging.agencia AS t
44 changes: 43 additions & 1 deletion models/br_bcb_agencia/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,46 @@ models:
- name: fone
description: "Fone"
- name: id_instalacao
description: "identificador de instalação da agência"
description: "identificador de instalação da agência"

- name: br_bcb_agencia__agencia_atualizado
description: "dbt model for agencia month table"
columns:
- name: ano
description: "Ano"
- name: mes
description: "Mês"
- name: sigla_uf
description: "Sigla da Unidade da Federação"
- name: id_municipio
description: "ID Município - IBGE 7 Dígitos"
- name: data_inicio
description: "Data de criação da agência"
- name: cnpj
description: "Cadastro Nacional de Pessoa Júridica (CNPJ)"
- name: nome_agencia
description: "Nome da Agência"
- name: instituicao
description: "Nome da Instituição Financeira (IF)"
- name: segmento
description: "Segemento de atuação da IF"
- name: id_compe_bcb_agencia
description: "Identificador do Sistema de Operações Monetárias e Compensações de Outros Papéis (COMPE) do Banco Central da agência"
- name: id_compe_bcb_instituicao
description: "Identificador do Sistema de Operações Monetárias e Compensações de Outros Papéis (COMPE) do Banco Central da instituição"
- name: nome_agencia
description: "Nome da Agência"
- name: cep
description: "CEP"
- name: endereco
description: "endereço da agência"
- name: complemento
description: "Complemento do endereço"
- name: bairro
description: "Bairro"
- name: ddd
description: "ddd"
- name: fone
description: "Fone"
- name: id_instalacao
description: "identificador de instalação da agência"
Loading