Skip to content

Commit

Permalink
Keep the original casting error message
Browse files Browse the repository at this point in the history
  • Loading branch information
astefan committed Aug 19, 2024
1 parent 06d09fc commit 21d00a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 21d00a1

Please sign in to comment.