Skip to content

Commit caca630

Browse files
committed
Added CSV tests for warnings
1 parent e85bbc1 commit caca630

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,26 @@ emp_no:integer | is_rehired:boolean | a1:boolean
287287
10005 | [false,false,false,true] | false
288288
;
289289

290+
mvSliceWarnings
291+
required_capability: functions_source_serialization_warnings
292+
293+
FROM employees
294+
| SORT first_name ASC
295+
| EVAL
296+
start = CASE(first_name == "Alejandro", 1, 0),
297+
end = CASE(first_name == "Alejandro", 0, 1),
298+
result = MV_SLICE(is_rehired, start, end)
299+
| KEEP first_name, result
300+
| LIMIT 1
301+
;
302+
303+
warning:Line 6:10: evaluation of [MV_SLICE(is_rehired, start, end)] failed, treating result as null. Only first 20 failures recorded.
304+
warning:Line 6:10: org.elasticsearch.xpack.esql.core.InvalidArgumentException: Start offset is greater than end offset
305+
306+
first_name:keyword | result:boolean
307+
Alejandro | null
308+
;
309+
290310
values
291311
required_capability: agg_values
292312

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,24 @@ date1:date | dd_ms:integer
366366
2023-12-02T11:00:00.000Z | 1000
367367
;
368368

369+
dateDiffTestWarnings
370+
required_capability: functions_source_serialization_warnings
371+
372+
FROM employees
373+
| SORT first_name ASC
374+
| EVAL date1 = TO_DATETIME("2023-12-02T11:00:00.000Z")
375+
| EVAL dd_ms = DATE_DIFF(first_name, date1, date1)
376+
| KEEP date1, dd_ms
377+
| LIMIT 1
378+
;
379+
380+
warning:Line 4:16: evaluation of [DATE_DIFF(first_name, date1, date1)] failed, treating result as null. Only first 20 failures recorded.
381+
warning:Line 4:16: java.lang.IllegalArgumentException: A value of [YEAR, QUARTER, MONTH, DAYOFYEAR, DAY, WEEK, WEEKDAY, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND, NANOSECOND] or their aliases is required; received [Alejandro]
382+
383+
date1:date | dd_ms:integer
384+
2023-12-02T11:00:00.000Z | null
385+
;
386+
369387
evalDateDiffMonthAsWhole0Months#[skip:-8.14.1, reason:omitting millis/timezone not allowed before 8.14]
370388

371389
ROW from=TO_DATETIME("2023-12-31T23:59:59.999Z"), to=TO_DATETIME("2024-01-01T00:00:00")

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,33 @@ mvsum:unsigned_long
10091009
null
10101010
;
10111011

1012+
mvSumOverflowOnNode
1013+
required_capability: functions_source_serialization_warnings
1014+
1015+
FROM employees
1016+
| SORT first_name ASC
1017+
| EVAL
1018+
ints = CASE(first_name == "Alejandro", [0, 1, 2147483647], 0),
1019+
longs = CASE(first_name == "Alejandro", [0, 1, 9223372036854775807], 0),
1020+
ulongs = CASE(first_name == "Alejandro", [0, 1, 18446744073709551615], 0),
1021+
intsResult = mv_sum(ints),
1022+
longsResult = mv_sum(longs),
1023+
ulongsResult = mv_sum(ulongs)
1024+
| KEEP first_name, intsResult, longsResult, ulongsResult
1025+
| LIMIT 1
1026+
;
1027+
1028+
warning:Line 7:14: evaluation of [mv_sum(ints)] failed, treating result as null. Only first 20 failures recorded.
1029+
warning:Line 7:14: java.lang.ArithmeticException: integer overflow
1030+
warning:Line 8:15: evaluation of [mv_sum(longs)] failed, treating result as null. Only first 20 failures recorded.
1031+
warning:Line 8:15: java.lang.ArithmeticException: long overflow
1032+
warning:Line 9:16: evaluation of [mv_sum(ulongs)] failed, treating result as null. Only first 20 failures recorded.
1033+
warning:Line 9:16: java.lang.ArithmeticException: unsigned_long overflow
1034+
1035+
first_name:keyword | intsResult:integer | longsResult:long | ulongsResult:unsigned_long
1036+
Alejandro | null | null | null
1037+
;
1038+
10121039
e
10131040
// tag::e[]
10141041
ROW E()

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,25 @@ Gatewayinstances|Gateway instances
10681068
null |null
10691069
;
10701070

1071+
replaceWarnings
1072+
required_capability: functions_source_serialization_warnings
1073+
1074+
FROM employees
1075+
| SORT first_name ASC
1076+
| EVAL
1077+
regex = CASE(first_name == "Alejandro", "(", ""),
1078+
result = replace(first_name, regex, "")
1079+
| KEEP first_name, result
1080+
| LIMIT 1
1081+
;
1082+
1083+
warning:Line 5:10: evaluation of [replace(first_name, regex, \"\")] failed, treating result as null. Only first 20 failures recorded.
1084+
warning:Line 5:10: java.util.regex.PatternSyntaxException: Unclosed group near index 1%0D%0A(
1085+
1086+
first_name:keyword | result:keyword
1087+
Alejandro | null
1088+
;
1089+
10711090
left
10721091
// tag::left[]
10731092
FROM employees

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ public enum Cap {
204204
*/
205205
FN_ROUND_UL_FIXES,
206206

207+
/**
208+
* Fixes for multiple functions not serializing their source, and emitting warnings with wrong line number and text.
209+
*/
210+
FUNCTIONS_SOURCE_SERIALIZATION_WARNINGS,
211+
207212
/**
208213
* All functions that take TEXT should never emit TEXT, only KEYWORD. #114334
209214
*/

0 commit comments

Comments
 (0)