Skip to content

Commit 688a1ab

Browse files
Merge pull request #108 from fivetran/bug/issue-type
bug/issue-type
2 parents 7a82ab8 + 04b7f55 commit 688a1ab

8 files changed

+91
-55
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# dbt_jira v0.15.0
2+
[PR #108](https://github.com/fivetran/dbt_jira/pull/108) contains the following updates:
3+
## 🚨 Breaking Changes 🚨
4+
- Updated the `jira__daily_issue_field_history` model to make sure `issue_type` values are correctly joined into the downstream issue models. This applied only if `issue type` is leveraged within the `issue_field_history_columns` variable.
5+
>**Note**: Please be aware that a `dbt run --full-refresh` will be required after upgrading to this version in order to capture the updates.
6+
17
# dbt_jira v0.14.0
28
## 🚨 Breaking Changes 🚨
39
- Fixed the `jira__daily_issue_field_history` model to make sure `component` values are correctly joined into the downstream issue models. This applied only if `components` are leveraged within the `issue_field_history_columns` variable. ([PR #99](https://github.com/fivetran/dbt_jira/pull/99))

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Include the following jira package version in your `packages.yml` file:
5656
```yaml
5757
packages:
5858
- package: fivetran/jira
59-
version: [">=0.14.0", "<0.15.0"]
59+
version: [">=0.15.0", "<0.16.0"]
6060
6161
```
6262
## Step 3: Define database and schema variables

dbt_project.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'jira'
2-
version: '0.14.0'
2+
version: '0.15.0'
33
config-version: 2
44
require-dbt-version: [">=1.3.0", "<2.0.0"]
55
vars:

docs/catalog.json

+1-1
Large diffs are not rendered by default.

docs/manifest.json

+1-1
Large diffs are not rendered by default.

docs/run_results.json

+1-1
Large diffs are not rendered by default.

integration_tests/dbt_project.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'jira_integration_tests'
2-
version: '0.14.0'
2+
version: '0.15.0'
33
config-version: 2
44
profile: 'integration_tests'
55

models/jira__daily_issue_field_history.sql

+79-49
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ with pivoted_daily_history as (
2727
-- those values into the future.
2828

2929
), most_recent_data as (
30-
3130
select
3231
*
3332
from {{ this }}
@@ -47,6 +46,11 @@ statuses as (
4746
from {{ var('status') }}
4847
),
4948

49+
issue_types as (
50+
51+
select *
52+
from {{ var('issue_type') }}
53+
),
5054

5155
{% if var('jira_using_components', True) %}
5256
components as (
@@ -74,18 +78,25 @@ joined as (
7478
calendar.issue_id
7579

7680
{% if is_incremental() %}
77-
{% for col in pivot_data_columns if col.name|lower == 'components' and var('jira_using_components', True) %}
78-
, coalesce(pivoted_daily_history.components, most_recent_data.components) as components
79-
{% endfor %}
80-
{% for col in pivot_data_columns if col.name|lower not in ['issue_day_id', 'issue_id', 'valid_starting_on', 'components'] %}
81-
, coalesce(pivoted_daily_history.{{ col.name }}, most_recent_data.{{ col.name }}) as {{ col.name }}
81+
{% for col in pivot_data_columns %}
82+
{% if col.name|lower == 'components' and var('jira_using_components', True) %}
83+
, coalesce(pivoted_daily_history.components, most_recent_data.components) as components
84+
85+
{% elif col.name|lower not in ['issue_day_id', 'issue_id', 'valid_starting_on', 'components'] %}
86+
, coalesce(pivoted_daily_history.{{ col.name }}, most_recent_data.{{ col.name }}) as {{ col.name }}
87+
88+
{% endif %}
8289
{% endfor %}
90+
8391
{% else %}
84-
{% for col in pivot_data_columns if col.name|lower == 'components' and var('jira_using_components', True) %}
85-
, pivoted_daily_history.components
86-
{% endfor %}
87-
{% for col in pivot_data_columns if col.name|lower not in ['issue_day_id','issue_id','valid_starting_on','components'] %}
88-
, {{ col.name }}
92+
{% for col in pivot_data_columns %}
93+
{% if col.name|lower == 'components' and var('jira_using_components', True) %}
94+
, pivoted_daily_history.components
95+
96+
{% elif col.name|lower not in ['issue_day_id', 'issue_id', 'valid_starting_on', 'components'] %}
97+
, pivoted_daily_history.{{ col.name }}
98+
99+
{% endif %}
89100
{% endfor %}
90101
{% endif %}
91102

@@ -102,36 +113,50 @@ joined as (
102113
),
103114

104115
set_values as (
105-
106116
select
107117
date_day,
108118
issue_id,
109119
joined.status_id,
110120
sum( case when joined.status_id is null then 0 else 1 end) over ( partition by issue_id
111121
order by date_day rows unbounded preceding) as status_id_field_partition
112122

113-
{% for col in pivot_data_columns if col.name|lower == 'components' and var('jira_using_components', True) %}
114-
, coalesce(components.component_name, joined.components) as components
115-
, sum(case when joined.components is null then 0 else 1 end) over (partition by issue_id order by date_day rows unbounded preceding) as component_field_partition
116-
{% endfor %}
123+
-- list of exception columns
124+
{% set exception_cols = ['issue_id', 'issue_day_id', 'valid_starting_on', 'status', 'status_id', 'components', 'issue_type'] %}
117125

118-
{% for col in pivot_data_columns if col.name|lower not in ['issue_id', 'issue_day_id', 'valid_starting_on', 'status', 'status_id', 'components'] %}
119-
, coalesce(field_option_{{ col.name }}.field_option_name, {{ col.name }}) as {{ col.name }}
120-
-- create a batch/partition once a new value is provided
121-
, sum( case when {{ col.name }} is null then 0 else 1 end) over ( partition by issue_id
122-
order by date_day rows unbounded preceding) as {{ col.name }}_field_partition
126+
{% for col in pivot_data_columns %}
127+
{% if col.name|lower == 'components' and var('jira_using_components', True) %}
128+
, coalesce(components.component_name, joined.components) as components
129+
, sum(case when joined.components is null then 0 else 1 end) over (partition by issue_id order by date_day rows unbounded preceding) as component_field_partition
130+
131+
{% elif col.name|lower == 'issue_type' %}
132+
, coalesce(issue_types.issue_type_name, joined.issue_type) as issue_type
133+
, sum(case when joined.issue_type is null then 0 else 1 end) over (partition by issue_id order by date_day rows unbounded preceding) as issue_type_field_partition
134+
135+
{% elif col.name|lower not in exception_cols %}
136+
, coalesce(field_option_{{ col.name }}.field_option_name, joined.{{ col.name }}) as {{ col.name }}
137+
-- create a batch/partition once a new value is provided
138+
, sum( case when joined.{{ col.name }} is null then 0 else 1 end) over ( partition by issue_id
139+
order by date_day rows unbounded preceding) as {{ col.name }}_field_partition
140+
141+
{% endif %}
123142
{% endfor %}
124143

125144
from joined
126145

127-
{% for col in pivot_data_columns if col.name|lower == 'components' and var('jira_using_components', True) %}
128-
left join components
129-
on cast(components.component_id as {{ dbt.type_string() }}) = joined.components
130-
{% endfor %}
146+
{% for col in pivot_data_columns %}
147+
{% if col.name|lower == 'components' and var('jira_using_components', True) %}
148+
left join components
149+
on cast(components.component_id as {{ dbt.type_string() }}) = joined.components
150+
151+
{% elif col.name|lower == 'issue_type' %}
152+
left join issue_types
153+
on cast(issue_types.issue_type_id as {{ dbt.type_string() }}) = joined.issue_type
154+
155+
{% elif col.name|lower not in exception_cols %}
156+
left join field_option as field_option_{{ col.name }}
157+
on cast(field_option_{{ col.name }}.field_id as {{ dbt.type_string() }}) = joined.{{ col.name }}
131158

132-
{% for col in pivot_data_columns if col.name|lower not in ['issue_id', 'issue_day_id', 'valid_starting_on', 'status', 'status_id', 'components'] %}
133-
left join field_option as field_option_{{ col.name }}
134-
on cast(field_option_{{ col.name }}.field_id as {{ dbt.type_string() }}) = {{ col.name }}
159+
{% endif %}
135160
{% endfor %}
136161
),
137162

@@ -144,15 +169,19 @@ fill_values as (
144169
partition by issue_id, status_id_field_partition
145170
order by date_day asc rows between unbounded preceding and current row) as status_id
146171

147-
{% for col in pivot_data_columns if col.name|lower == 'components' and var('jira_using_components', True) %}
148-
, first_value(components) over (partition by issue_id, component_field_partition order by date_day asc rows between unbounded preceding and current row) as components
149-
{% endfor %}
172+
{% for col in pivot_data_columns %}
173+
{% if col.name|lower == 'components' and var('jira_using_components', True) %}
174+
, first_value(components) over (
175+
partition by issue_id, component_field_partition
176+
order by date_day asc rows between unbounded preceding and current row) as components
150177

151-
{% for col in pivot_data_columns if col.name|lower not in ['issue_id', 'issue_day_id', 'valid_starting_on', 'status', 'status_id', 'components'] %}
152-
-- grab the value that started this batch/partition
153-
, first_value( {{ col.name }} ) over (
154-
partition by issue_id, {{ col.name }}_field_partition
155-
order by date_day asc rows between unbounded preceding and current row) as {{ col.name }}
178+
{% elif col.name|lower not in ['issue_id', 'issue_day_id', 'valid_starting_on', 'status', 'status_id', 'components'] %}
179+
-- grab the value that started this batch/partition
180+
, first_value( {{ col.name }} ) over (
181+
partition by issue_id, {{ col.name }}_field_partition
182+
order by date_day asc rows between unbounded preceding and current row) as {{ col.name }}
183+
184+
{% endif %}
156185
{% endfor %}
157186

158187
from set_values
@@ -164,18 +193,17 @@ fix_null_values as (
164193
date_day,
165194
issue_id
166195

167-
{% for col in pivot_data_columns if col.name|lower == 'components' and var('jira_using_components', True) %}
168-
, case when components = 'is_null' then null else components end as components
169-
{% endfor %}
196+
{% for col in pivot_data_columns %}
197+
{% if col.name|lower == 'components' and var('jira_using_components', True) %}
198+
, case when components = 'is_null' then null else components end as components
170199

171-
{% for col in pivot_data_columns if col.name|lower not in ['issue_id','issue_day_id','valid_starting_on', 'status', 'components'] %}
200+
{% elif col.name|lower not in ['issue_id','issue_day_id','valid_starting_on', 'status', 'components'] %}
201+
-- we de-nulled the true null values earlier in order to differentiate them from nulls that just needed to be backfilled
202+
, case when {{ col.name }} = 'is_null' then null else {{ col.name }} end as {{ col.name }}
172203

173-
-- we de-nulled the true null values earlier in order to differentiate them from nulls that just needed to be backfilled
174-
, case when {{ col.name }} = 'is_null' then null else {{ col.name }} end as {{ col.name }}
204+
{% endif %}
175205
{% endfor %}
176206

177-
178-
179207
from fill_values
180208

181209
),
@@ -187,12 +215,14 @@ surrogate_key as (
187215
fix_null_values.issue_id,
188216
statuses.status_name as status
189217

190-
{% for col in pivot_data_columns if col.name|lower == 'components' and var('jira_using_components', True) %}
191-
, case when components = 'is_null' then null else components end as components
192-
{% endfor %}
218+
{% for col in pivot_data_columns %}
219+
{% if col.name|lower == 'components' and var('jira_using_components', True) %}
220+
, fix_null_values.components as components
221+
222+
{% elif col.name|lower not in ['issue_id','issue_day_id','valid_starting_on', 'status', 'components'] %}
223+
, fix_null_values.{{ col.name }} as {{ col.name }}
193224

194-
{% for col in pivot_data_columns if col.name|lower not in ['issue_id','issue_day_id','valid_starting_on', 'status', 'components'] %}
195-
, fix_null_values.{{ col.name }} as {{ col.name }}
225+
{% endif %}
196226
{% endfor %}
197227

198228
, {{ dbt_utils.generate_surrogate_key(['date_day','issue_id']) }} as issue_day_id

0 commit comments

Comments
 (0)