Skip to content

Commit

Permalink
feat: br_innmet_bdmep model v2
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfg committed Sep 29, 2023
1 parent 7a5987d commit 635f220
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion models/br_inmet_bdmep/br_inmet_bdmep__microdados.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
{{ config(alias='microdados', schema='br_inmet_bdmep') }}
{{ config(alias='microdados', schema='br_inmet_bdmep',
materialized='table',
partition_by={
"field": "ano",
"data_type": "int64",
"range": {
"start": 2000,
"end": 2023,
"interval": 1}
},
cluster_by = ["id_estacao"],
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(extract(MONTH FROM data) as INT64),1), MONTH) > 6)',
'CREATE OR REPLACE ROW ACCESS POLICY bdpro_filter
ON {{this}}
GRANT TO ("group:[email protected]", "group:[email protected]")
FILTER USING (DATE_DIFF(DATE("{{ run_started_at.strftime("%Y-%m-%d") }}"),DATE(CAST(ano AS INT64),cast(extract(MONTH FROM data) as INT64),1), MONTH) <= 6)'] ) }}
SELECT
SAFE_CAST(ano AS INT64) ano,
SAFE_CAST(extract(MONTH FROM SAFE_CAST(data AS DATE)) as INT64) mes,
SAFE_CAST(data AS DATE) data,
SAFE_CAST(hora AS TIME) hora,
SAFE_CAST(id_estacao AS STRING) id_estacao,
Expand Down

0 comments on commit 635f220

Please sign in to comment.