From 16d4765ae3c0780828a1ad6e6c03000b1f8a6048 Mon Sep 17 00:00:00 2001 From: Laura Amaral Date: Tue, 2 Jan 2024 16:05:51 -0300 Subject: [PATCH 1/4] fix: remove incremental --- ...r_cvm_oferta_publica_distribuicao__dia.sql | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql b/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql index 90fedc02..7d3956bc 100644 --- a/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql +++ b/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql @@ -2,22 +2,11 @@ config( alias = 'dia', schema='br_cvm_oferta_publica_distribuicao', - materialized='incremental', partition_by = { "field": "data_abertura_processo", "data_type": "date", "granularity": "day" }, - 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(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(data_abertura_processo), MONTH) > 6)', - 'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter - ON {{this}} - GRANT TO ("group:bd-pro@basedosdados.org", "group:sudo@basedosdados.org") - FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(data_abertura_processo), MONTH) <= 6)'] - ) }} WITH tabela as(SELECT @@ -65,13 +54,4 @@ SAFE_CAST(tipo_societario_emissor AS STRING) tipo_societario_emissor, SAFE_CAST(tipo_fundo_investimento AS STRING) tipo_fundo_investimento, SAFE_CAST(ultimo_comunicado AS STRING) ultimo_comunicado, SAFE_CAST(data_comunicado AS DATE) data_comunicado -FROM basedosdados-staging.br_cvm_oferta_publica_distribuicao_staging.dia AS t) -SELECT * -FROM tabela -{% if is_incremental() %} - - -- this filter will only be applied on an incremental run - -- (uses > to include records whose timestamp occurred since the last run of this model) - where data_abertura_processo > (select max(data_abertura_processo) from {{ this }}) - -{% endif %} \ No newline at end of file +FROM basedosdados-staging.br_cvm_oferta_publica_distribuicao_staging.dia AS t \ No newline at end of file From 3e3366296b68e6767537e47bd786af505ae04fe0 Mon Sep 17 00:00:00 2001 From: Laura Amaral Date: Tue, 2 Jan 2024 16:07:23 -0300 Subject: [PATCH 2/4] fix: remove 'with' from query --- .../br_cvm_oferta_publica_distribuicao__dia.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql b/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql index 7d3956bc..5fcaba4c 100644 --- a/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql +++ b/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql @@ -9,7 +9,7 @@ }, }} -WITH tabela as(SELECT +SELECT SAFE_CAST(numero_processo AS STRING) numero_processo, SAFE_CAST(numero_registro_oferta AS STRING) numero_registro_oferta, SAFE_CAST(tipo_oferta AS STRING) tipo_oferta, From ebba045eafd67e7844138dc963bbf58d24d9bb47 Mon Sep 17 00:00:00 2001 From: Laura Amaral Date: Tue, 2 Jan 2024 16:18:41 -0300 Subject: [PATCH 3/4] fix: small fix --- .../br_cvm_oferta_publica_distribuicao__dia.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql b/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql index 5fcaba4c..a1052164 100644 --- a/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql +++ b/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql @@ -6,7 +6,7 @@ "field": "data_abertura_processo", "data_type": "date", "granularity": "day" - }, + }) }} SELECT From c329d68c7b5118dc5dde8f5f79608a114db56409 Mon Sep 17 00:00:00 2001 From: Laura Amaral Date: Tue, 2 Jan 2024 16:26:31 -0300 Subject: [PATCH 4/4] fix: remove partition --- .../br_cvm_oferta_publica_distribuicao__dia.sql | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql b/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql index a1052164..204ecfa7 100644 --- a/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql +++ b/models/br_cvm_oferta_publica_distribuicao/br_cvm_oferta_publica_distribuicao__dia.sql @@ -1,12 +1,7 @@ {{ config( alias = 'dia', - schema='br_cvm_oferta_publica_distribuicao', - partition_by = { - "field": "data_abertura_processo", - "data_type": "date", - "granularity": "day" - }) + schema='br_cvm_oferta_publica_distribuicao') }} SELECT