From 84c3f4379025f0ac7e7f6566a5aa4c3e491a9d32 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Wed, 14 Jun 2023 14:37:16 -0700 Subject: [PATCH 1/3] feat: add options to substring for start parameter being negative --- extensions/functions_string.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/extensions/functions_string.yaml b/extensions/functions_string.yaml index 7842e94eb..0b4c8a12f 100644 --- a/extensions/functions_string.yaml +++ b/extensions/functions_string.yaml @@ -53,6 +53,12 @@ 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 returned substring will start from the end of the `input`. The last character + has an index of -1. `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" @@ -61,6 +67,9 @@ scalar_functions: name: "start" - value: i32 name: "length" + options: + negative_start: + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] return: "varchar" - args: - value: "string" @@ -69,6 +78,9 @@ scalar_functions: name: "start" - value: i32 name: "length" + options: + negative_start: + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] return: "string" - args: - value: "fixedchar" @@ -77,24 +89,36 @@ scalar_functions: name: "start" - value: i32 name: "length" + options: + negative_start: + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] return: "string" - args: - value: "varchar" name: "input" - value: i32 name: "start" + options: + negative_start: + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] return: "varchar" - args: - value: "string" name: "input" - value: i32 name: "start" + options: + negative_start: + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] return: "string" - args: - value: "fixedchar" name: "input" - value: i32 name: "start" + options: + negative_start: + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] return: "string" - name: regexp_match_substring From 2ea6907c259994662ca84d5829d8a6cc3b4faf86 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Thu, 22 Jun 2023 08:49:11 -0700 Subject: [PATCH 2/3] feat: add option for error and provide better option descriptions --- extensions/functions_string.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/extensions/functions_string.yaml b/extensions/functions_string.yaml index 0b4c8a12f..bd6eacce3 100644 --- a/extensions/functions_string.yaml +++ b/extensions/functions_string.yaml @@ -55,8 +55,9 @@ scalar_functions: 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 returned substring will start from the end of the `input`. The last character - has an index of -1. `LEFT_OF_BEGINNING` means the returned substring will start from + the returned substring 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: @@ -69,7 +70,7 @@ scalar_functions: name: "length" options: negative_start: - values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING, ERROR ] return: "varchar" - args: - value: "string" @@ -80,7 +81,7 @@ scalar_functions: name: "length" options: negative_start: - values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING, ERROR ] return: "string" - args: - value: "fixedchar" @@ -91,7 +92,7 @@ scalar_functions: name: "length" options: negative_start: - values: [ WRAP_FROM_END, LEFT_OF_BEGINNING ] + values: [ WRAP_FROM_END, LEFT_OF_BEGINNING, ERROR ] return: "string" - args: - value: "varchar" From 76637086d3d1d9e3c4ff3f2fc167c1d3f319a7f1 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Mon, 26 Jun 2023 10:59:10 -0700 Subject: [PATCH 3/3] docs: fix description for negative start option --- extensions/functions_string.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/functions_string.yaml b/extensions/functions_string.yaml index bd6eacce3..159988c47 100644 --- a/extensions/functions_string.yaml +++ b/extensions/functions_string.yaml @@ -55,7 +55,7 @@ scalar_functions: 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 returned substring will start from the end of the `input` and move backwards. + 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