Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/122762.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 122762
summary: "ESQL: Remove estimated row size assertion"
area: ES|QL
type: bug
issues:
- 121535
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,28 @@ public void testFilterWithNullAndEval() {
}
}

public void testSortWithNull() {
try (EsqlQueryResponse results = run("row a = null | sort a")) {
logger.info(results);
assertEquals(1, getValuesList(results).size());
int countIndex = results.columns().indexOf(new ColumnInfoImpl("a", "null"));
assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a"));
assertThat(results.columns().stream().map(ColumnInfoImpl::type).toList(), contains(DataType.NULL));
assertNull(getValuesList(results).get(0).get(countIndex));
}
}

public void testStatsByNull() {
try (EsqlQueryResponse results = run("row a = null | stats by a")) {
logger.info(results);
assertEquals(1, getValuesList(results).size());
int countIndex = results.columns().indexOf(new ColumnInfoImpl("a", "null"));
assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a"));
assertThat(results.columns().stream().map(ColumnInfoImpl::type).toList(), contains(DataType.NULL));
assertNull(getValuesList(results).get(0).get(countIndex));
}
}

public void testStringLength() {
try (EsqlQueryResponse results = run("from test | eval l = length(color)")) {
logger.info(results);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public Integer estimatedRowSize() {
public PhysicalPlan estimateRowSize(State state) {
state.add(false, aggregates); // The groupings are contained within the aggregates
int size = state.consumeAllFields(true);
size = Math.max(size, 1);
return Objects.equals(this.estimatedRowSize, size)
? this
: new AggregateExec(source(), child(), groupings, aggregates, mode, intermediateAttributes, size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public PhysicalPlan estimateRowSize(State state) {
final boolean needsSortedDocIds = output.stream().anyMatch(a -> a.dataType() == DataType.DOC_DATA_TYPE);
state.add(needsSortedDocIds, output);
int size = state.consumeAllFields(true);
size = Math.max(size, 1);
return Objects.equals(this.estimatedRowSize, size) ? this : new TopNExec(source(), child(), order, limit, size);
}

Expand Down