Skip to content

Commit

Permalink
feat: add trim/ltrim/rtrim with single input argument to remove spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
scgkiran committed Dec 9, 2024
1 parent af82db5 commit b0a9a43
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion tests/cases/string/ltrim.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ltrim('aaaaabc'::str, 'a'::str) [spaces_only:FALSE] = 'bc'::str
ltrim('abcabcdef'::str, 'abc'::str) [spaces_only:FALSE] = 'def'::str
ltrim('abccbadef'::str, 'abc'::str) [spaces_only:FALSE] = 'def'::str

# ltrim with varchar
# varchar
ltrim('abc'::vchar<20>, ' '::vchar<5>) = 'abc'::vchar<20>
ltrim(' abc'::vchar<20>, ' '::vchar<5>) = 'abc'::vchar<20>
ltrim('abc '::vchar<20>, ' '::vchar<5>) = 'abc '::vchar<20>
Expand All @@ -35,3 +35,7 @@ ltrim('abc '::vchar<20>) = 'abc '::vchar<20>
ltrim(' abc '::vchar<20>) = 'abc '::vchar<20>
ltrim('aaaaabc'::vchar<20>, 'a'::vchar<9>) [spaces_only:False] = 'bc'::vchar<20>
ltrim('abcabcdef'::vchar<20>, 'abc'::vchar<9>) [spaces_only:False] = 'def'::vchar<20>
ltrim(' \t\tHello World'::vchar<30>) = '\t\tHello World'::vchar<30>
ltrim(' \n\nHello World'::vchar<30>) = '\n\nHello World'::vchar<30>
ltrim(' \r\rHello World'::vchar<30>) = '\r\rHello World'::vchar<30>
ltrim(' \u2003Hello World'::vchar<30>) = '\u2003Hello World'::vchar<30>
6 changes: 5 additions & 1 deletion tests/cases/string/rtrim.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rtrim('aaaaabccccc'::str, 'c'::str) [spaces_only:FALSE] = 'aaaaab'::str
rtrim('abcabcdef'::str, 'def'::str) [spaces_only:FALSE] = 'abcabc'::str
rtrim('defabccba'::str, 'abc'::str) [spaces_only:FALSE] = 'def'::str

# rtrim with varchar
# varchar
rtrim('abc'::vchar<20>, ' '::vchar<5>) = 'abc'::vchar<20>
rtrim(' abc'::vchar<20>, ' '::vchar<5>) = ' abc'::vchar<20>
rtrim('abc '::vchar<20>, ' '::vchar<5>) = 'abc'::vchar<20>
Expand All @@ -35,3 +35,7 @@ rtrim('abc '::vchar<20>) = 'abc'::vchar<20>
rtrim(' abc '::vchar<20>) = ' abc'::vchar<20>
rtrim('aaaaabccccc'::vchar<20>, 'c'::vchar<9>) [spaces_only:False] = 'aaaaab'::vchar<20>
rtrim('abcabcdef'::vchar<20>, 'def'::vchar<9>) [spaces_only:False] = 'abcabc'::vchar<20>
rtrim('Hello World\t\t '::vchar<30>) = 'Hello World\t\t'::vchar<30>
rtrim('Hello World\n\n '::vchar<30>) = 'Hello World\n\n'::vchar<30>
rtrim('Hello World\r\r '::vchar<30>) = 'Hello World\r\r'::vchar<30>
rtrim('Hello World\u2003 '::vchar<30>) = 'Hello World\u2003'::vchar<30>
6 changes: 5 additions & 1 deletion tests/cases/string/trim.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trim('aaaaabcccccaaa'::str, 'a'::str) [spaces_only:False] = 'bccccc'::str
trim('defabcabcdef'::str, 'def'::str) [spaces_only:False] = 'abcabc'::str
trim('abcdefcbaa'::str, 'abc'::str) [spaces_only:False] = 'def'::str

# trim with varchar
# varchar
trim('abc'::vchar<20>, ' '::vchar<5>) = 'abc'::vchar<20>
trim(' abc'::vchar<20>, ' '::vchar<5>) = 'abc'::vchar<20>
trim('abc '::vchar<20>, ' '::vchar<5>) = 'abc'::vchar<20>
Expand All @@ -35,3 +35,7 @@ trim('abc '::vchar<20>) = 'abc'::vchar<20>
trim(' abc '::vchar<20>) = 'abc'::vchar<20>
trim('aaaaabcccccaaa'::vchar<20>, 'a'::vchar<9>) [spaces_only:False] = 'bccccc'::vchar<20>
trim('defabcabcdef'::vchar<20>, 'def'::vchar<9>) [spaces_only:False] = 'abcabc'::vchar<20>
trim(' \tHello World\t '::vchar<30>) = '\tHello World\t'::vchar<30>
trim(' \nHello World\n '::vchar<30>) = '\nHello World\n'::vchar<30>
trim(' \rHello World\r '::vchar<30>) = '\rHello World\r'::vchar<30>
trim(' \u2003Hello World\u2003 '::vchar<30>) = '\u2003Hello World\u2003'::vchar<30>
2 changes: 1 addition & 1 deletion tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_substrait_extension_coverage():
all_test_files = load_all_testcases(test_case_dir)
coverage = get_test_coverage(all_test_files, registry)

assert coverage.test_count >= 1068
assert coverage.test_count >= 1080
assert (
coverage.num_tests_with_no_matching_function == 0
), f"{coverage.num_tests_with_no_matching_function} tests with no matching function"
Expand Down

0 comments on commit b0a9a43

Please sign in to comment.