Skip to content

Commit fd36695

Browse files
committed
Fix assertion error when executing row query with filter (elastic#133704)
(cherry picked from commit 12fd34d)
1 parent 6f391f6 commit fd36695

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.elasticsearch.index.IndexSettings;
3939
import org.elasticsearch.index.mapper.DateFieldMapper;
4040
import org.elasticsearch.index.mapper.extras.MapperExtrasPlugin;
41+
import org.elasticsearch.index.query.BoolQueryBuilder;
4142
import org.elasticsearch.index.query.QueryBuilder;
4243
import org.elasticsearch.index.query.RangeQueryBuilder;
4344
import org.elasticsearch.index.shard.IndexShard;
@@ -146,6 +147,13 @@ public void testRow() {
146147
}
147148
}
148149

150+
public void testRowWithFilter() {
151+
long value = randomLongBetween(0, Long.MAX_VALUE);
152+
try (EsqlQueryResponse response = run(syncEsqlQueryRequest().query("row " + value).filter(new BoolQueryBuilder().boost(1.0f)))) {
153+
assertEquals(List.of(List.of(value)), getValuesList(response));
154+
}
155+
}
156+
149157
public void testFromStatsGroupingAvgWithSort() {
150158
testFromStatsGroupingAvgImpl("from test | stats avg(count) by data | sort data | limit 2", "data", "avg(count)");
151159
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,9 @@ private static void analyzeAndMaybeRetry(
568568
if (result.indices.isValid() || requestFilter != null) {
569569
// We won't run this check with no filter and no valid indices since this may lead to false positive - missing index report
570570
// when the resolution result is not valid for a different reason.
571-
EsqlCCSUtils.updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, result.indices, requestFilter != null);
571+
if (executionInfo.clusterInfo.isEmpty() == false) {
572+
EsqlCCSUtils.updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, result.indices, requestFilter != null);
573+
}
572574
}
573575
plan = analyzeAction.apply(result);
574576
} catch (Exception e) {

0 commit comments

Comments
 (0)