Skip to content

Commit

Permalink
ESQL: Move more test type error testing (#119945) (#120324)
Browse files Browse the repository at this point in the history
This reduces the number of test cases in ESQL a little more ala #119678.
It migrates a few random tests and all of the multivalue functions:
```
92775 -> 43760
 3m45 -> 4m04
```

This adds a few more error test cases that were missing to make sure it all
lines up well. And it fixes a few error messages in a few functions. That's
*likely* where the extra time goes.
  • Loading branch information
nik9000 authored Jan 16, 2025
1 parent b590298 commit 8253a83
Show file tree
Hide file tree
Showing 57 changed files with 1,184 additions and 237 deletions.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/kibana/definition/like.json

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

72 changes: 72 additions & 0 deletions docs/reference/esql/functions/kibana/definition/mv_append.json

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

12 changes: 12 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.

24 changes: 24 additions & 0 deletions docs/reference/esql/functions/kibana/definition/mv_slice.json

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

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/kibana/definition/rlike.json

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

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/types/like.asciidoc

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_append.asciidoc

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

1 change: 1 addition & 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.

1 change: 1 addition & 0 deletions docs/reference/esql/functions/types/mv_slice.asciidoc

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

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/types/rlike.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 @@ -55,13 +55,15 @@ public class MvAppend extends EsqlScalarFunction implements EvaluatorMapper {
"cartesian_point",
"cartesian_shape",
"date",
"date_nanos",
"double",
"geo_point",
"geo_shape",
"integer",
"ip",
"keyword",
"long",
"unsigned_long",
"version" },
description = "Concatenates values of two multi-value fields."
)
Expand All @@ -74,6 +76,7 @@ public MvAppend(
"cartesian_point",
"cartesian_shape",
"date",
"date_nanos",
"double",
"geo_point",
"geo_shape",
Expand All @@ -82,6 +85,7 @@ public MvAppend(
"keyword",
"long",
"text",
"unsigned_long",
"version" }
) Expression field1,
@Param(
Expand All @@ -91,6 +95,7 @@ public MvAppend(
"cartesian_point",
"cartesian_shape",
"date",
"date_nanos",
"double",
"geo_point",
"geo_shape",
Expand All @@ -99,6 +104,7 @@ public MvAppend(
"keyword",
"long",
"text",
"unsigned_long",
"version" }
) Expression field2
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class MvDedupe extends AbstractMultivalueFunction {
"ip",
"keyword",
"long",
"unsigned_long",
"version" },
description = "Remove duplicate values from a multivalued field.",
note = "`MV_DEDUPE` may, but won't always, sort the values in the column.",
Expand All @@ -69,6 +70,7 @@ public MvDedupe(
"keyword",
"long",
"text",
"unsigned_long",
"version" },
description = "Multivalue expression."
) Expression field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class MvSlice extends EsqlScalarFunction implements OptionalArgument, Eva
"ip",
"keyword",
"long",
"unsigned_long",
"version" },
description = """
Returns a subset of the multivalued field using the start and end index values.
Expand Down Expand Up @@ -96,6 +97,7 @@ public MvSlice(
"keyword",
"long",
"text",
"unsigned_long",
"version" },
description = "Multivalue expression. If `null`, the function returns `null`."
) Expression field,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ protected static TestCaseSupplier typeErrorSupplier(

/**
* Build a test case that asserts that the combination of parameter types is an error.
* @deprecated use an extension of {@link ErrorsForCasesWithoutExamplesTestCase}
*/
@Deprecated
protected static TestCaseSupplier typeErrorSupplier(
boolean includeOrdinal,
List<Set<DataType>> validPerPosition,
Expand Down Expand Up @@ -643,11 +645,17 @@ protected static void buildLayout(Layout.Builder builder, Expression e) {
protected Object toJavaObjectUnsignedLongAware(Block block, int position) {
Object result;
result = toJavaObject(block, position);
if (result != null && testCase.expectedType() == DataType.UNSIGNED_LONG) {
assertThat(result, instanceOf(Long.class));
result = NumericUtils.unsignedLongAsBigInteger((Long) result);
if (result == null || testCase.expectedType() != DataType.UNSIGNED_LONG) {
return result;
}
return result;
if (result instanceof List<?> l) {
return l.stream().map(v -> {
assertThat(v, instanceOf(Long.class));
return NumericUtils.unsignedLongAsBigInteger((Long) v);
}).toList();
}
assertThat(result, instanceOf(Long.class));
return NumericUtils.unsignedLongAsBigInteger((Long) result);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,11 @@ public void testFold() {
Object result = nullOptimized.fold(FoldContext.small());
// Decode unsigned longs into BigIntegers
if (testCase.expectedType() == DataType.UNSIGNED_LONG && result != null) {
result = NumericUtils.unsignedLongAsBigInteger((Long) result);
if (result instanceof List<?> l) {
result = l.stream().map(v -> NumericUtils.unsignedLongAsBigInteger((Long) v)).toList();
} else {
result = NumericUtils.unsignedLongAsBigInteger((Long) result);
}
}
assertThat(result, testCase.getMatcher());
if (testCase.getExpectedBuildEvaluatorWarnings() != null) {
Expand Down
Loading

0 comments on commit 8253a83

Please sign in to comment.