Skip to content

Commit bef38ef

Browse files
committed
Review comments
1 parent f584b7d commit bef38ef

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,17 @@ public void testFilterWithNullAndEval() {
587587
}
588588
}
589589

590+
public void testSortWithNull() {
591+
try (EsqlQueryResponse results = run("row a = null | sort a")) {
592+
logger.info(results);
593+
assertEquals(1, getValuesList(results).size());
594+
int countIndex = results.columns().indexOf(new ColumnInfoImpl("a", "null"));
595+
assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a"));
596+
assertThat(results.columns().stream().map(ColumnInfoImpl::type).toList(), contains(DataType.NULL));
597+
assertNull(getValuesList(results).getFirst().get(countIndex));
598+
}
599+
}
600+
590601
public void testStringLength() {
591602
try (EsqlQueryResponse results = run("from test | eval l = length(color)")) {
592603
logger.info(results);

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/EstimatesRowSize.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public int consumeAllFields(boolean producesUnsortedDocIds) {
8585
}
8686
estimatedRowSize = maxEstimatedRowSize = 0;
8787
needsSortedDocIds = false;
88-
return size;
88+
return size == 0 ? 1 : size;
8989
}
9090

9191
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ private PhysicalOperation planExchangeSource(ExchangeSourceExec exchangeSource,
374374

375375
private PhysicalOperation planTopN(TopNExec topNExec, LocalExecutionPlannerContext context) {
376376
final Integer rowSize = topNExec.estimatedRowSize();
377+
assert rowSize != null && rowSize > 0 : "estimated row size [" + rowSize + "] wasn't set";
377378
PhysicalOperation source = plan(topNExec.child(), context);
378379

379380
ElementType[] elementTypes = new ElementType[source.layout.numberOfChannels()];

0 commit comments

Comments
 (0)