Conversation
[Ticket: elastic#106818]
|
Documentation preview: |
| least |"integer|long|double|boolean|keyword|text|ip|version least(first:integer|long|double|boolean|keyword|text|ip|version, ?rest...:integer|long|double|boolean|keyword|text|ip|version)" | first |"integer|long|double|boolean|keyword|text|ip|version" |"" |"integer|long|double|boolean|keyword|text|ip|version" | "Returns the minimum value from many columns." | false | true | false | ||
| left |"keyword left(string:keyword|text, length:integer)" |[string, length] |["keyword|text", "integer"] |["The string from which to return a substring.", "The number of characters to return."] |keyword | "Returns the substring that extracts 'length' chars from 'string' starting from the left." | [false, false] | false | false | ||
| length |"integer length(string:keyword|text)" |string |"keyword|text" | "" |integer | "Returns the character length of a string." | false | false | false | ||
| locate |"integer locate(str:keyword|text, substr:keyword|text)" |[str,substr] |["keyword|text", "keyword|text"] |["", ""] |integer | "Returns an integer that indicates the position of a keyword substring within another string" | [false, false] | false | false |
There was a problem hiding this comment.
I'm sorry for this test. It was a good idea, but I think it's grown to be a problem. @luigidellaquila, would you be ok if I broke this test apart into a few tests so updating it is easier? Right now it's a huge blob of text to work through.
There was a problem hiding this comment.
+100, updating this test is always painful for me as well
There was a problem hiding this comment.
👍 it's a good idea to break it down into smaller tests, imho.
There was a problem hiding this comment.
I'm doing it. Now. Well. Maybe in an hour.
...rc/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateTests.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateTests.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Locate.java
Outdated
Show resolved
Hide resolved
|
Hi @tteofili, I've created a changelog YAML for you. |
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
astefan
left a comment
There was a problem hiding this comment.
Left one comment regarding parameter names. Also, please add more complex csv-spec tests using from command:
- nested function calls locate(another_function(...)) or another_function(locate(...))
- use the result of locate in
stats,sortand other commands - check the warning messages it creates. In string.csv-spec look for examples (
warning:Line 1:).
| ) | ||
| public Locate( | ||
| Source source, | ||
| @Param(name = "str", type = { "keyword", "text" }, description = "An input string") Expression str, |
There was a problem hiding this comment.
Use the full word instead of str. There was a recent effort in having a common naming convention as much as possible in all functions. Same statement for substr below.
ChrisHegarty
left a comment
There was a problem hiding this comment.
LGTM. Left one small optional comment.
...rc/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateTests.java
Show resolved
Hide resolved
| int codePointCount = UnicodeUtil.codePointCount(str); | ||
| int indexStart = indexStart(codePointCount, start); | ||
| String utf8ToString = str.utf8ToString(); | ||
| return 1 + utf8ToString.indexOf(substr.utf8ToString(), utf8ToString.offsetByCodePoints(0, indexStart)); |
There was a problem hiding this comment.
I worry about this one with characters that need two chars in utf-16.
There was a problem hiding this comment.
thanks for noticing this @nik9000, and thanks @ChrisHegarty for opening #107172
This is automatically generated and should probably have been committed as part of elastic#106899.
This is automatically generated and was created as part of #106899.
This adds a
LOCATEfunction to ES|QL.closes #106818