-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug : handle cleaning null values
- pre hook calls a macro to NULL from dummy dates. - added a CI profile with env var for future GHA runs
- Loading branch information
1 parent
d253a15
commit 61cf8dd
Showing
6 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{# had to hardcode the pre hook cause otherwise the old dummy lookahead dates gonn persist & build up #} | ||
|
||
{% macro cleanup_nulls(column_name) %} | ||
{% if execute %} | ||
-- Check if the table exists | ||
{% set table_exists_query %} | ||
SELECT COUNT(*) | ||
FROM information_schema.tables | ||
WHERE table_schema = '{{ this.schema }}' | ||
AND table_name = '{{ this.table }}' | ||
{% endset %} | ||
|
||
{% set table_exists_results = run_query(table_exists_query) %} | ||
{% set table_exists = table_exists_results.rows[0][0] > 0 %} | ||
|
||
-- Run the DELETE only if the table exists | ||
{% if table_exists %} | ||
DELETE FROM {{ this }} | ||
WHERE {{ column_name }} IS NULL; | ||
{% else %} | ||
{{ log("Skipping DELETE because the table does not exist.", info=True) }} | ||
select 1 | ||
{% endif %} | ||
{% else %} | ||
-- Dry-run mode: Log the SQL | ||
{{ log("DELETE FROM " ~ this ~ " WHERE " ~ column_name ~ " IS NULL;", info=True) }} | ||
{% endif %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters