Skip to content

Commit 3b7dcc9

Browse files
committed
Add enhancement for MV_APPEND supports 2-n number of arguments
1 parent c6f7827 commit 3b7dcc9

File tree

17 files changed

+287
-167
lines changed

17 files changed

+287
-167
lines changed

docs/reference/esql/functions/description/mv_append.asciidoc

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/definition/mv_append.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/docs/mv_append.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorImplementer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ public void unpackValues(MethodSpec.Builder builder, boolean blockStyle) {
699699
}
700700
if (componentType.equals(BYTES_REF)) {
701701
builder.addStatement("$LValues[i] = $L[i].getBytesRef($L, $LScratch[i])", name, paramName(blockStyle), lookupVar, name);
702+
} else if (componentType.equals(INT_BLOCK) || componentType.equals(LONG_BLOCK) || componentType.equals(DOUBLE_BLOCK)
703+
|| componentType.equals(BOOLEAN_BLOCK) || componentType.equals(BYTES_REF_BLOCK)) {
704+
builder.addStatement("$LValues[i] = $L[i]", name, paramName(blockStyle));
702705
} else {
703706
builder.addStatement("$LValues[i] = $L[i].$L($L)", name, paramName(blockStyle), getMethod(componentType), lookupVar);
704707
}

x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/Types.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,19 @@ public class Types {
139139
static final ClassName RELEASABLES = ClassName.get("org.elasticsearch.core", "Releasables");
140140

141141
static ClassName blockType(TypeName elementType) {
142-
if (elementType.equals(TypeName.BOOLEAN)) {
142+
if (elementType.equals(TypeName.BOOLEAN) || elementType.equals(BOOLEAN_BLOCK)) {
143143
return BOOLEAN_BLOCK;
144144
}
145-
if (elementType.equals(BYTES_REF)) {
145+
if (elementType.equals(BYTES_REF) || elementType.equals(BYTES_REF_BLOCK)) {
146146
return BYTES_REF_BLOCK;
147147
}
148-
if (elementType.equals(TypeName.INT)) {
148+
if (elementType.equals(TypeName.INT) || elementType.equals(INT_BLOCK)) {
149149
return INT_BLOCK;
150150
}
151-
if (elementType.equals(TypeName.LONG)) {
151+
if (elementType.equals(TypeName.LONG) || elementType.equals(LONG_BLOCK)) {
152152
return LONG_BLOCK;
153153
}
154-
if (elementType.equals(TypeName.DOUBLE)) {
154+
if (elementType.equals(TypeName.DOUBLE) || elementType.equals(DOUBLE_BLOCK)) {
155155
return DOUBLE_BLOCK;
156156
}
157157
throw new IllegalArgumentException("unknown block type for [" + elementType + "]");

x-pack/plugin/esql/qa/testFixtures/src/main/resources/floats.csv-spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,12 @@ FROM employees
540540
i = mv_append(salary_change.int, salary_change.int),
541541
i2 = mv_append(emp_no, salary_change.int),
542542
i3 = mv_append(emp_no, emp_no),
543-
s = mv_append(salary_change.keyword, salary_change.keyword)
543+
s = mv_append(salary_change.keyword, salary_change.keyword, salary_change.keyword)
544544
| KEEP emp_no, salary_change, d, i, i2, i3, s
545545
| SORT emp_no;
546546

547547
emp_no:integer | salary_change:double | d:double | i:integer | i2:integer | i3:integer | s:keyword
548-
10008 | [-2.92,0.75,3.54,12.68] | [-2.92,0.75,3.54,12.68,-2.92,0.75,3.54,12.68] | [-2,0,3,12,-2,0,3,12] | [10008,-2,0,3,12] | [10008, 10008] | [-2.92,0.75,12.68,3.54,-2.92,0.75,12.68,3.54]
548+
10008 | [-2.92,0.75,3.54,12.68] | [-2.92,0.75,3.54,12.68,-2.92,0.75,3.54,12.68] | [-2,0,3,12,-2,0,3,12] | [10008,-2,0,3,12] | [10008, 10008] | [-2.92,0.75,12.68,3.54,-2.92,0.75,12.68,3.54,-2.92,0.75,12.68,3.54]
549549
10021 | null | null | null | null | [10021, 10021] | null
550550
;
551551

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ mvAppend
14861486
required_capability: fn_mv_append
14871487

14881488
ROW a = "a", b = ["b", "c"], n = null
1489-
| EVAL aa = mv_append(a, a), bb = mv_append(b, b), ab = mv_append(a, b), abb = mv_append(mv_append(a, b), b), na = mv_append(n, a), an = mv_append(a, n)
1489+
| EVAL aa = mv_append(a, a), bb = mv_append(b, b), ab = mv_append(a, b), abb = mv_append(a, b, b), na = mv_append(n, a), an = mv_append(a, n)
14901490
;
14911491

14921492
a:keyword | b:keyword | n:null | aa:keyword | bb:keyword | ab:keyword | abb:keyword | na:keyword | an:keyword

x-pack/plugin/esql/qa/testFixtures/src/main/resources/union_types.csv-spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ multiIndexIndirectUseOfUnionTypesInMvExpand
13411341
// make the csv tests work with multiple indices.
13421342
required_capability: union_types
13431343
FROM sample_data, sample_data_ts_long
1344-
| EVAL foo = MV_APPEND(message, message)
1344+
| EVAL foo = MV_APPEND(message, message, message)
13451345
| SORT client_ip ASC
13461346
| LIMIT 1
13471347
| MV_EXPAND foo

x-pack/plugin/esql/qa/testFixtures/src/main/resources/version.csv-spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ required_capability: fn_mv_append
377377

378378
ROW a = to_version("1.2.0"), x1 = to_version("0.0.1"), x2 = to_version("1.0.0")
379379
| EVAL b = mv_append(x1, x2)
380-
| EVAL aa = mv_append(a, a), bb = mv_append(b, b), ab = mv_append(a, b), abb = mv_append(mv_append(a, b), b)
380+
| EVAL aa = mv_append(a, a), bb = mv_append(b, b), ab = mv_append(a, b), abb = mv_append(a, b, b)
381381
| KEEP a, b, aa, bb, ab, abb
382382
;
383383

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBooleanEvaluator.java

Lines changed: 26 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)