Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent compile error in optional function (DNA-18883: DNA-18917) #59

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'pm_utils'
version: '0.14.4'
version: '0.14.5'
config-version: 2

require-dbt-version: [">=1.0.0", "<2.0.0"]
7 changes: 4 additions & 3 deletions macros/generic/optional.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
{%- set columns = adapter.get_columns_in_relation(relation) -%}
{%- endif -%}

{# Check if relation is a source based on whether the relation's schema and identifier is defined as source. #}
{# Check if relation is a source based on whether the relation's schema and identifier is defined as source.
Only check when relation exists to prevent dbt compile errors. #}
{%- set ns = namespace(is_source_relation = false) -%}

{% if execute %}
{% if execute and relation != null %}
{% for node in graph.sources.values() -%}
{% if node.schema == relation.schema and node.identifier == relation.identifier %}
{% set ns.is_source_relation = true %}
Expand All @@ -32,7 +33,7 @@
{% set column_value = 'null' -%}
{%- endif -%}

{# Apply casting when relation is a source or when the field doesn't exist in the relation and is being created. #}
{# Apply casting when relation is a source or when the field doesn't exist and is being created. #}
{% if ns.is_source_relation or column_value == 'null' %}
{%- if data_type == 'boolean' -%}
{{ pm_utils.to_boolean(column_value, relation) }}
Expand Down