Skip to content

Commit b8f315b

Browse files
committed
Updated tests to use the non-empty source, fixing the warnings and disabling serialization on broken functions
1 parent 1b26239 commit b8f315b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+213
-188
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ protected static String typeErrorMessage(
333333
String ordinal = includeOrdinal ? TypeResolutions.ParamOrdinal.fromIndex(badArgPosition).name().toLowerCase(Locale.ROOT) + " " : "";
334334
String expectedTypeString = expectedTypeSupplier.apply(validPerPosition.get(badArgPosition), badArgPosition);
335335
String name = types.get(badArgPosition).typeName();
336-
return ordinal + "argument of [] must be [" + expectedTypeString + "], found value [" + name + "] type [" + name + "]";
336+
return ordinal + "argument of [source] must be [" + expectedTypeString + "], found value [" + name + "] type [" + name + "]";
337337
}
338338

339339
@FunctionalInterface

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractScalarFunctionTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ protected static TestCaseSupplier arithmeticExceptionOverflowCase(
401401
evaluator + "[lhs=Attribute[channel=0], rhs=Attribute[channel=1]]",
402402
dataType,
403403
is(nullValue())
404-
).withWarning("Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.")
405-
.withWarning("Line -1:-1: java.lang.ArithmeticException: " + typeNameOverflow)
404+
).withWarning("Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.")
405+
.withWarning("Line 1:1: java.lang.ArithmeticException: " + typeNameOverflow)
406406
);
407407
}
408408
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopTests.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public static Iterable<Object[]> parameters() {
241241
new TestCaseSupplier.TypedData(0, DataType.INTEGER, "limit").forceLiteral(),
242242
new TestCaseSupplier.TypedData(new BytesRef("desc"), DataType.KEYWORD, "order").forceLiteral()
243243
),
244-
"Limit must be greater than 0 in [], found [0]"
244+
"Limit must be greater than 0 in [source], found [0]"
245245
)
246246
),
247247
new TestCaseSupplier(
@@ -252,7 +252,7 @@ public static Iterable<Object[]> parameters() {
252252
new TestCaseSupplier.TypedData(2, DataType.INTEGER, "limit").forceLiteral(),
253253
new TestCaseSupplier.TypedData(new BytesRef("wrong-order"), DataType.KEYWORD, "order").forceLiteral()
254254
),
255-
"Invalid order value in [], expected [ASC, DESC] but got [wrong-order]"
255+
"Invalid order value in [source], expected [ASC, DESC] but got [wrong-order]"
256256
)
257257
),
258258
new TestCaseSupplier(
@@ -263,7 +263,7 @@ public static Iterable<Object[]> parameters() {
263263
new TestCaseSupplier.TypedData(null, DataType.INTEGER, "limit").forceLiteral(),
264264
new TestCaseSupplier.TypedData(new BytesRef("desc"), DataType.KEYWORD, "order").forceLiteral()
265265
),
266-
"second argument of [] cannot be null, received [limit]"
266+
"second argument of [source] cannot be null, received [limit]"
267267
)
268268
),
269269
new TestCaseSupplier(
@@ -274,7 +274,7 @@ public static Iterable<Object[]> parameters() {
274274
new TestCaseSupplier.TypedData(1, DataType.INTEGER, "limit").forceLiteral(),
275275
new TestCaseSupplier.TypedData(null, DataType.KEYWORD, "order").forceLiteral()
276276
),
277-
"third argument of [] cannot be null, received [order]"
277+
"third argument of [source] cannot be null, received [order]"
278278
)
279279
)
280280
)
@@ -317,4 +317,10 @@ private static TestCaseSupplier makeSupplier(
317317
);
318318
});
319319
}
320+
321+
@Override
322+
protected Expression serializeDeserializeExpression(Expression expression) {
323+
// TODO: This aggregation doesn't serialize the Source, and must be fixed.
324+
return expression;
325+
}
320326
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToCartesianPointTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public static Iterable<Object[]> parameters() {
4949
bytesRef -> {
5050
var exception = expectThrows(Exception.class, () -> CARTESIAN.wktToWkb(bytesRef.utf8ToString()));
5151
return List.of(
52-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
53-
"Line -1:-1: " + exception
52+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
53+
"Line 1:1: " + exception
5454
);
5555
}
5656
);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToCartesianShapeTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public static Iterable<Object[]> parameters() {
5050
bytesRef -> {
5151
var exception = expectThrows(Exception.class, () -> CARTESIAN.wktToWkb(bytesRef.utf8ToString()));
5252
return List.of(
53-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
54-
"Line -1:-1: " + exception
53+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
54+
"Line 1:1: " + exception
5555
);
5656
}
5757
);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDateNanosTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public static Iterable<Object[]> parameters() {
7070
Long.MIN_VALUE,
7171
-1L,
7272
List.of(
73-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
74-
"Line -1:-1: java.lang.IllegalArgumentException: Nanosecond dates before 1970-01-01T00:00:00.000Z are not supported."
73+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
74+
"Line 1:1: java.lang.IllegalArgumentException: Nanosecond dates before 1970-01-01T00:00:00.000Z are not supported."
7575
)
7676
);
7777
TestCaseSupplier.forUnaryUnsignedLong(
@@ -91,8 +91,8 @@ public static Iterable<Object[]> parameters() {
9191
BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.TWO),
9292
UNSIGNED_LONG_MAX,
9393
bi -> List.of(
94-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
95-
"Line -1:-1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + bi + "] out of [long] range"
94+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
95+
"Line 1:1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + bi + "] out of [long] range"
9696
)
9797
);
9898
TestCaseSupplier.forUnaryDouble(
@@ -103,8 +103,8 @@ public static Iterable<Object[]> parameters() {
103103
Double.NEGATIVE_INFINITY,
104104
-Double.MIN_VALUE,
105105
d -> List.of(
106-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
107-
"Line -1:-1: java.lang.IllegalArgumentException: Nanosecond dates before 1970-01-01T00:00:00.000Z are not supported."
106+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
107+
"Line 1:1: java.lang.IllegalArgumentException: Nanosecond dates before 1970-01-01T00:00:00.000Z are not supported."
108108
)
109109
);
110110
TestCaseSupplier.forUnaryDouble(
@@ -115,8 +115,8 @@ public static Iterable<Object[]> parameters() {
115115
9.223372036854777E18, // a "convenient" value larger than `(double) Long.MAX_VALUE` (== ...776E18)
116116
Double.POSITIVE_INFINITY,
117117
d -> List.of(
118-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
119-
"Line -1:-1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + d + "] out of [long] range"
118+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
119+
"Line 1:1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + d + "] out of [long] range"
120120
)
121121
);
122122
TestCaseSupplier.forUnaryStrings(
@@ -125,8 +125,8 @@ public static Iterable<Object[]> parameters() {
125125
DataType.DATE_NANOS,
126126
bytesRef -> null,
127127
bytesRef -> List.of(
128-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
129-
"Line -1:-1: java.lang.IllegalArgumentException: "
128+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
129+
"Line 1:1: java.lang.IllegalArgumentException: "
130130
+ (bytesRef.utf8ToString().isEmpty()
131131
? "cannot parse empty datetime"
132132
: ("failed to parse date field [" + bytesRef.utf8ToString() + "] with format [strict_date_optional_time_nanos]"))

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetimeTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public static Iterable<Object[]> parameters() {
8181
BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.TWO),
8282
UNSIGNED_LONG_MAX,
8383
bi -> List.of(
84-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
85-
"Line -1:-1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + bi + "] out of [long] range"
84+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
85+
"Line 1:1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + bi + "] out of [long] range"
8686
)
8787
);
8888
TestCaseSupplier.forUnaryDouble(
@@ -93,8 +93,8 @@ public static Iterable<Object[]> parameters() {
9393
Double.NEGATIVE_INFINITY,
9494
-9.223372036854777E18, // a "convenient" value smaller than `(double) Long.MIN_VALUE` (== ...776E18)
9595
d -> List.of(
96-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
97-
"Line -1:-1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + d + "] out of [long] range"
96+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
97+
"Line 1:1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + d + "] out of [long] range"
9898
)
9999
);
100100
TestCaseSupplier.forUnaryDouble(
@@ -105,8 +105,8 @@ public static Iterable<Object[]> parameters() {
105105
9.223372036854777E18, // a "convenient" value larger than `(double) Long.MAX_VALUE` (== ...776E18)
106106
Double.POSITIVE_INFINITY,
107107
d -> List.of(
108-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
109-
"Line -1:-1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + d + "] out of [long] range"
108+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
109+
"Line 1:1: org.elasticsearch.xpack.esql.core.InvalidArgumentException: [" + d + "] out of [long] range"
110110
)
111111
);
112112
TestCaseSupplier.forUnaryStrings(
@@ -115,8 +115,8 @@ public static Iterable<Object[]> parameters() {
115115
DataType.DATETIME,
116116
bytesRef -> null,
117117
bytesRef -> List.of(
118-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
119-
"Line -1:-1: java.lang.IllegalArgumentException: "
118+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
119+
"Line 1:1: java.lang.IllegalArgumentException: "
120120
+ (bytesRef.utf8ToString().isEmpty()
121121
? "cannot parse empty datetime"
122122
: ("failed to parse date field [" + bytesRef.utf8ToString() + "] with format [strict_date_optional_time]"))
@@ -151,8 +151,8 @@ public static Iterable<Object[]> parameters() {
151151
DataType.DATETIME,
152152
bytesRef -> null,
153153
bytesRef -> List.of(
154-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
155-
"Line -1:-1: java.lang.IllegalArgumentException: failed to parse date field ["
154+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
155+
"Line 1:1: java.lang.IllegalArgumentException: failed to parse date field ["
156156
+ ((BytesRef) bytesRef).utf8ToString()
157157
+ "] with format [strict_date_optional_time]"
158158
)
@@ -171,8 +171,8 @@ public static Iterable<Object[]> parameters() {
171171
DataType.DATETIME,
172172
bytesRef -> null,
173173
bytesRef -> List.of(
174-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
175-
"Line -1:-1: java.lang.IllegalArgumentException: failed to parse date field ["
174+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
175+
"Line 1:1: java.lang.IllegalArgumentException: failed to parse date field ["
176176
+ ((BytesRef) bytesRef).utf8ToString()
177177
+ "] with format [strict_date_optional_time]"
178178
)

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDegreesTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public static Iterable<Object[]> parameters() {
6767
double deg = Math.toDegrees(d);
6868
ArrayList<String> warnings = new ArrayList<>(2);
6969
if (Double.isNaN(deg) || Double.isInfinite(deg)) {
70-
warnings.add("Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.");
71-
warnings.add("Line -1:-1: java.lang.ArithmeticException: not a finite double number: " + deg);
70+
warnings.add("Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.");
71+
warnings.add("Line 1:1: java.lang.ArithmeticException: not a finite double number: " + deg);
7272
}
7373
return warnings;
7474
});
@@ -84,8 +84,8 @@ public static Iterable<Object[]> parameters() {
8484
DataType.DOUBLE,
8585
d -> null,
8686
d -> List.of(
87-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
88-
"Line -1:-1: java.lang.ArithmeticException: not a finite double number: " + ((double) d > 0 ? "Infinity" : "-Infinity")
87+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
88+
"Line 1:1: java.lang.ArithmeticException: not a finite double number: " + ((double) d > 0 ? "Infinity" : "-Infinity")
8989
)
9090
);
9191

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public static Iterable<Object[]> parameters() {
6565
() -> EsqlDataTypeConverter.stringToDouble(bytesRef.utf8ToString())
6666
);
6767
return List.of(
68-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
69-
"Line -1:-1: " + exception
68+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
69+
"Line 1:1: " + exception
7070
);
7171
});
7272
TestCaseSupplier.forUnaryUnsignedLong(

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeoPointTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public static Iterable<Object[]> parameters() {
4444
TestCaseSupplier.forUnaryStrings(suppliers, evaluatorName.apply("FromString"), DataType.GEO_POINT, bytesRef -> null, bytesRef -> {
4545
var exception = expectThrows(Exception.class, () -> GEO.wktToWkb(bytesRef.utf8ToString()));
4646
return List.of(
47-
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
48-
"Line -1:-1: " + exception
47+
"Line 1:1: evaluation of [source] failed, treating result as null. Only first 20 failures recorded.",
48+
"Line 1:1: " + exception
4949
);
5050
});
5151
// strings that are geo point representations

0 commit comments

Comments
 (0)