diff --git a/muted-tests.yml b/muted-tests.yml index 05235d19eba24..f68969baef276 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -501,9 +501,6 @@ tests: - class: org.elasticsearch.readiness.ReadinessClusterIT method: testReadinessDuringRestartsNormalOrder issue: https://github.com/elastic/elasticsearch/issues/136955 -- class: org.elasticsearch.xpack.esql.expression.function.aggregate.DimensionValuesByteRefGroupingAggregatorFunctionTests - method: testSimple - issue: https://github.com/elastic/elasticsearch/issues/137378 - class: org.elasticsearch.xpack.ilm.TimeSeriesDataStreamsIT method: testSearchableSnapshotAction issue: https://github.com/elastic/elasticsearch/issues/137167 diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/DimensionValuesByteRefGroupingAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/DimensionValuesByteRefGroupingAggregatorFunction.java index 52e543b5ab175..4abffb70411c9 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/DimensionValuesByteRefGroupingAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/DimensionValuesByteRefGroupingAggregatorFunction.java @@ -237,16 +237,17 @@ public void addIntermediateInput(int positionOffset, IntVector groups, Page page @Override public void evaluateIntermediate(Block[] blocks, int offset, IntVector selected) { int positionCount = selected.getPositionCount(); - boolean allSelected = positionCount == maxGroupId + 1; + boolean allSelected = positionCount > maxGroupId; if (allSelected) { for (int i = 0; i < selected.getPositionCount(); i++) { - if (selected.getInt(i) == i) { + if (selected.getInt(i) != i) { allSelected = false; break; } } } if (allSelected) { + fillNullsUpTo(positionCount); blocks[offset] = builder.build(); return; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/DimensionValuesByteRefGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/DimensionValuesByteRefGroupingAggregatorFunctionTests.java index 704736c973687..4cf63855bbeef 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/DimensionValuesByteRefGroupingAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/DimensionValuesByteRefGroupingAggregatorFunctionTests.java @@ -77,14 +77,17 @@ public void testSimple() { randomFrom(AggregatorMode.INITIAL, AggregatorMode.SINGLE), List.of(0) ); + final List groupSpecs; + if (randomBoolean()) { + // Use IntBlockHash; reserves 0 for null values + groupSpecs = List.of(new BlockHash.GroupSpec(1, ElementType.INT)); + } else { + // Use PackedValuesBlockHash; does not reserve 0 for null values + groupSpecs = List.of(new BlockHash.GroupSpec(1, ElementType.INT), new BlockHash.GroupSpec(1, ElementType.INT)); + } HashAggregationOperator hashAggregationOperator = new HashAggregationOperator( List.of(aggregatorFactory), - () -> BlockHash.build( - List.of(new BlockHash.GroupSpec(1, ElementType.INT)), - driverContext.blockFactory(), - randomIntBetween(1, 1024), - randomBoolean() - ), + () -> BlockHash.build(groupSpecs, driverContext.blockFactory(), randomIntBetween(1, 1024), randomBoolean()), driverContext ); List outputPages = new ArrayList<>(); @@ -99,7 +102,7 @@ public void testSimple() { Map> actualValues = new HashMap<>(); for (Page out : outputPages) { IntBlock groups = out.getBlock(0); - BytesRefBlock valuesBlock = out.getBlock(1); + BytesRefBlock valuesBlock = out.getBlock(groupSpecs.size()); for (int p = 0; p < out.getPositionCount(); p++) { int group = groups.getInt(p); int valueCount = valuesBlock.getValueCount(p);