mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 17:34:17 -04:00
SQL: Test and fix the NULL handling of the String functions (#68379)
Fixed the inconsistencies regarding NULL argument handling. NULL literal vs NULL field value as function arguments in some case resulted in different function return values. Functions should return with the same value no matter if the argument(s) came from a field or from a literal. The introduced integration test tests if function calls with same argument values (regardless of literal/field) will return with the same output (also checks if newly added functions are added to the testcases). Fixed the following functions: * Insert: NULL start, length and replacement arguments (as fields) also result in NULL return value instead of returning the input. * Locate: NULL pattern results in NULL return value, NULL optional start argument handled the same as missing start argument * Replace: NULL pattern and replacement results in NULL instead of returning the input * Substring: NULL start or length results in NULL instead of returning the input Fixes #58907
This commit is contained in:
parent
5695a63f0c
commit
a3dbdae2ef
13 changed files with 428 additions and 46 deletions
|
@ -107,7 +107,7 @@ CONCAT(
|
|||
|
||||
*Output*: string
|
||||
|
||||
*Description*: Returns a character string that is the result of concatenating `string_exp1` to `string_exp2`. If one of the string is `NULL`, the other string will be returned.
|
||||
*Description*: Returns a character string that is the result of concatenating `string_exp1` to `string_exp2`. `NULL` input strings are treated as empty strings.
|
||||
|
||||
[source, sql]
|
||||
--------------------------------------------------
|
||||
|
@ -228,7 +228,7 @@ LOCATE(
|
|||
|
||||
*Output*: integer
|
||||
|
||||
*Description*: Returns the starting position of the first occurrence of `pattern` within `source`. The search for the first occurrence of `pattern` begins with the first character position in `source` unless the optional argument, `start`, is specified. If `start` is specified, the search begins with the character position indicated by the value of `start`. The first character position in `source` is indicated by the value 1. If `pattern` is not found within `source`, the value 0 is returned.
|
||||
*Description*: Returns the starting position of the first occurrence of `pattern` within `source`. The optional `start` specifies the character position to start the search with. The first character position in `source` is indicated by the value 1. Not specifying `start` or specifying it as `NULL`, any negative value, 0 or 1, starts the search at the first character position. If `pattern` is not found within `source`, the value 0 is returned.
|
||||
|
||||
[source, sql]
|
||||
--------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue