Browse Source

Rename mv_join to mv_concat (ESQL-1213)

That's not the name SPL uses for this, but it's a much more intuitive
name.

Closes ESQL-1210
Nik Everett 2 years ago
parent
commit
be7e182a6c

+ 2 - 2
docs/reference/esql/esql-functions.asciidoc

@@ -23,8 +23,8 @@ these functions:
 * <<esql-is_null>>
 * <<esql-length>>
 * <<esql-mv_avg>>
+* <<esql-mv_concat>>
 * <<esql-mv_count>>
-* <<esql-mv_join>>
 * <<esql-mv_max>>
 * <<esql-mv_median>>
 * <<esql-mv_min>>
@@ -49,8 +49,8 @@ include::functions/is_nan.asciidoc[]
 include::functions/is_null.asciidoc[]
 include::functions/length.asciidoc[]
 include::functions/mv_avg.asciidoc[]
+include::functions/mv_concat.asciidoc[]
 include::functions/mv_count.asciidoc[]
-include::functions/mv_join.asciidoc[]
 include::functions/mv_max.asciidoc[]
 include::functions/mv_median.asciidoc[]
 include::functions/mv_min.asciidoc[]

+ 30 - 0
docs/reference/esql/functions/mv_concat.asciidoc

@@ -0,0 +1,30 @@
+[[esql-mv_concat]]
+=== `MV_CONCAT`
+Converts a multivalued string field into a single valued field containing the
+concatenation of all values separated by a delimiter:
+
+[source,esql]
+----
+include::{esql-specs}/string.csv-spec[tag=mv_concat]
+----
+
+Returns:
+
+[%header,format=dsv,separator=|]
+|===
+include::{esql-specs}/string.csv-spec[tag=mv_concat-result]
+|===
+
+If you want to concat non-string fields call <<esql-to_string>> on them first:
+[source,esql]
+----
+include::{esql-specs}/ints.csv-spec[tag=mv_concat]
+----
+
+Returns:
+
+[%header,format=dsv,separator=|]
+|===
+include::{esql-specs}/ints.csv-spec[tag=mv_concat-result]
+|===
+

+ 0 - 30
docs/reference/esql/functions/mv_join.asciidoc

@@ -1,30 +0,0 @@
-[[esql-mv_join]]
-=== `MV_JOIN`
-Converts a multivalued string field into a single valued field containing the
-concatenation of all values separated by a delimiter:
-
-[source,esql]
-----
-include::{esql-specs}/string.csv-spec[tag=mv_join]
-----
-
-Returns:
-
-[%header,format=dsv,separator=|]
-|===
-include::{esql-specs}/string.csv-spec[tag=mv_join-result]
-|===
-
-If you want to join non-string fields call <<esql-to_string>> on them first:
-[source,esql]
-----
-include::{esql-specs}/ints.csv-spec[tag=mv_join]
-----
-
-Returns:
-
-[%header,format=dsv,separator=|]
-|===
-include::{esql-specs}/ints.csv-spec[tag=mv_join-result]
-|===
-

+ 5 - 5
x-pack/plugin/esql/qa/testFixtures/src/main/resources/ints.csv-spec

@@ -154,14 +154,14 @@ ROW a=[10, 9, 8]
 ;
 
 mvJoin
-// tag::mv_join[]
+// tag::mv_concat[]
 ROW a=[10, 9, 8]
-| EVAL j = MV_JOIN(TO_STRING(a), ", ")
-// end::mv_join[]
+| EVAL j = MV_CONCAT(TO_STRING(a), ", ")
+// end::mv_concat[]
 ;
 
-// tag::mv_join-result[]
+// tag::mv_concat-result[]
  a:integer | j:keyword
 [10, 9, 8] | "10, 9, 8"
-// end::mv_join-result[]
+// end::mv_concat-result[]
 ;

+ 1 - 1
x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec

@@ -30,8 +30,8 @@ median                   |median(arg1)
 median_absolute_deviation|median_absolute_deviation(arg1)
 min                      |min(arg1)
 mv_avg                   |mv_avg(arg1)
+mv_concat                |mv_concat(arg1, arg2)
 mv_count                 |mv_count(arg1)
-mv_join                  |mv_join(arg1, arg2)
 mv_max                   |mv_max(arg1)
 mv_median                |mv_median(arg1)
 mv_min                   |mv_min(arg1)

+ 5 - 5
x-pack/plugin/esql/qa/testFixtures/src/main/resources/string.csv-spec

@@ -233,16 +233,16 @@ ROW a=["foo", "zoo", "bar"]
 ;
 
 mvJoin
-// tag::mv_join[]
+// tag::mv_concat[]
 ROW a=["foo", "zoo", "bar"]
-| EVAL j = MV_JOIN(a, ", ")
-// end::mv_join[]
+| EVAL j = MV_CONCAT(a, ", ")
+// end::mv_concat[]
 ;
 
-// tag::mv_join-result[]
+// tag::mv_concat-result[]
             a:keyword | j:keyword
 ["foo", "zoo", "bar"] | "foo, zoo, bar"
-// end::mv_join-result[]
+// end::mv_concat-result[]
 ;
 
 mvMax

+ 2 - 2
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java

@@ -36,8 +36,8 @@ import org.elasticsearch.xpack.esql.expression.function.scalar.math.IsNaN;
 import org.elasticsearch.xpack.esql.expression.function.scalar.math.Pow;
 import org.elasticsearch.xpack.esql.expression.function.scalar.math.Round;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvAvg;
+import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvConcat;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvCount;
-import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvJoin;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMax;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMedian;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMin;
@@ -111,8 +111,8 @@ public class EsqlFunctionRegistry extends FunctionRegistry {
             // multivalue functions
             new FunctionDefinition[] {
                 def(MvAvg.class, MvAvg::new, "mv_avg"),
+                def(MvConcat.class, MvConcat::new, "mv_concat"),
                 def(MvCount.class, MvCount::new, "mv_count"),
-                def(MvJoin.class, MvJoin::new, "mv_join"),
                 def(MvMax.class, MvMax::new, "mv_max"),
                 def(MvMedian.class, MvMedian::new, "mv_median"),
                 def(MvMin.class, MvMin::new, "mv_min"),

+ 9 - 9
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvJoin.java → x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcat.java

@@ -30,8 +30,8 @@ import static org.elasticsearch.xpack.ql.expression.TypeResolutions.isString;
 /**
  * Reduce a multivalued string field to a single valued field by concatenating all values.
  */
-public class MvJoin extends BinaryScalarFunction implements Mappable {
-    public MvJoin(Source source, Expression field, Expression delim) {
+public class MvConcat extends BinaryScalarFunction implements Mappable {
+    public MvConcat(Source source, Expression field, Expression delim) {
         super(source, field, delim);
     }
 
@@ -60,7 +60,7 @@ public class MvJoin extends BinaryScalarFunction implements Mappable {
     ) {
         Supplier<EvalOperator.ExpressionEvaluator> fieldEval = toEvaluator.apply(left());
         Supplier<EvalOperator.ExpressionEvaluator> delimEval = toEvaluator.apply(right());
-        return () -> new MvJoinEvaluator(fieldEval.get(), delimEval.get());
+        return () -> new MvConcatEvaluator(fieldEval.get(), delimEval.get());
     }
 
     @Override
@@ -70,16 +70,16 @@ public class MvJoin extends BinaryScalarFunction implements Mappable {
 
     @Override
     protected BinaryScalarFunction replaceChildren(Expression newLeft, Expression newRight) {
-        return new MvJoin(source(), newLeft, newRight);
+        return new MvConcat(source(), newLeft, newRight);
     }
 
     @Override
     protected NodeInfo<? extends Expression> info() {
-        return NodeInfo.create(this, MvJoin::new, left(), right());
+        return NodeInfo.create(this, MvConcat::new, left(), right());
     }
 
     /**
-     * Evaluator for {@link MvJoin}. Not generated and doesn't extend from
+     * Evaluator for {@link MvConcat}. Not generated and doesn't extend from
      * {@link AbstractMultivalueFunction.AbstractEvaluator} because it's just
      * too different from all the other mv operators:
      * <ul>
@@ -88,11 +88,11 @@ public class MvJoin extends BinaryScalarFunction implements Mappable {
      *     <li>The actual joining process needs init step per row - {@link BytesRefBuilder#clear()}</li>
      * </ul>
      */
-    private class MvJoinEvaluator implements EvalOperator.ExpressionEvaluator {
+    private class MvConcatEvaluator implements EvalOperator.ExpressionEvaluator {
         private final EvalOperator.ExpressionEvaluator field;
         private final EvalOperator.ExpressionEvaluator delim;
 
-        MvJoinEvaluator(EvalOperator.ExpressionEvaluator field, EvalOperator.ExpressionEvaluator delim) {
+        MvConcatEvaluator(EvalOperator.ExpressionEvaluator field, EvalOperator.ExpressionEvaluator delim) {
             this.field = field;
             this.delim = delim;
         }
@@ -142,7 +142,7 @@ public class MvJoin extends BinaryScalarFunction implements Mappable {
 
         @Override
         public final String toString() {
-            return "MvJoin[field=" + field + ", delim=" + delim + "]";
+            return "MvConcat[field=" + field + ", delim=" + delim + "]";
         }
     }
 }

+ 5 - 5
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanNamedTypes.java

@@ -45,8 +45,8 @@ import org.elasticsearch.xpack.esql.expression.function.scalar.math.Pow;
 import org.elasticsearch.xpack.esql.expression.function.scalar.math.Round;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.AbstractMultivalueFunction;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvAvg;
+import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvConcat;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvCount;
-import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvJoin;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMax;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMedian;
 import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMin;
@@ -289,7 +289,7 @@ public final class PlanNamedTypes {
             // Multivalue functions
             of(ScalarFunction.class, MvAvg.class, PlanNamedTypes::writeMvFunction, PlanNamedTypes::readMvFunction),
             of(ScalarFunction.class, MvCount.class, PlanNamedTypes::writeMvFunction, PlanNamedTypes::readMvFunction),
-            of(ScalarFunction.class, MvJoin.class, PlanNamedTypes::writeMvJoin, PlanNamedTypes::readMvJoin),
+            of(ScalarFunction.class, MvConcat.class, PlanNamedTypes::writeMvJoin, PlanNamedTypes::readMvJoin),
             of(ScalarFunction.class, MvMax.class, PlanNamedTypes::writeMvFunction, PlanNamedTypes::readMvFunction),
             of(ScalarFunction.class, MvMedian.class, PlanNamedTypes::writeMvFunction, PlanNamedTypes::readMvFunction),
             of(ScalarFunction.class, MvMin.class, PlanNamedTypes::writeMvFunction, PlanNamedTypes::readMvFunction),
@@ -1093,11 +1093,11 @@ public final class PlanNamedTypes {
         out.writeExpression(fn.field());
     }
 
-    static MvJoin readMvJoin(PlanStreamInput in) throws IOException {
-        return new MvJoin(Source.EMPTY, in.readExpression(), in.readExpression());
+    static MvConcat readMvJoin(PlanStreamInput in) throws IOException {
+        return new MvConcat(Source.EMPTY, in.readExpression(), in.readExpression());
     }
 
-    static void writeMvJoin(PlanStreamOutput out, MvJoin fn) throws IOException {
+    static void writeMvJoin(PlanStreamOutput out, MvConcat fn) throws IOException {
         out.writeExpression(fn.left());
         out.writeExpression(fn.right());
     }

+ 5 - 5
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvJoinTests.java → x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatTests.java

@@ -24,10 +24,10 @@ import static org.elasticsearch.compute.data.BlockUtils.toJavaObject;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.nullValue;
 
-public class MvJoinTests extends AbstractScalarFunctionTestCase {
+public class MvConcatTests extends AbstractScalarFunctionTestCase {
     @Override
     protected Expression build(Source source, List<Literal> args) {
-        return new MvJoin(source, args.get(0), args.get(1));
+        return new MvConcat(source, args.get(0), args.get(1));
     }
 
     @Override
@@ -37,7 +37,7 @@ public class MvJoinTests extends AbstractScalarFunctionTestCase {
 
     @Override
     protected Expression expressionForSimpleData() {
-        return new MvJoin(Source.EMPTY, field("field", DataTypes.KEYWORD), field("delim", DataTypes.KEYWORD));
+        return new MvConcat(Source.EMPTY, field("field", DataTypes.KEYWORD), field("delim", DataTypes.KEYWORD));
     }
 
     @Override
@@ -54,12 +54,12 @@ public class MvJoinTests extends AbstractScalarFunctionTestCase {
 
     @Override
     protected String expectedEvaluatorSimpleToString() {
-        return "MvJoin[field=Attribute[channel=0], delim=Attribute[channel=1]]";
+        return "MvConcat[field=Attribute[channel=0], delim=Attribute[channel=1]]";
     }
 
     @Override
     protected Expression constantFoldable(List<Object> data) {
-        return new MvJoin(
+        return new MvConcat(
             Source.EMPTY,
             new Literal(Source.EMPTY, data.get(0), DataTypes.KEYWORD),
             new Literal(Source.EMPTY, data.get(1), DataTypes.KEYWORD)