diff --git a/models/br_ms_cnes/br_ms_cnes__dados_complementares.sql b/models/br_ms_cnes/br_ms_cnes__dados_complementares.sql index fe515868..ef4d4f54 100644 --- a/models/br_ms_cnes/br_ms_cnes__dados_complementares.sql +++ b/models/br_ms_cnes/br_ms_cnes__dados_complementares.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with diff --git a/models/br_ms_cnes/br_ms_cnes__equipamento.sql b/models/br_ms_cnes/br_ms_cnes__equipamento.sql index 6c0ccf88..b7bdaa73 100644 --- a/models/br_ms_cnes/br_ms_cnes__equipamento.sql +++ b/models/br_ms_cnes/br_ms_cnes__equipamento.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} diff --git a/models/br_ms_cnes/br_ms_cnes__equipe.sql b/models/br_ms_cnes/br_ms_cnes__equipe.sql index bcb743bf..0a9a114d 100644 --- a/models/br_ms_cnes/br_ms_cnes__equipe.sql +++ b/models/br_ms_cnes/br_ms_cnes__equipe.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} diff --git a/models/br_ms_cnes/br_ms_cnes__estabelecimento.sql b/models/br_ms_cnes/br_ms_cnes__estabelecimento.sql index 761eac6e..87066e6e 100644 --- a/models/br_ms_cnes/br_ms_cnes__estabelecimento.sql +++ b/models/br_ms_cnes/br_ms_cnes__estabelecimento.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with diff --git a/models/br_ms_cnes/br_ms_cnes__estabelecimento_ensino.sql b/models/br_ms_cnes/br_ms_cnes__estabelecimento_ensino.sql index 2f4b3dc4..df5900ec 100644 --- a/models/br_ms_cnes/br_ms_cnes__estabelecimento_ensino.sql +++ b/models/br_ms_cnes/br_ms_cnes__estabelecimento_ensino.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with diff --git a/models/br_ms_cnes/br_ms_cnes__estabelecimento_filantropico.sql b/models/br_ms_cnes/br_ms_cnes__estabelecimento_filantropico.sql index de2afec7..ef7dfbd8 100644 --- a/models/br_ms_cnes/br_ms_cnes__estabelecimento_filantropico.sql +++ b/models/br_ms_cnes/br_ms_cnes__estabelecimento_filantropico.sql @@ -8,7 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, - ) + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], }} with raw_cnes_estabelecimento_filantropico as ( diff --git a/models/br_ms_cnes/br_ms_cnes__gestao_metas.sql b/models/br_ms_cnes/br_ms_cnes__gestao_metas.sql index da4ebe60..14909c95 100644 --- a/models/br_ms_cnes/br_ms_cnes__gestao_metas.sql +++ b/models/br_ms_cnes/br_ms_cnes__gestao_metas.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with diff --git a/models/br_ms_cnes/br_ms_cnes__habilitacao.sql b/models/br_ms_cnes/br_ms_cnes__habilitacao.sql index 8ae30eb4..ded43aef 100644 --- a/models/br_ms_cnes/br_ms_cnes__habilitacao.sql +++ b/models/br_ms_cnes/br_ms_cnes__habilitacao.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with diff --git a/models/br_ms_cnes/br_ms_cnes__incentivos.sql b/models/br_ms_cnes/br_ms_cnes__incentivos.sql index 5ef1e14d..2742aaa8 100644 --- a/models/br_ms_cnes/br_ms_cnes__incentivos.sql +++ b/models/br_ms_cnes/br_ms_cnes__incentivos.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with diff --git a/models/br_ms_cnes/br_ms_cnes__leito.sql b/models/br_ms_cnes/br_ms_cnes__leito.sql index 87677429..eda01dbd 100644 --- a/models/br_ms_cnes/br_ms_cnes__leito.sql +++ b/models/br_ms_cnes/br_ms_cnes__leito.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2007, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} diff --git a/models/br_ms_cnes/br_ms_cnes__profissional.sql b/models/br_ms_cnes/br_ms_cnes__profissional.sql index ddb3fcd9..ee4289c2 100644 --- a/models/br_ms_cnes/br_ms_cnes__profissional.sql +++ b/models/br_ms_cnes/br_ms_cnes__profissional.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with diff --git a/models/br_ms_cnes/br_ms_cnes__regra_contratual.sql b/models/br_ms_cnes/br_ms_cnes__regra_contratual.sql index e96282f7..026ffc5e 100644 --- a/models/br_ms_cnes/br_ms_cnes__regra_contratual.sql +++ b/models/br_ms_cnes/br_ms_cnes__regra_contratual.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with diff --git a/models/br_ms_cnes/br_ms_cnes__servico_especializado.sql b/models/br_ms_cnes/br_ms_cnes__servico_especializado.sql index 0aaecd4a..7001f75b 100644 --- a/models/br_ms_cnes/br_ms_cnes__servico_especializado.sql +++ b/models/br_ms_cnes/br_ms_cnes__servico_especializado.sql @@ -8,6 +8,11 @@ "data_type": "int64", "range": {"start": 2005, "end": 2024, "interval": 1}, }, + 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(CAST(ano AS INT64),CAST(mes AS INT64),1), 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(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) <= 6)', + ], ) }} with