Skip to content

Commit

Permalink
ES|QL: add geo tests for mv_dedupe (#109342)
Browse files Browse the repository at this point in the history
Adding more unit tests for MV_DEDUPE function, covering geo_point,
geo_shape, cartesian_point and cartesian_shape. This also adds docs for
Kibana.

Fixes #108982
  • Loading branch information
luigidellaquila authored Jun 4, 2024
1 parent 4d91f0f commit 21952c7
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 6 deletions.
48 changes: 48 additions & 0 deletions docs/reference/esql/functions/kibana/definition/mv_dedupe.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/reference/esql/functions/types/mv_dedupe.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ double e()
"double mv_avg(number:double|integer|long|unsigned_long)"
"keyword mv_concat(string:text|keyword, delim:text|keyword)"
"integer mv_count(field:boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version)"
"boolean|date|double|integer|ip|keyword|long|text|version mv_dedupe(field:boolean|date|double|integer|ip|keyword|long|text|version)"
"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|version mv_dedupe(field:boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|version)"
"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version mv_first(field:boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version)"
"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version mv_last(field:boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version)"
"boolean|date|double|integer|ip|keyword|long|text|unsigned_long|version mv_max(field:boolean|date|double|integer|ip|keyword|long|text|unsigned_long|version)"
Expand Down Expand Up @@ -160,7 +160,7 @@ min |number |"double|integer|long"
mv_avg |number |"double|integer|long|unsigned_long" |Multivalue expression.
mv_concat |[string, delim] |["text|keyword", "text|keyword"] |[Multivalue expression., Delimiter.]
mv_count |field |"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version" |Multivalue expression.
mv_dedupe |field |"boolean|date|double|integer|ip|keyword|long|text|version" |Multivalue expression.
mv_dedupe |field |"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|version" |Multivalue expression.
mv_first |field |"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version" |Multivalue expression.
mv_last |field |"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version" |Multivalue expression.
mv_max |field |"boolean|date|double|integer|ip|keyword|long|text|unsigned_long|version" |Multivalue expression.
Expand Down Expand Up @@ -393,7 +393,7 @@ min |"double|integer|long"
mv_avg |double |false |false |false
mv_concat |keyword |[false, false] |false |false
mv_count |integer |false |false |false
mv_dedupe |"boolean|date|double|integer|ip|keyword|long|text|version" |false |false |false
mv_dedupe |"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|version" |false |false |false
mv_first |"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version"|false |false |false
mv_last |"boolean|cartesian_point|cartesian_shape|date|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version"|false |false |false
mv_max |"boolean|date|double|integer|ip|keyword|long|text|unsigned_long|version" |false |false |false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,22 @@
* Removes duplicate values from a multivalued field.
*/
public class MvDedupe extends AbstractMultivalueFunction {
// @TODO: add cartesian_point, geo_point, unsigned_long
// @TODO: add unsigned_long
@FunctionInfo(
returnType = { "boolean", "date", "double", "integer", "ip", "keyword", "long", "text", "version" },
returnType = {
"boolean",
"cartesian_point",
"cartesian_shape",
"date",
"double",
"geo_point",
"geo_shape",
"integer",
"ip",
"keyword",
"long",
"text",
"version" },
description = "Remove duplicate values from a multivalued field.",
note = "`MV_DEDUPE` may, but won't always, sort the values in the column.",
examples = @Example(file = "string", tag = "mv_dedupe")
Expand All @@ -37,7 +50,20 @@ public MvDedupe(
Source source,
@Param(
name = "field",
type = { "boolean", "date", "double", "integer", "ip", "keyword", "long", "text", "version" },
type = {
"boolean",
"cartesian_point",
"cartesian_shape",
"date",
"double",
"geo_point",
"geo_shape",
"integer",
"ip",
"keyword",
"long",
"text",
"version" },
description = "Multivalue expression."
) Expression field
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
import org.elasticsearch.xpack.esql.core.type.DataTypes;
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -42,6 +43,11 @@ public static Iterable<Object[]> parameters() {
doubles(cases, "mv_dedupe", "MvDedupe", (size, values) -> getMatcher(values.mapToObj(Double::valueOf)));
ints(cases, "mv_dedupe", "MvDedupe", (size, values) -> getMatcher(values.mapToObj(Integer::valueOf)));
longs(cases, "mv_dedupe", "MvDedupe", (size, values) -> getMatcher(values.mapToObj(Long::valueOf)));
cartesianPoints(cases, "mv_dedupe", "MvDedupe", (size, values) -> getMatcher(values));
cartesianShape(cases, "mv_dedupe", "MvDedupe", DataTypes.CARTESIAN_SHAPE, (size, values) -> getMatcher(values));
geoPoints(cases, "mv_dedupe", "MvDedupe", (size, values) -> getMatcher(values));
geoShape(cases, "mv_dedupe", "MvDedupe", DataTypes.GEO_SHAPE, (size, values) -> getMatcher(values));

// TODO switch extraction to BigInteger so this just works.
// unsignedLongs(cases, "mv_dedupe", "MvDedupe", (size, values) -> getMatcher(values));
return parameterSuppliersFromTypedData(cases);
Expand Down

0 comments on commit 21952c7

Please sign in to comment.