Skip to content

Commit 105fe9d

Browse files
committed
more fix
1 parent 0c3c78d commit 105fe9d

File tree

2 files changed

+19
-40
lines changed

2 files changed

+19
-40
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,7 @@ public void testTripleExtractorPerField() {
637637

638638
/**
639639
*LimitExec[10000[INTEGER],8]
640-
* \_AggregateExec[[],[SUM(salary{f}#13460,true[BOOLEAN]) AS x#13454],FINAL,[$$x$sum{r}#13466, $$x$seen{r}#13467],8]
641-
* \_AggregateExec[[],[SUM(salary{f}#13460,true[BOOLEAN]) AS x#13454],INITIAL,[$$x$sum{r}#13466, $$x$seen{r}#13467],8]
640+
* \_AggregateExec[[],[SUM(salary{f}#13460,true[BOOLEAN]) AS x#13454],SINGLE,[$$x$sum{r}#13466, $$x$seen{r}#13467],8]
642641
* \_FilterExec[ROUND(emp_no{f}#13455) > 10[INTEGER]]
643642
* \_TopNExec[[Order[last_name{f}#13459,ASC,LAST]],10[INTEGER],58]
644643
* \_ExchangeExec[[emp_no{f}#13455, last_name{f}#13459, salary{f}#13460],false]
@@ -659,11 +658,10 @@ public void testExtractorForField() {
659658

660659
var optimized = optimizedPlan(plan);
661660
var limit = as(optimized, LimitExec.class);
662-
var aggregateFinal = as(limit.child(), AggregateExec.class);
663-
assertThat(aggregateFinal.estimatedRowSize(), equalTo(Long.BYTES));
661+
var agg = as(limit.child(), AggregateExec.class);
662+
assertThat(agg.estimatedRowSize(), equalTo(Long.BYTES));
664663

665-
var aggregatePartial = as(aggregateFinal.child(), AggregateExec.class);
666-
var filter = as(aggregatePartial.child(), FilterExec.class);
664+
var filter = as(agg.child(), FilterExec.class);
667665
var topN = as(filter.child(), TopNExec.class);
668666

669667
var exchange = asRemoteExchange(topN.child());
@@ -3143,8 +3141,7 @@ public void testProjectAwayAllColumnsWhenOnlyTheCountMatters() {
31433141
* Expects
31443142
*
31453143
* LimitExec[10000[INTEGER]]
3146-
* \_AggregateExec[[],[COUNT([2a][KEYWORD]) AS count(*)],FINAL,[count{r}#13, seen{r}#14],8]
3147-
* \_AggregateExec[[],[COUNT([2a][KEYWORD]) AS count(*)],INITIAL,[count{r}#13, seen{r}#14],8]
3144+
* \_AggregateExec[[],[COUNT([2a][KEYWORD]) AS count(*)],SINGLE,[count{r}#13, seen{r}#14],8]
31483145
* \_LimitExec[10[INTEGER]]
31493146
* \_ExchangeExec[[<all-fields-projected>{r:s}#28],false]
31503147
* \_ProjectExec[[<all-fields-projected>{r:s}#28]]
@@ -3159,9 +3156,9 @@ public void testProjectAwayAllColumnsWhenOnlyTheCountMattersInStats() {
31593156
"""));
31603157

31613158
var limit = as(plan, LimitExec.class);
3162-
var aggFinal = as(limit.child(), AggregateExec.class);
3163-
var aggInitial = as(aggFinal.child(), AggregateExec.class);
3164-
var limit10 = as(aggInitial.child(), LimitExec.class);
3159+
var agg = as(limit.child(), AggregateExec.class);
3160+
assertThat(agg.getMode(), equalTo(SINGLE));
3161+
var limit10 = as(agg.child(), LimitExec.class);
31653162

31663163
var exchange = as(limit10.child(), ExchangeExec.class);
31673164
var project = as(exchange.child(), ProjectExec.class);
@@ -3228,8 +3225,7 @@ public void testProjectAwayMvExpandColumnOrder() {
32283225
* ProjectExec[[a{r}#5]]
32293226
* \_EvalExec[[__a_SUM@81823521{r}#15 / __a_COUNT@31645621{r}#16 AS a]]
32303227
* \_LimitExec[10000[INTEGER]]
3231-
* \_AggregateExec[[],[SUM(salary{f}#11) AS __a_SUM@81823521, COUNT(salary{f}#11) AS __a_COUNT@31645621],FINAL,24]
3232-
* \_AggregateExec[[],[SUM(salary{f}#11) AS __a_SUM@81823521, COUNT(salary{f}#11) AS __a_COUNT@31645621],PARTIAL,16]
3228+
* \_AggregateExec[[],[SUM(salary{f}#11) AS __a_SUM@81823521, COUNT(salary{f}#11) AS __a_COUNT@31645621],SINGLE,24]
32333229
* \_LimitExec[10[INTEGER]]
32343230
* \_ExchangeExec[[],false]
32353231
* \_ProjectExec[[salary{f}#11]]
@@ -3249,11 +3245,9 @@ public void testAvgSurrogateFunctionAfterRenameAndLimit() {
32493245
var limit = as(eval.child(), LimitExec.class);
32503246
assertThat(limit.limit(), instanceOf(Literal.class));
32513247
assertThat(limit.limit().fold(FoldContext.small()), equalTo(10000));
3252-
var aggFinal = as(limit.child(), AggregateExec.class);
3253-
assertThat(aggFinal.getMode(), equalTo(FINAL));
3254-
var aggPartial = as(aggFinal.child(), AggregateExec.class);
3255-
assertThat(aggPartial.getMode(), equalTo(INITIAL));
3256-
limit = as(aggPartial.child(), LimitExec.class);
3248+
var agg = as(limit.child(), AggregateExec.class);
3249+
assertThat(agg.getMode(), equalTo(SINGLE));
3250+
limit = as(agg.child(), LimitExec.class);
32573251
assertThat(limit.limit(), instanceOf(Literal.class));
32583252
assertThat(limit.limit().fold(FoldContext.small()), equalTo(10));
32593253

@@ -3363,11 +3357,9 @@ public void testGlobalAggFoldingOutput() {
33633357
var optimized = optimizedPlan(plan, stats);
33643358

33653359
var limit = as(optimized, LimitExec.class);
3366-
var aggFinal = as(limit.child(), AggregateExec.class);
3367-
var aggPartial = as(aggFinal.child(), AggregateExec.class);
3368-
// The partial aggregation's output is determined via AbstractPhysicalOperationProviders.intermediateAttributes()
3369-
assertThat(Expressions.names(aggPartial.output()), contains("$$c$count", "$$c$seen"));
3370-
limit = as(aggPartial.child(), LimitExec.class);
3360+
var agg = as(limit.child(), AggregateExec.class);
3361+
assertThat(agg.getMode(), equalTo(SINGLE));
3362+
limit = as(agg.child(), LimitExec.class);
33713363
var exchange = as(limit.child(), ExchangeExec.class);
33723364
var project = as(exchange.child(), ProjectExec.class);
33733365
}
@@ -4093,8 +4085,7 @@ public void testSpatialTypesAndStatsUseDocValuesMultiAggregationsGrouped() {
40934085
* After local optimizations:
40944086
* <code>
40954087
* LimitExec[1000[INTEGER]]
4096-
* \_AggregateExec[[],[SPATIALCENTROID(centroid{r}#4) AS centroid, SUM(count{r}#6) AS count],FINAL,58]
4097-
* \_AggregateExec[[],[SPATIALCENTROID(centroid{r}#4) AS centroid, SUM(count{r}#6) AS count],PARTIAL,58]
4088+
* \_AggregateExec[[],[SPATIALCENTROID(centroid{r}#4) AS centroid, SUM(count{r}#6) AS count],SINGLE,58]
40984089
* \_AggregateExec[[scalerank{f}#16],[SPATIALCENTROID(location{f}#18) AS centroid, COUNT([2a][KEYWORD]) AS count],FINAL,58]
40994090
* \_ExchangeExec[[scalerank{f}#16, xVal{r}#19, xDel{r}#20, yVal{r}#21, yDel{r}#22, count{r}#23, count{r}#24, seen{r}#25],true]
41004091
* \_AggregateExec[[scalerank{f}#16],[SPATIALCENTROID(location{f}#18) AS centroid, COUNT([2a][KEYWORD]) AS count],PARTIAL,58]
@@ -4138,12 +4129,7 @@ public void testSpatialTypesAndStatsUseDocValuesMultiAggregationsGroupedAggregat
41384129
var optimized = optimizedPlan(plan);
41394130
limit = as(optimized, LimitExec.class);
41404131
agg = as(limit.child(), AggregateExec.class);
4141-
assertThat("Aggregation is FINAL", agg.getMode(), equalTo(FINAL));
4142-
assertThat("No groupings in aggregation", agg.groupings().size(), equalTo(0));
4143-
assertAggregation(agg, "count", Sum.class);
4144-
assertAggregation(agg, "centroid", SpatialCentroid.class, GEO_POINT, FieldExtractPreference.NONE);
4145-
agg = as(agg.child(), AggregateExec.class);
4146-
assertThat("Aggregation is PARTIAL", agg.getMode(), equalTo(INITIAL));
4132+
assertThat("Aggregation is SINGLE", agg.getMode(), equalTo(SINGLE));
41474133
assertThat("No groupings in aggregation", agg.groupings().size(), equalTo(0));
41484134
assertAggregation(agg, "count", Sum.class);
41494135
assertAggregation(agg, "centroid", SpatialCentroid.class, GEO_POINT, FieldExtractPreference.NONE);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/ReplaceRoundToWithQueryAndTagsTests.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
import java.util.stream.Collectors;
5656

5757
import static org.elasticsearch.compute.aggregation.AggregatorMode.FINAL;
58-
import static org.elasticsearch.compute.aggregation.AggregatorMode.INITIAL;
58+
import static org.elasticsearch.compute.aggregation.AggregatorMode.SINGLE;
5959
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
6060
import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
6161
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
@@ -379,19 +379,12 @@ public void testDateTruncBucketNotTransformToQueryAndTagsWithFork() {
379379

380380
LimitExec limit = as(plan, LimitExec.class);
381381
AggregateExec agg = as(limit.child(), AggregateExec.class);
382-
assertThat(agg.getMode(), is(FINAL));
382+
assertThat(agg.getMode(), is(SINGLE));
383383
List<? extends Expression> groupings = agg.groupings();
384384
NamedExpression grouping = as(groupings.get(0), NamedExpression.class);
385385
assertEquals("x", grouping.name());
386386
assertEquals(DataType.DATETIME, grouping.dataType());
387387
assertEquals(List.of("count(*)", "x"), Expressions.names(agg.aggregates()));
388-
agg = as(agg.child(), AggregateExec.class);
389-
assertThat(agg.getMode(), is(INITIAL));
390-
groupings = agg.groupings();
391-
grouping = as(groupings.get(0), NamedExpression.class);
392-
assertEquals("x", grouping.name());
393-
assertEquals(DataType.DATETIME, grouping.dataType());
394-
assertEquals(List.of("count(*)", "x"), Expressions.names(agg.aggregates()));
395388
EvalExec eval = as(agg.child(), EvalExec.class);
396389
List<Alias> aliases = eval.fields();
397390
assertEquals(1, aliases.size());

0 commit comments

Comments
 (0)