Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add options to substring for start parameter being negative #508

Merged
merged 3 commits into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions extensions/functions_string.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ scalar_functions:
A `start` value of 1 refers to the first characters of the string. When
`length` is not specified the function will extract a substring starting
from position `start` and ending at the end of the string.

The `negative_start` option applies to the `start` parameter. `WRAP_FROM_END` means
the index will start from the end of the `input` and move backwards.
The last character has an index of -1, the second to last character has an index of -2,
and so on. `LEFT_OF_BEGINNING` means the returned substring will start from
the left of the first character. A `start` of -1 will begin 2 characters left of the
the `input`, while a `start` of 0 begins 1 character left of the `input`.
impls:
- args:
- value: "varchar<L1>"
Expand All @@ -61,6 +68,9 @@ scalar_functions:
name: "start"
- value: i32
name: "length"
options:
negative_start:
values: [ WRAP_FROM_END, LEFT_OF_BEGINNING, ERROR ]
return: "varchar<L1>"
- args:
- value: "string"
Expand All @@ -69,6 +79,9 @@ scalar_functions:
name: "start"
- value: i32
name: "length"
options:
negative_start:
values: [ WRAP_FROM_END, LEFT_OF_BEGINNING, ERROR ]
return: "string"
- args:
- value: "fixedchar<l1>"
Expand All @@ -77,24 +90,36 @@ scalar_functions:
name: "start"
- value: i32
name: "length"
options:
negative_start:
values: [ WRAP_FROM_END, LEFT_OF_BEGINNING, ERROR ]
return: "string"
- args:
- value: "varchar<L1>"
name: "input"
- value: i32
name: "start"
options:
negative_start:
values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ]
return: "varchar<L1>"
- args:
- value: "string"
name: "input"
- value: i32
name: "start"
options:
negative_start:
values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ]
return: "string"
- args:
- value: "fixedchar<l1>"
name: "input"
- value: i32
name: "start"
options:
negative_start:
values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ]
return: "string"
-
name: regexp_match_substring
Expand Down
Loading