From bb6ee3f35fbd221ef5af783b291e24e9b000040d Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 15 Jan 2025 14:18:02 -0500 Subject: [PATCH] Add operator to ESQL signature for kibana This adds a field to the kibana defintion files for each signature that looks like: ``` "operator": "+", ``` Kibana wants these symbols. --- docs/reference/esql/functions/kibana/definition/add.json | 1 + docs/reference/esql/functions/kibana/definition/div.json | 1 + .../esql/functions/kibana/definition/equals.json | 1 + .../esql/functions/kibana/definition/greater_than.json | 1 + .../kibana/definition/greater_than_or_equal.json | 1 + docs/reference/esql/functions/kibana/definition/in.json | 1 + .../esql/functions/kibana/definition/less_than.json | 1 + .../functions/kibana/definition/less_than_or_equal.json | 1 + .../reference/esql/functions/kibana/definition/like.json | 1 + .../esql/functions/kibana/definition/match.json | 3 ++- .../esql/functions/kibana/definition/match_operator.json | 1 + docs/reference/esql/functions/kibana/definition/mod.json | 1 + docs/reference/esql/functions/kibana/definition/mul.json | 1 + docs/reference/esql/functions/kibana/definition/neg.json | 1 + .../esql/functions/kibana/definition/not_equals.json | 1 + .../esql/functions/kibana/definition/rlike.json | 1 + docs/reference/esql/functions/kibana/definition/sub.json | 1 + .../xpack/esql/expression/function/FunctionInfo.java | 9 +++++++++ .../xpack/esql/expression/function/fulltext/Match.java | 1 + .../esql/expression/function/scalar/string/RLike.java | 2 +- .../expression/function/scalar/string/WildcardLike.java | 2 +- .../expression/predicate/operator/arithmetic/Add.java | 1 + .../expression/predicate/operator/arithmetic/Div.java | 1 + .../expression/predicate/operator/arithmetic/Mod.java | 1 + .../expression/predicate/operator/arithmetic/Mul.java | 1 + .../expression/predicate/operator/arithmetic/Neg.java | 1 + .../expression/predicate/operator/arithmetic/Sub.java | 1 + .../expression/predicate/operator/comparison/Equals.java | 1 + .../predicate/operator/comparison/GreaterThan.java | 1 + .../operator/comparison/GreaterThanOrEqual.java | 1 + .../expression/predicate/operator/comparison/In.java | 1 + .../predicate/operator/comparison/LessThan.java | 1 + .../predicate/operator/comparison/LessThanOrEqual.java | 1 + .../predicate/operator/comparison/NotEquals.java | 1 + .../expression/function/AbstractFunctionTestCase.java | 8 +++++++- 35 files changed, 50 insertions(+), 4 deletions(-) diff --git a/docs/reference/esql/functions/kibana/definition/add.json b/docs/reference/esql/functions/kibana/definition/add.json index cfb4755a93d59..e362f76d3d66c 100644 --- a/docs/reference/esql/functions/kibana/definition/add.json +++ b/docs/reference/esql/functions/kibana/definition/add.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "+", "name" : "add", "description" : "Add two numbers together. If either field is <> then the result is `null`.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/div.json b/docs/reference/esql/functions/kibana/definition/div.json index 9132f32a27778..0ff7d7f413f7e 100644 --- a/docs/reference/esql/functions/kibana/definition/div.json +++ b/docs/reference/esql/functions/kibana/definition/div.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "/", "name" : "div", "description" : "Divide one number by another. If either field is <> then the result is `null`.", "note" : "Division of two integer types will yield an integer result, rounding towards 0. If you need floating point division, <> one of the arguments to a `DOUBLE`.", diff --git a/docs/reference/esql/functions/kibana/definition/equals.json b/docs/reference/esql/functions/kibana/definition/equals.json index 40f3d54ba597a..035adb826107e 100644 --- a/docs/reference/esql/functions/kibana/definition/equals.json +++ b/docs/reference/esql/functions/kibana/definition/equals.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "==", "name" : "equals", "description" : "Check if two fields are equal. If either field is <> then the result is `null`.", "note" : "This is pushed to the underlying search index if one side of the comparison is constant and the other side is a field in the index that has both an <> and <>.", diff --git a/docs/reference/esql/functions/kibana/definition/greater_than.json b/docs/reference/esql/functions/kibana/definition/greater_than.json index ea2c0fb1212c7..3f8be68f76cae 100644 --- a/docs/reference/esql/functions/kibana/definition/greater_than.json +++ b/docs/reference/esql/functions/kibana/definition/greater_than.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : ">", "name" : "greater_than", "description" : "Check if one field is greater than another. If either field is <> then the result is `null`.", "note" : "This is pushed to the underlying search index if one side of the comparison is constant and the other side is a field in the index that has both an <> and <>.", diff --git a/docs/reference/esql/functions/kibana/definition/greater_than_or_equal.json b/docs/reference/esql/functions/kibana/definition/greater_than_or_equal.json index 7e1feb37e87b0..8f68e2af02073 100644 --- a/docs/reference/esql/functions/kibana/definition/greater_than_or_equal.json +++ b/docs/reference/esql/functions/kibana/definition/greater_than_or_equal.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : ">=", "name" : "greater_than_or_equal", "description" : "Check if one field is greater than or equal to another. If either field is <> then the result is `null`.", "note" : "This is pushed to the underlying search index if one side of the comparison is constant and the other side is a field in the index that has both an <> and <>.", diff --git a/docs/reference/esql/functions/kibana/definition/in.json b/docs/reference/esql/functions/kibana/definition/in.json index 46fca7ced5a9f..fa041e79df451 100644 --- a/docs/reference/esql/functions/kibana/definition/in.json +++ b/docs/reference/esql/functions/kibana/definition/in.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "IN", "name" : "in", "description" : "The `IN` operator allows testing whether a field or expression equals an element in a list of literals, fields or expressions.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/less_than.json b/docs/reference/esql/functions/kibana/definition/less_than.json index 71aae4d759ecf..1572b34534ac2 100644 --- a/docs/reference/esql/functions/kibana/definition/less_than.json +++ b/docs/reference/esql/functions/kibana/definition/less_than.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "<", "name" : "less_than", "description" : "Check if one field is less than another. If either field is <> then the result is `null`.", "note" : "This is pushed to the underlying search index if one side of the comparison is constant and the other side is a field in the index that has both an <> and <>.", diff --git a/docs/reference/esql/functions/kibana/definition/less_than_or_equal.json b/docs/reference/esql/functions/kibana/definition/less_than_or_equal.json index f119b7ab2eb12..62fd3d69fe143 100644 --- a/docs/reference/esql/functions/kibana/definition/less_than_or_equal.json +++ b/docs/reference/esql/functions/kibana/definition/less_than_or_equal.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "<=", "name" : "less_than_or_equal", "description" : "Check if one field is less than or equal to another. If either field is <> then the result is `null`.", "note" : "This is pushed to the underlying search index if one side of the comparison is constant and the other side is a field in the index that has both an <> and <>.", diff --git a/docs/reference/esql/functions/kibana/definition/like.json b/docs/reference/esql/functions/kibana/definition/like.json index f375c697bd60d..335f2b655ffd4 100644 --- a/docs/reference/esql/functions/kibana/definition/like.json +++ b/docs/reference/esql/functions/kibana/definition/like.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "LIKE", "name" : "like", "description" : "Use `LIKE` to filter data based on string patterns using wildcards. `LIKE`\nusually acts on a field placed on the left-hand side of the operator, but it can\nalso act on a constant (literal) expression. The right-hand side of the operator\nrepresents the pattern.\n\nThe following wildcard characters are supported:\n\n* `*` matches zero or more characters.\n* `?` matches one character.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/match.json b/docs/reference/esql/functions/kibana/definition/match.json index eb206cb9ddf4d..d7035e285dac1 100644 --- a/docs/reference/esql/functions/kibana/definition/match.json +++ b/docs/reference/esql/functions/kibana/definition/match.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", - "type" : "eval", + "type" : "operator", + "operator" : "MATCH", "name" : "match", "description" : "Use `MATCH` to perform a <> on the specified field.\nUsing `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL.\n\nMatch can be used on fields from the text family like <> and <>,\nas well as other field types like keyword, boolean, dates, and numeric types.\n\nFor a simplified syntax, you can use the <> `:` operator instead of `MATCH`.\n\n`MATCH` returns true if the provided query matches the row.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/match_operator.json b/docs/reference/esql/functions/kibana/definition/match_operator.json index b58f9d5835a2d..919778f10c7ca 100644 --- a/docs/reference/esql/functions/kibana/definition/match_operator.json +++ b/docs/reference/esql/functions/kibana/definition/match_operator.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "MATCH", "name" : "match_operator", "description" : "Use `MATCH` to perform a <> on the specified field.\nUsing `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL.\n\nMatch can be used on fields from the text family like <> and <>,\nas well as other field types like keyword, boolean, dates, and numeric types.\n\nFor a simplified syntax, you can use the <> `:` operator instead of `MATCH`.\n\n`MATCH` returns true if the provided query matches the row.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/mod.json b/docs/reference/esql/functions/kibana/definition/mod.json index 51e4c55e41528..194cbdcc4eb9e 100644 --- a/docs/reference/esql/functions/kibana/definition/mod.json +++ b/docs/reference/esql/functions/kibana/definition/mod.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "%", "name" : "mod", "description" : "Divide one number by another and return the remainder. If either field is <> then the result is `null`.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/mul.json b/docs/reference/esql/functions/kibana/definition/mul.json index 961330cd23661..e62da0a6d0721 100644 --- a/docs/reference/esql/functions/kibana/definition/mul.json +++ b/docs/reference/esql/functions/kibana/definition/mul.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "*", "name" : "mul", "description" : "Multiply two numbers together. If either field is <> then the result is `null`.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/neg.json b/docs/reference/esql/functions/kibana/definition/neg.json index 5d5f519f8fe50..7074ad204d3b0 100644 --- a/docs/reference/esql/functions/kibana/definition/neg.json +++ b/docs/reference/esql/functions/kibana/definition/neg.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "-", "name" : "neg", "description" : "Returns the negation of the argument.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/not_equals.json b/docs/reference/esql/functions/kibana/definition/not_equals.json index d35a5b43ec238..42220168d3b03 100644 --- a/docs/reference/esql/functions/kibana/definition/not_equals.json +++ b/docs/reference/esql/functions/kibana/definition/not_equals.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "!=", "name" : "not_equals", "description" : "Check if two fields are unequal. If either field is <> then the result is `null`.", "note" : "This is pushed to the underlying search index if one side of the comparison is constant and the other side is a field in the index that has both an <> and <>.", diff --git a/docs/reference/esql/functions/kibana/definition/rlike.json b/docs/reference/esql/functions/kibana/definition/rlike.json index 7a328293383bb..4ac7e25a32540 100644 --- a/docs/reference/esql/functions/kibana/definition/rlike.json +++ b/docs/reference/esql/functions/kibana/definition/rlike.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "RLIKE", "name" : "rlike", "description" : "Use `RLIKE` to filter data based on string patterns using using\n<>. `RLIKE` usually acts on a field placed on\nthe left-hand side of the operator, but it can also act on a constant (literal)\nexpression. The right-hand side of the operator represents the pattern.", "signatures" : [ diff --git a/docs/reference/esql/functions/kibana/definition/sub.json b/docs/reference/esql/functions/kibana/definition/sub.json index 608b5eb1009a7..4555e12a00dd4 100644 --- a/docs/reference/esql/functions/kibana/definition/sub.json +++ b/docs/reference/esql/functions/kibana/definition/sub.json @@ -1,6 +1,7 @@ { "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", "type" : "operator", + "operator" : "-", "name" : "sub", "description" : "Subtract one number from another. If either field is <> then the result is `null`.", "signatures" : [ diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/FunctionInfo.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/FunctionInfo.java index 1491f5643e4f5..46aa2e0530da7 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/FunctionInfo.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/FunctionInfo.java @@ -18,6 +18,15 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.CONSTRUCTOR) public @interface FunctionInfo { + /** + * If this function implements an operator, what is its symbol? + *

+ * This exists entirely to add to the Kibana function definition + * json files. + *

+ */ + String operator() default ""; + /** * The type(s) this function returns. */ diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/Match.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/Match.java index 93f23d2f7ad08..7d900b7bc7116 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/Match.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/Match.java @@ -98,6 +98,7 @@ public class Match extends FullTextFunction implements PostOptimizationVerificat @FunctionInfo( returnType = "boolean", + operator = "MATCH", preview = true, description = """ Use `MATCH` to perform a <> on the specified field. diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLike.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLike.java index fb0aac0c85b38..9c9861fecf38c 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLike.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLike.java @@ -30,7 +30,7 @@ public class RLike extends org.elasticsearch.xpack.esql.core.expression.predicate.regex.RLike implements EvaluatorMapper { public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "RLike", RLike::new); - @FunctionInfo(returnType = "boolean", description = """ + @FunctionInfo(returnType = "boolean", operator = "RLIKE", description = """ Use `RLIKE` to filter data based on string patterns using using <>. `RLIKE` usually acts on a field placed on the left-hand side of the operator, but it can also act on a constant (literal) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLike.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLike.java index 65455c708cc9b..87d963b0ef024 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLike.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLike.java @@ -35,7 +35,7 @@ public class WildcardLike extends org.elasticsearch.xpack.esql.core.expression.p WildcardLike::new ); - @FunctionInfo(returnType = "boolean", description = """ + @FunctionInfo(returnType = "boolean", operator = "LIKE", description = """ Use `LIKE` to filter data based on string patterns using wildcards. `LIKE` usually acts on a field placed on the left-hand side of the operator, but it can also act on a constant (literal) expression. The right-hand side of the operator diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Add.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Add.java index 9d34410e8a164..ebfb0fdee47fa 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Add.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Add.java @@ -36,6 +36,7 @@ public class Add extends DateTimeArithmeticOperation implements BinaryComparison public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Add", Add::new); @FunctionInfo( + operator = "+", returnType = { "double", "integer", "long", "date_nanos", "date_period", "datetime", "time_duration", "unsigned_long" }, description = "Add two numbers together. " + "If either field is <> then the result is `null`." ) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Div.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Div.java index f1e197cf350b6..1c944678be028 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Div.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Div.java @@ -29,6 +29,7 @@ public class Div extends EsqlArithmeticOperation implements BinaryComparisonInve private DataType type; @FunctionInfo( + operator = "/", returnType = { "double", "integer", "long", "unsigned_long" }, description = "Divide one number by another. " + "If either field is <> then the result is `null`.", diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Mod.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Mod.java index 2381e3df9b617..622a5db1a023a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Mod.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Mod.java @@ -26,6 +26,7 @@ public class Mod extends EsqlArithmeticOperation { public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Mod", Mod::new); @FunctionInfo( + operator = "%", returnType = { "double", "integer", "long", "unsigned_long" }, description = "Divide one number by another and return the remainder. " + "If either field is <> then the result is `null`." diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Mul.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Mul.java index 03981a821f52d..6229e107847d8 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Mul.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Mul.java @@ -26,6 +26,7 @@ public class Mul extends EsqlArithmeticOperation implements BinaryComparisonInve public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Mul", Mul::new); @FunctionInfo( + operator = "*", returnType = { "double", "integer", "long", "unsigned_long" }, description = "Multiply two numbers together. " + "If either field is <> then the result is `null`." diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Neg.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Neg.java index 6663ccf0ef7b6..2f3cb0a0c3f04 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Neg.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Neg.java @@ -37,6 +37,7 @@ public class Neg extends UnaryScalarFunction { public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Neg", Neg::new); @FunctionInfo( + operator = "-", returnType = { "double", "integer", "long", "date_period", "time_duration" }, description = "Returns the negation of the argument." ) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Sub.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Sub.java index e072619e67728..90d7e34a43a8a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Sub.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/Sub.java @@ -38,6 +38,7 @@ public class Sub extends DateTimeArithmeticOperation implements BinaryComparison public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Sub", Sub::new); @FunctionInfo( + operator = "-", returnType = { "double", "integer", "long", "date_period", "datetime", "time_duration", "unsigned_long" }, description = "Subtract one number from another. " + "If either field is <> then the result is `null`." diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java index 464553977d3cc..72186a0c96c10 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java @@ -49,6 +49,7 @@ public class Equals extends EsqlBinaryComparison implements Negatable> then the result is `null`.", diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThan.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThan.java index 6087240387f01..c72ab0e53964a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThan.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThan.java @@ -44,6 +44,7 @@ public class GreaterThan extends EsqlBinaryComparison implements Negatable> then the result is `null`.", diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqual.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqual.java index 7ec1e5590bef6..f9d17a8aeb7a3 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqual.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqual.java @@ -44,6 +44,7 @@ public class GreaterThanOrEqual extends EsqlBinaryComparison implements Negatabl ); @FunctionInfo( + operator = ">=", returnType = { "boolean" }, description = "Check if one field is greater than or equal to another. " + "If either field is <> then the result is `null`.", diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/In.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/In.java index 6a35fa8e8b957..ff90f472bae30 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/In.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/In.java @@ -108,6 +108,7 @@ public class In extends EsqlScalarFunction { private final List list; @FunctionInfo( + operator = "IN", returnType = "boolean", description = "The `IN` operator allows testing whether a field or expression equals an element in a list of literals, " + "fields or expressions.", diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThan.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThan.java index 5f130c054cd6f..aea92ec103805 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThan.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThan.java @@ -44,6 +44,7 @@ public class LessThan extends EsqlBinaryComparison implements Negatable> then the result is `null`.", diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqual.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqual.java index 0904c408bfab5..47981054cbf8c 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqual.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqual.java @@ -44,6 +44,7 @@ public class LessThanOrEqual extends EsqlBinaryComparison implements Negatable> then the result is `null`.", diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEquals.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEquals.java index d4f86e9a878a9..278ad936c56fa 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEquals.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEquals.java @@ -49,6 +49,7 @@ public class NotEquals extends EsqlBinaryComparison implements Negatable> then the result is `null`.", diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java index 1cf087cf55ccd..6011a972d69ec 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java @@ -1146,7 +1146,13 @@ private static void renderKibanaFunctionDefinition( "comment", "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it." ); - builder.field("type", isAggregation() ? "agg" : OPERATORS.get(name) != null ? "operator" : "eval"); + if (false == info.operator().isEmpty()) { + builder.field("type", "operator"); + builder.field("operator", info.operator()); + assertThat(isAggregation(), equalTo(false)); + } else { + builder.field("type", isAggregation() ? "agg" : "eval"); + } builder.field("name", name); builder.field("description", removeAsciidocLinks(info.description())); if (Strings.isNullOrEmpty(info.note()) == false) {