Skip to content

Commit 54fbaff

Browse files
ES|QL: Fix adjustment of warnings for multi-cluster tests (#107322)
1 parent 7ee5c73 commit 54fbaff

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

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

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -781,39 +781,20 @@ ROW deg = [90, 180, 270]
781781
[90, 180, 270] | [1.5707963267948966, 3.141592653589793, 4.71238898038469]
782782
;
783783

784-
warningWithFromSource-Ignore
784+
warningWithFromSource
785785
from employees | sort emp_no | limit 1 | eval x = to_long(emp_no) * 10000000 | eval y = to_int(x) > 1 | keep y;
786-
warning:Line 1:89: evaluation of [to_int(x)] failed, treating result as null. Only first 20 failures recorded.
787-
warning:Line 1:89: org.elasticsearch.xpack.ql.InvalidArgumentException: [100010000000] out of [integer] range
786+
warningRegex:Line 1:89: evaluation of \[to_int\(x\)\] failed, treating result as null. Only first 20 failures recorded.
787+
warningRegex:Line 1:89: org.elasticsearch.xpack.ql.InvalidArgumentException: \[10\d+0000000\] out of \[integer\] range
788788

789789
y:boolean
790790
null
791791
;
792792

793793
// the test is also notable through having the "failing" operation in the filter, which will be part of the fragment sent to a data node
794-
multipleWarnings-Ignore
794+
multipleWarnings
795795
from employees | sort emp_no | eval x = to_long(emp_no) * 10000000 | where to_int(x) > 1 | keep x | limit 1;
796-
warning:Line 1:76: evaluation of [to_int(x)] failed, treating result as null. Only first 20 failures recorded.
797-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100010000000] out of [integer] range
798-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100020000000] out of [integer] range
799-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100030000000] out of [integer] range
800-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100040000000] out of [integer] range
801-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100050000000] out of [integer] range
802-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100060000000] out of [integer] range
803-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100070000000] out of [integer] range
804-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100080000000] out of [integer] range
805-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100090000000] out of [integer] range
806-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100100000000] out of [integer] range
807-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100110000000] out of [integer] range
808-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100120000000] out of [integer] range
809-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100130000000] out of [integer] range
810-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100140000000] out of [integer] range
811-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100150000000] out of [integer] range
812-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100160000000] out of [integer] range
813-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100170000000] out of [integer] range
814-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100180000000] out of [integer] range
815-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100190000000] out of [integer] range
816-
warning:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: [100200000000] out of [integer] range
796+
warningRegex:Line 1:76: evaluation of \[to_int\(x\)\] failed, treating result as null. Only first 20 failures recorded.
797+
warningRegex:Line 1:76: org.elasticsearch.xpack.ql.InvalidArgumentException: \[10\d+0000000\] out of \[integer\] range
817798

818799
x:long
819800
;

x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/CsvSpecReader.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ public Object parse(String line) {
7777
if (testCase.expectedWarnings.isEmpty() == false) {
7878
throw new IllegalArgumentException("Cannot mix warnings and regex warnings in CSV SPEC files: [" + line + "]");
7979
}
80-
testCase.expectedWarningsRegex.add(Pattern.compile(".*" + line.substring("warningregex:".length()).trim() + ".*"));
80+
String regex = line.substring("warningregex:".length()).trim();
81+
testCase.expectedWarningsRegexString.add(regex);
82+
testCase.expectedWarningsRegex.add(warningRegexToPattern(regex));
8183
} else if (lower.startsWith("ignoreorder:")) {
8284
testCase.ignoreOrder = Boolean.parseBoolean(line.substring("ignoreOrder:".length()).trim());
8385
} else if (line.startsWith(";")) {
@@ -97,11 +99,16 @@ public Object parse(String line) {
9799
}
98100
}
99101

102+
private static Pattern warningRegexToPattern(String regex) {
103+
return Pattern.compile(".*" + regex + ".*");
104+
}
105+
100106
public static class CsvTestCase {
101107
public String query;
102108
public String earlySchema;
103109
public String expectedResults;
104110
private final List<String> expectedWarnings = new ArrayList<>();
111+
private final List<String> expectedWarningsRegexString = new ArrayList<>();
105112
private final List<Pattern> expectedWarningsRegex = new ArrayList<>();
106113
public boolean ignoreOrder;
107114
public List<String> requiredFeatures = List.of();
@@ -146,6 +153,9 @@ public List<String> expectedWarnings(boolean forEmulated) {
146153
*/
147154
public void adjustExpectedWarnings(Function<String, String> updater) {
148155
expectedWarnings.replaceAll(updater::apply);
156+
expectedWarningsRegexString.replaceAll(updater::apply);
157+
expectedWarningsRegex.clear();
158+
expectedWarningsRegex.addAll(expectedWarningsRegexString.stream().map(CsvSpecReader::warningRegexToPattern).toList());
149159
}
150160

151161
public List<Pattern> expectedWarningsRegex() {

0 commit comments

Comments
 (0)