Hotfix/Points Transfers Model FR Override (#435)

* upd gitignore

* add fallback to FR table if bad data
This commit is contained in:
Jack Forgash 2025-04-22 11:02:33 -06:00 committed by GitHub
parent dbe0cd465d
commit 2e7d617fe7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 10 deletions

5
.gitignore vendored
View File

@ -19,4 +19,7 @@ logs/
.env
.github/workflows/.dbt/.user.yml
local*
local*
venv/
.cursor/
.cursorrules

View File

@ -14,15 +14,36 @@
MAX(partition_key)
FROM
{{ ref('bronze_api__points_transfers') }}
WHERE
TYPEOF(data) != 'NULL_VALUE'
{% endset %}
{% set max_partition_key = run_query(query) [0] [0] %}
{% set must_fr = False %}
{% do log(
"max_partition_key: " ~ max_partition_key,
info = True
) %}
{% if max_partition_key == '' or max_partition_key is none %}
{% do exceptions.raise_compiler_error("max_partition_key is not set. Aborting model execution.") %}
{% do log("No recent data found. Using FR table.", info = True) %}
{% set query %}
SELECT
MAX(partition_key)
FROM
{{ ref('bronze_api__FR_points_transfers') }}
WHERE
TYPEOF(data) != 'NULL_VALUE'
{% endset%}
{% set max_partition_key = run_query(query) [0] [0] %}
{% set must_fr = True %}
{% do log(
"max_partition_key: " ~ max_partition_key,
info = True
) %}
{# {% do exceptions.raise_compiler_error("max_partition_key is not set. Aborting model execution.") %} #}
{% endif %}
{% endif %}
@ -44,6 +65,10 @@ SELECT
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
{{ ref('bronze_api__points_transfers') }}
{% if must_fr %}
{{ ref('bronze_api__FR_points_transfers') }}
{% else %}
{{ ref('bronze_api__points_transfers') }}
{% endif %}
WHERE
partition_key = {{ max_partition_key }}

View File

@ -25,13 +25,6 @@ models:
tests:
- not_null
- name: data_mb
tests:
- dbt_utils.accepted_range:
min_value: 0
max_value: 15.5
severity: error
- name: points_transfers_id
tests:
- not_null