Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/111968.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 111968
summary: "ESQL: don't lose the original casting error message"
area: ES|QL
type: bug
issues:
- 111967
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,9 @@ private static List<Attribute> potentialCandidatesIfNoMatchesFound(
Collection<Attribute> attrList,
java.util.function.Function<List<String>, String> messageProducer
) {
if (ua.customMessage()) {
return List.of();
}
// none found - add error message
if (matches.isEmpty()) {
Set<String> names = new HashSet<>(attrList.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,30 @@ public void testRoundFunctionInvalidInputs() {
"1:31: second argument of [round(a, 3.5)] must be [integer], found value [3.5] type [double]",
error("row a = 1, b = \"c\" | eval x = round(a, 3.5)")
);
}

public void testImplicitCastingErrorMessages() {
assertEquals(
"1:23: Cannot convert string [c] to [INTEGER], error [Cannot parse number [c]]",
error("row a = round(123.45, \"c\")")
);
assertEquals(
"1:27: Cannot convert string [c] to [DOUBLE], error [Cannot parse number [c]]",
error("row a = 1 | eval x = acos(\"c\")")
);
assertEquals(
"1:33: Cannot convert string [c] to [DOUBLE], error [Cannot parse number [c]]\n"
+ "line 1:38: Cannot convert string [a] to [INTEGER], error [Cannot parse number [a]]",
error("row a = 1 | eval x = round(acos(\"c\"),\"a\")")
);
assertEquals(
"1:63: Cannot convert string [x] to [INTEGER], error [Cannot parse number [x]]",
error("row ip4 = to_ip(\"1.2.3.4\") | eval ip4_prefix = ip_prefix(ip4, \"x\", 0)")
);
assertEquals(
"1:42: Cannot convert string [a] to [DOUBLE], error [Cannot parse number [a]]",
error("ROW a=[3, 5, 1, 6] | EVAL avg_a = MV_AVG(\"a\")")
);
}

public void testAggsExpressionsInStatsAggs() {
Expand Down