Skip to content

Commit

Permalink
chore: change some tables from incremental to table
Browse files Browse the repository at this point in the history
  • Loading branch information
d116626 committed Jan 12, 2024
1 parent 2f70a56 commit 3ef6d70
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
18 changes: 8 additions & 10 deletions queries/models/recursos_humanos_ergon/ficha_financeira.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{{
config(
alias='ficha_financeira',
schema='recursos_humanos_ergon',
materialized='incremental',
materialized='table',
partition_by={
"field": "data_particao",
"data_type": "date",
Expand All @@ -27,14 +25,14 @@ SELECT
SAFE_CAST(REGEXP_REPLACE(TRIM(emp_codigo), r'\.0$', '') AS STRING) AS emp_codigo,
SAFE_CAST(data_particao AS DATE) data_particao,
FROM rj-smfp.recursos_humanos_ergon_staging.ficha_financeira AS t
WHERE
SAFE_CAST(data_particao AS DATE) < CURRENT_DATE('America/Sao_Paulo')
-- WHERE
-- SAFE_CAST(data_particao AS DATE) < CURRENT_DATE('America/Sao_Paulo')

{% if is_incremental() %}
-- {% if is_incremental() %}

{% set max_partition = run_query("SELECT gr FROM (SELECT IF(max(data_particao) > CURRENT_DATE('America/Sao_Paulo'), CURRENT_DATE('America/Sao_Paulo'), max(data_particao)) as gr FROM " ~ this ~ ")").columns[0].values()[0] %}
-- {% set max_partition = run_query("SELECT gr FROM (SELECT IF(max(data_particao) > CURRENT_DATE('America/Sao_Paulo'), CURRENT_DATE('America/Sao_Paulo'), max(data_particao)) as gr FROM " ~ this ~ ")").columns[0].values()[0] %}

AND
SAFE_CAST(data_particao AS DATE) > ("{{ max_partition }}")
-- AND
-- SAFE_CAST(data_particao AS DATE) > ("{{ max_partition }}")

{% endif %}
-- {% endif %}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{
config(
materialized='incremental',
materialized='table',
partition_by={
"field": "data_particao",
"data_type": "date",
Expand Down Expand Up @@ -30,14 +30,14 @@ SELECT
SAFE_CAST(REGEXP_REPLACE(TRIM(emp_codigo), r'.0$', '') AS STRING) AS emp_codigo,
SAFE_CAST(data_particao AS DATE) data_particao,
FROM rj-smfp.recursos_humanos_ergon_staging.ficha_financeira_contabil AS t
WHERE
SAFE_CAST(data_particao AS DATE) < CURRENT_DATE('America/Sao_Paulo')
-- WHERE
-- SAFE_CAST(data_particao AS DATE) < CURRENT_DATE('America/Sao_Paulo')

{% if is_incremental() %}
-- {% if is_incremental() %}

{% set max_partition = run_query("SELECT gr FROM (SELECT IF(max(data_particao) > CURRENT_DATE('America/Sao_Paulo'), CURRENT_DATE('America/Sao_Paulo'), max(data_particao)) as gr FROM " ~ this ~ ")").columns[0].values()[0] %}
-- {% set max_partition = run_query("SELECT gr FROM (SELECT IF(max(data_particao) > CURRENT_DATE('America/Sao_Paulo'), CURRENT_DATE('America/Sao_Paulo'), max(data_particao)) as gr FROM " ~ this ~ ")").columns[0].values()[0] %}

AND
SAFE_CAST(data_particao AS DATE) > ("{{ max_partition }}")
-- AND
-- SAFE_CAST(data_particao AS DATE) > ("{{ max_partition }}")

{% endif %}
-- {% endif %}
20 changes: 9 additions & 11 deletions queries/models/recursos_humanos_ergon/fita_banco.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{{
config(
alias='fita_banco',
schema='recursos_humanos_ergon',
materialized='incremental',
materialized='table',
partition_by={
"field": "data_particao",
"data_type": "date",
Expand Down Expand Up @@ -44,15 +42,15 @@ SELECT
SAFE_CAST(REGEXP_REPLACE(flex_campo_05, r'\.0$', '') AS STRING) AS flex_campo_05,
SAFE_CAST(REGEXP_REPLACE(jornada, r'\.0$', '') AS STRING) AS jornada,
SAFE_CAST(data_particao AS DATE) data_particao,
FROM rj-smfp.recursos_humanos_ergon_staging.fita_banco AS t
WHERE
SAFE_CAST(data_particao AS DATE) < CURRENT_DATE('America/Sao_Paulo')
FROM rj-smfp.recursos_humanos_ergon_staging.fita_banco AS t
-- WHERE
-- SAFE_CAST(data_particao AS DATE) < CURRENT_DATE('America/Sao_Paulo')

{% if is_incremental() %}
-- {% if is_incremental() %}

{% set max_partition = run_query("SELECT gr FROM (SELECT IF(max(data_particao) > CURRENT_DATE('America/Sao_Paulo'), CURRENT_DATE('America/Sao_Paulo'), max(data_particao)) as gr FROM " ~ this ~ ")").columns[0].values()[0] %}
-- {% set max_partition = run_query("SELECT gr FROM (SELECT IF(max(data_particao) > CURRENT_DATE('America/Sao_Paulo'), CURRENT_DATE('America/Sao_Paulo'), max(data_particao)) as gr FROM " ~ this ~ ")").columns[0].values()[0] %}

AND
SAFE_CAST(data_particao AS DATE) > ("{{ max_partition }}")
-- AND
-- SAFE_CAST(data_particao AS DATE) > ("{{ max_partition }}")

{% endif %}
-- {% endif %}

0 comments on commit 3ef6d70

Please sign in to comment.