Skip to content

Commit

Permalink
add negative part number test case for split part cross db util (#7200)
Browse files Browse the repository at this point in the history
* add negative test case

* changie

* missed a comma

* Update changelog entry

* Add a negative number (rather than subtract a positive number)

---------

Co-authored-by: Doug Beatty <[email protected]>
Co-authored-by: Doug Beatty <[email protected]>
  • Loading branch information
3 people authored Jul 11, 2023
1 parent a8e3afe commit a57fdf0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230320-153225.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: add negative part_number arg for split part macro
time: 2023-03-20T15:32:25.5932-05:00
custom:
Author: dave-connors-3
Issue: "7915"
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
length({{ string_text }})
- length(
replace({{ string_text }}, {{ delimiter_text }}, '')
) + 2 {{ part_number }}
) + 2 + {{ part_number }}
)

{% endmacro %}
16 changes: 12 additions & 4 deletions tests/adapter/dbt/tests/adapter/utils/fixture_split_part.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# split_part

seeds__data_split_part_csv = """parts,split_on,result_1,result_2,result_3
a|b|c,|,a,b,c
1|2|3,|,1,2,3
,|,,,
seeds__data_split_part_csv = """parts,split_on,result_1,result_2,result_3,result_4
a|b|c,|,a,b,c,c
1|2|3,|,1,2,3,3
,|,,,,
"""


Expand Down Expand Up @@ -34,6 +34,14 @@
{{ split_part('parts', 'split_on', 3) }} as actual,
result_3 as expected
from data
union all
select
{{ split_part('parts', 'split_on', -1) }} as actual,
result_4 as expected
from data
"""

Expand Down

0 comments on commit a57fdf0

Please sign in to comment.