Skip to content

Commit e9af7b2

Browse files
Merge pull request #37 from fivetran/fix/field-history-partition
Partition by fix within field history models
2 parents ba16b3b + 7e35a8b commit e9af7b2

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Check [dbt Hub](https://hub.getdbt.com/) for the latest installation instruction
2929
# packages.yml
3030
packages:
3131
- package: fivetran/jira
32-
version: [">=0.4.0", "<0.5.0"]
32+
version: [">=0.5.0", "<0.6.0"]
3333
```
3434
3535
## Configuration

dbt_project.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'jira'
2-
version: '0.4.0'
2+
version: '0.5.0'
33
config-version: 2
44
require-dbt-version: ">=0.20.0"
55

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.4.0'
2+
version: '0.5.0'
33
config-version: 2
44
profile: 'integration_tests'
55

models/intermediate/field_history/int_jira__field_history_scd.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ with change_data as (
1717
{% for col in issue_columns if col.name|lower not in ['valid_starting_on','issue_id','issue_day_id'] %}
1818
, {{ col.name }}
1919
-- create a batch/partition once a new value is provided
20-
, sum( case when {{ col.name }} is null then 0 else 1 end) over (
21-
order by issue_id, valid_starting_on rows unbounded preceding) as {{ col.name }}_field_partition
20+
, sum( case when {{ col.name }} is null then 0 else 1 end) over ( partition by issue_id
21+
order by valid_starting_on rows unbounded preceding) as {{ col.name }}_field_partition
2222

2323
{% endfor %}
2424

@@ -37,7 +37,7 @@ with change_data as (
3737

3838
-- grab the value that started this batch/partition
3939
, first_value( {{ col.name }} ) over (
40-
partition by {{ col.name }}_field_partition
40+
partition by issue_id, {{ col.name }}_field_partition
4141
order by valid_starting_on asc rows between unbounded preceding and current row) as {{ col.name }}
4242

4343
{% endfor %}

models/jira__daily_issue_field_history.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ set_values as (
8585
{% for col in pivot_data_columns if col.name|lower not in ['issue_id','issue_day_id','valid_starting_on'] %}
8686
, {{ col.name }}
8787
-- create a batch/partition once a new value is provided
88-
, sum( case when {{ col.name }} is null then 0 else 1 end) over (
89-
order by issue_id, date_day rows unbounded preceding) as {{ col.name }}_field_partition
88+
, sum( case when {{ col.name }} is null then 0 else 1 end) over ( partition by issue_id
89+
order by date_day rows unbounded preceding) as {{ col.name }}_field_partition
9090

9191
{% endfor %}
9292

@@ -102,7 +102,7 @@ fill_values as (
102102
{% for col in pivot_data_columns if col.name|lower not in ['issue_id','issue_day_id','valid_starting_on'] %}
103103
-- grab the value that started this batch/partition
104104
, first_value( {{ col.name }} ) over (
105-
partition by {{ col.name }}_field_partition
105+
partition by issue_id, {{ col.name }}_field_partition
106106
order by date_day asc rows between unbounded preceding and current row) as {{ col.name }}
107107
{% endfor %}
108108

0 commit comments

Comments
 (0)