1
0
Эх сурвалжийг харах

Add GA lifecycle and version metadata to `Contains` function (#133445)

* Add GA lifecycle and version metadata to `Contains` function
* Adding documentation around null
Michael Bischoff 1 сар өмнө
parent
commit
a1d1a81fe1

+ 1 - 1
docs/reference/query-languages/esql/_snippets/functions/description/contains.md

@@ -2,5 +2,5 @@
 
 **Description**
 
-Returns true if a keyword substring is within another string. Returns false if the substring cannot be found.
+Returns a boolean that indicates whether a keyword substring is within another string. Returns `null` if either parameter is null.
 

+ 3 - 0
docs/reference/query-languages/esql/_snippets/functions/layout/contains.md

@@ -1,6 +1,9 @@
 % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.
 
 ## `CONTAINS` [esql-contains]
+```{applies_to}
+stack: ga 9.2.0
+```
 
 **Syntax**
 

+ 2 - 2
docs/reference/query-languages/esql/_snippets/functions/parameters/contains.md

@@ -3,8 +3,8 @@
 **Parameters**
 
 `string`
-:   An input string
+:   String expression: input string to check against. If `null`, the function returns `null`.
 
 `substring`
-:   A substring to find in the input string
+:   String expression: A substring to find in the input string. If `null`, the function returns `null`.
 

+ 9 - 9
docs/reference/query-languages/esql/kibana/definition/functions/contains.json

@@ -2,7 +2,7 @@
   "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.",
   "type" : "scalar",
   "name" : "contains",
-  "description" : "Returns true if a keyword substring is within another string.\nReturns false if the substring cannot be found.",
+  "description" : "Returns a boolean that indicates whether a keyword substring is within another string.\nReturns `null` if either parameter is null.",
   "signatures" : [
     {
       "params" : [
@@ -10,13 +10,13 @@
           "name" : "string",
           "type" : "keyword",
           "optional" : false,
-          "description" : "An input string"
+          "description" : "String expression: input string to check against. If `null`, the function returns `null`."
         },
         {
           "name" : "substring",
           "type" : "keyword",
           "optional" : false,
-          "description" : "A substring to find in the input string"
+          "description" : "String expression: A substring to find in the input string. If `null`, the function returns `null`."
         }
       ],
       "variadic" : false,
@@ -28,13 +28,13 @@
           "name" : "string",
           "type" : "keyword",
           "optional" : false,
-          "description" : "An input string"
+          "description" : "String expression: input string to check against. If `null`, the function returns `null`."
         },
         {
           "name" : "substring",
           "type" : "text",
           "optional" : false,
-          "description" : "A substring to find in the input string"
+          "description" : "String expression: A substring to find in the input string. If `null`, the function returns `null`."
         }
       ],
       "variadic" : false,
@@ -46,13 +46,13 @@
           "name" : "string",
           "type" : "text",
           "optional" : false,
-          "description" : "An input string"
+          "description" : "String expression: input string to check against. If `null`, the function returns `null`."
         },
         {
           "name" : "substring",
           "type" : "keyword",
           "optional" : false,
-          "description" : "A substring to find in the input string"
+          "description" : "String expression: A substring to find in the input string. If `null`, the function returns `null`."
         }
       ],
       "variadic" : false,
@@ -64,13 +64,13 @@
           "name" : "string",
           "type" : "text",
           "optional" : false,
-          "description" : "An input string"
+          "description" : "String expression: input string to check against. If `null`, the function returns `null`."
         },
         {
           "name" : "substring",
           "type" : "text",
           "optional" : false,
-          "description" : "A substring to find in the input string"
+          "description" : "String expression: A substring to find in the input string. If `null`, the function returns `null`."
         }
       ],
       "variadic" : false,

+ 2 - 2
docs/reference/query-languages/esql/kibana/docs/functions/contains.md

@@ -1,8 +1,8 @@
 % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.
 
 ### CONTAINS
-Returns true if a keyword substring is within another string.
-Returns false if the substring cannot be found.
+Returns a boolean that indicates whether a keyword substring is within another string.
+Returns `null` if either parameter is null.
 
 ```esql
 ROW a = "hello"

+ 20 - 5
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Contains.java

@@ -18,6 +18,8 @@ import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
 import org.elasticsearch.xpack.esql.core.tree.Source;
 import org.elasticsearch.xpack.esql.core.type.DataType;
 import org.elasticsearch.xpack.esql.expression.function.Example;
+import org.elasticsearch.xpack.esql.expression.function.FunctionAppliesTo;
+import org.elasticsearch.xpack.esql.expression.function.FunctionAppliesToLifecycle;
 import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
 import org.elasticsearch.xpack.esql.expression.function.OptionalArgument;
 import org.elasticsearch.xpack.esql.expression.function.Param;
@@ -41,13 +43,26 @@ public class Contains extends EsqlScalarFunction implements OptionalArgument {
     private final Expression str;
     private final Expression substr;
 
-    @FunctionInfo(returnType = "boolean", description = """
-        Returns true if a keyword substring is within another string.
-        Returns false if the substring cannot be found.""", examples = @Example(file = "string", tag = "contains"))
+    @FunctionInfo(
+        returnType = "boolean",
+        description = """
+            Returns a boolean that indicates whether a keyword substring is within another string.
+            Returns `null` if either parameter is null.""",
+        examples = @Example(file = "string", tag = "contains"),
+        appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.GA, version = "9.2.0") }
+    )
     public Contains(
         Source source,
-        @Param(name = "string", type = { "keyword", "text" }, description = "An input string") Expression str,
-        @Param(name = "substring", type = { "keyword", "text" }, description = "A substring to find in the input string") Expression substr
+        @Param(
+            name = "string",
+            type = { "keyword", "text" },
+            description = "String expression: input string to check against. If `null`, the function returns `null`."
+        ) Expression str,
+        @Param(
+            name = "substring",
+            type = { "keyword", "text" },
+            description = "String expression: A substring to find in the input string. If `null`, the function returns `null`."
+        ) Expression substr
     ) {
         super(source, Arrays.asList(str, substr));
         this.str = str;