Skip to content

Commit

Permalink
Feat/add tags to exposures (#301)
Browse files Browse the repository at this point in the history
* Add tags to exposures

* Add tags to exposures (staging and mart)

* Add exposure tags
  • Loading branch information
glsdown committed May 12, 2023
1 parent 919d4cd commit 3bcd824
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions integration_test_project/models/tests_and_exposures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exposures:
maturity: high
description: "ceo's favourite dashboard"
url: https://bi.tool/dashboards/1
tags: ["ceo", "data"]

depends_on:
- ref('non_incremental')
Expand All @@ -28,6 +29,7 @@ exposures:
maturity: high
description: '{{ doc("clickstream") }}'
url: https://bi.tool/dashboards/1
tags: ["cio", "it"]

depends_on:
- ref('incremental')
Expand Down
10 changes: 7 additions & 3 deletions macros/upload_exposures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }},
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }},
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }},
{{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }}
{{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }},
{{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(13)) }}
from values
{% for exposure in exposures -%}
(
Expand All @@ -37,7 +38,8 @@
'{{ exposure.description | replace("'","\\'") }}', {# description #}
'{{ exposure.url }}', {# url #}
'{{ exposure.package_name }}', {# package_name #}
'{{ tojson(exposure.depends_on.nodes) }}' {# depends_on_nodes #}
'{{ tojson(exposure.depends_on.nodes) }}', {# depends_on_nodes #}
'{{ tojson(exposure.tags) }}' {# tags #}
)
{%- if not loop.last %},{%- endif %}
{%- endfor %}
Expand All @@ -64,7 +66,9 @@
"""{{ exposure.description | replace("'","\\'") }}""", {# description #}
'{{ exposure.url }}', {# url #}
'{{ exposure.package_name }}', {# package_name #}
{{ tojson(exposure.depends_on.nodes) }} {# depends_on_nodes #}
{{ tojson(exposure.depends_on.nodes) }}, {# depends_on_nodes #}
{{ tojson(exposure.tags) }} {# tags #}

)
{%- if not loop.last %},{%- endif %}
{%- endfor %}
Expand Down
3 changes: 2 additions & 1 deletion models/dim_dbt__exposures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ exposures as (
description,
url,
package_name,
depends_on_nodes
depends_on_nodes,
tags
from base

)
Expand Down
2 changes: 2 additions & 0 deletions models/dim_dbt__exposures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ models:
description: '{{ doc("type") }}'
- name: url
description: '{{ doc("url") }}'
- name: tags
description: '{{ doc("tags") }}'
3 changes: 2 additions & 1 deletion models/sources/exposures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ select
cast(null as {{ type_string() }}) as description,
cast(null as {{ type_string() }}) as url,
cast(null as {{ type_string() }}) as package_name,
cast(null as {{ type_array() }}) as depends_on_nodes
cast(null as {{ type_array() }}) as depends_on_nodes,
cast(null as {{ type_array() }}) as tags
from dummy_cte
where 1 = 0
3 changes: 2 additions & 1 deletion models/staging/stg_dbt__exposures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ enhanced as (
description,
url,
package_name,
depends_on_nodes
depends_on_nodes,
tags
from base

)
Expand Down
2 changes: 2 additions & 0 deletions models/staging/stg_dbt__exposures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ models:
description: '{{ doc("type") }}'
- name: url
description: '{{ doc("url") }}'
- name: tags
description: '{{ doc("tags") }}'

0 comments on commit 3bcd824

Please sign in to comment.