Skip to content

Commit e20b4aa

Browse files
committed
Fixup lookup
1 parent a53bd0f commit e20b4aa

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/read/ValuesSourceReaderOperator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public class ValuesSourceReaderOperator extends AbstractPageMappingToIteratorOpe
4343
* @param docChannel the channel containing the shard, leaf/segment and doc id
4444
*/
4545
public record Factory(List<FieldInfo> fields, List<ShardContext> shardContexts, int docChannel) implements OperatorFactory {
46+
public Factory {
47+
if (fields.isEmpty()) {
48+
throw new IllegalStateException("ValuesSourceReaderOperator doesn't support empty fields");
49+
}
50+
}
51+
4652
@Override
4753
public Operator get(DriverContext driverContext) {
4854
return new ValuesSourceReaderOperator(driverContext.blockFactory(), fields, shardContexts, docChannel);
@@ -96,6 +102,9 @@ public record ShardContext(IndexReader reader, Supplier<SourceLoader> newSourceL
96102
* @param docChannel the channel containing the shard, leaf/segment and doc id
97103
*/
98104
public ValuesSourceReaderOperator(BlockFactory blockFactory, List<FieldInfo> fields, List<ShardContext> shardContexts, int docChannel) {
105+
if (fields.isEmpty()) {
106+
throw new IllegalStateException("ValuesSourceReaderOperator doesn't support empty fields");
107+
}
99108
this.fields = fields.stream().map(FieldWork::new).toArray(FieldWork[]::new);
100109
this.shardContexts = shardContexts;
101110
this.docChannel = docChannel;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/AbstractLookupService.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,14 @@ private void doLookup(T request, CancellableTask task, ActionListener<List<Page>
350350
warnings
351351
);
352352
releasables.add(queryOperator);
353-
var extractFieldsOperator = extractFieldsOperator(shardContext.context, driverContext, request.extractFields);
354-
releasables.add(extractFieldsOperator);
353+
354+
List<Operator> operators = new ArrayList<>();
355+
if (request.extractFields.isEmpty() == false) {
356+
var extractFieldsOperator = extractFieldsOperator(shardContext.context, driverContext, request.extractFields);
357+
releasables.add(extractFieldsOperator);
358+
operators.add(extractFieldsOperator);
359+
}
360+
operators.add(finishPages);
355361

356362
/*
357363
* Collect all result Pages in a synchronizedList mostly out of paranoia. We'll
@@ -373,7 +379,7 @@ private void doLookup(T request, CancellableTask task, ActionListener<List<Page>
373379
driverContext,
374380
request::toString,
375381
queryOperator,
376-
List.of(extractFieldsOperator, finishPages),
382+
operators,
377383
outputOperator,
378384
Driver.DEFAULT_STATUS_INTERVAL,
379385
Releasables.wrap(shardContext.release, localBreaker)

0 commit comments

Comments
 (0)