Skip to content

Commit

Permalink
add quotes to field if numeric in safe_cast macro
Browse files Browse the repository at this point in the history
  • Loading branch information
graciegoheen committed Jan 29, 2024
1 parent 4b2d938 commit 8f8d876
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dbt/include/snowflake/macros/utils/safe_cast.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% macro snowflake__safe_cast(field, type) %}
try_cast({{field}} as {{type}})
{% endmacro %}
{% set field_as_string = "'" ~ field ~ "'" if field is number else field%}
try_cast({{field_as_string}} as {{type}})
{% endmacro %}

0 comments on commit 8f8d876

Please sign in to comment.