Skip to content

Commit

Permalink
Merge pull request #422 from dbt-labs/wrap-strings-quote-update
Browse files Browse the repository at this point in the history
  • Loading branch information
b-per authored Apr 25, 2024
2 parents defae8b + 03538f3 commit e6bbe8f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ models:
- name: on_schema_change
description: this contains the on_schema_change setting for incremental models. This column was sometimes an empty string, so should be tested to detect regressions
tests:
- is_not_empty_string
- not_null:
config:
where: resource_type = 'model'
- name: model_type
tests:
- dbt_utils.expression_is_true:
Expand Down
4 changes: 3 additions & 1 deletion integration_tests/models/staging/source_1/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ models:
description: test
columns:
- name: id
description: hocus pocus
description: >
hocus pocus
pocus hocus
tests:
- unique
- name: stg_model_3
Expand Down
11 changes: 9 additions & 2 deletions macros/wrap_string_with_quotes.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{% macro wrap_string_with_quotes(str) %}
{% if not str %}
{% if str is none %}
{{ return('cast(NULL as ' ~ dbt.type_string() ~ ')') }}
{% else %}
{{ return("'" ~ str ~ "'") }}
{{ dbt.string_literal(str) }}
{% endif %}
{% endmacro %}

{#
To be removed when https://github.com/dbt-labs/dbt-bigquery/pull/1089 is merged
#}
{% macro bigquery__string_literal(value) -%}
'''{{ value }}'''
{%- endmacro %}
2 changes: 1 addition & 1 deletion models/marts/core/int_all_graph_resources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ unioned_with_calc as (
*,
case
when resource_type = 'source' then {{ dbt.concat(['source_name',"'.'",'name']) }}
when version is not null then {{ dbt.concat(['name',"'.v'",'version']) }}
when coalesce(version, '') != '' then {{ dbt.concat(['name',"'.v'",'version']) }}
else name
end as resource_name,
case
Expand Down
4 changes: 2 additions & 2 deletions models/marts/dag/dag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ models:
tests:
- is_empty
- name: fct_duplicate_sources
descritption: "This table shows each source database location with more than one node in your dbt project."
description: "This table shows each source database location with more than one node in your dbt project."
tests:
- is_empty
- name: fct_marts_or_intermediate_dependent_on_source
Expand All @@ -24,7 +24,7 @@ models:
- name: fct_rejoining_of_upstream_concepts
description: >
"All cases where one of the parent's direct children (child) is ALSO the direct child of ANOTHER one of the
parent's direct childen (parent_and_child). Only includes cases where the model "in between" the parent and child
parent's direct children (parent_and_child). Only includes cases where the model "in between" the parent and child
has NO other downstream dependencies.
tests:
- is_empty
Expand Down
2 changes: 1 addition & 1 deletion models/marts/dag/fct_hard_coded_references.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final as (
resource_name as model,
hard_coded_references
from models
where hard_coded_references is not null
where hard_coded_references != ''
)

select * from final
Expand Down

0 comments on commit e6bbe8f

Please sign in to comment.