Skip to content

Commit 7413e41

Browse files
authored
Fix headers check in SingleValueQueryTests (#103074)
If the generated docs have no values at all for the first documents which are checked, don't expect Warnings either. Closes #102997
1 parent c0bfab9 commit 7413e41

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueQueryTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,18 @@ private void runCase(List<List<Object>> fieldValues, int count, Integer docsStar
156156
int expected = 0;
157157
int min = docsStart != null ? docsStart : 0;
158158
int max = docsStop != null ? docsStop : fieldValues.size();
159+
int valuesCount = 0;
159160
for (int i = min; i < max; i++) {
160-
if (fieldValues.get(i).size() == 1) {
161+
int mvCount = fieldValues.get(i).size();
162+
if (mvCount == 1) {
161163
expected++;
162164
}
165+
valuesCount += mvCount;
163166
}
164167
assertThat(count, equalTo(expected));
165168

166169
// query's count runs against the full set, not just min-to-max
167-
if (fieldValues.stream().anyMatch(x -> x.size() > 1)) {
170+
if (valuesCount > 0 && fieldValues.stream().anyMatch(x -> x.size() > 1)) {
168171
assertWarnings(
169172
"Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.",
170173
"Line -1:-1: java.lang.IllegalArgumentException: single-value function encountered multi-value"

0 commit comments

Comments
 (0)