Skip to content

Commit 4011b9f

Browse files
ES|QL: Fix BasicPageTests (elastic#136755)
1 parent e88cb33 commit 4011b9f

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,6 @@ tests:
585585
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
586586
method: testManyConcat
587587
issue: https://github.com/elastic/elasticsearch/issues/136728
588-
- class: org.elasticsearch.compute.data.BasicPageTests
589-
method: testEqualityAndHashCode
590-
issue: https://github.com/elastic/elasticsearch/issues/136753
591588
- class: org.elasticsearch.index.codec.vectors.es93.ES93HnswBinaryQuantizedBFloat16VectorsFormatTests
592589
method: testRandomWithUpdatesAndGraph
593590
issue: https://github.com/elastic/elasticsearch/issues/136767

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicPageTests.java

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,31 @@ public void testEqualityAndHashCode() throws IOException {
141141
};
142142

143143
final EqualsHashCodeTestUtils.MutateFunction<Page> mutatePageFunction = page -> {
144-
assert page.getPositionCount() > 0;
145-
Block[] blocks = new Block[page.getBlockCount()];
146-
int positions = randomInt(page.getPositionCount() - 1);
147-
for (int blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
148-
Block block = page.getBlock(blockIndex);
149-
blocks[blockIndex] = block.elementType()
150-
.newBlockBuilder(positions, TestBlockFactory.getNonBreakingInstance())
151-
.copyFrom(block, 0, positions)
152-
.build();
144+
if (page.getPositionCount() > 0) {
145+
Block[] blocks = new Block[page.getBlockCount()];
146+
int positions = randomInt(page.getPositionCount() - 1);
147+
for (int blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
148+
Block block = page.getBlock(blockIndex);
149+
blocks[blockIndex] = block.elementType()
150+
.newBlockBuilder(positions, TestBlockFactory.getNonBreakingInstance())
151+
.copyFrom(block, 0, positions)
152+
.build();
153+
}
154+
return new Page(positions, blocks);
155+
} else {
156+
Block[] blocks = new Block[page.getBlockCount() + 1];
157+
for (int blockIndex = 0; blockIndex < page.getBlockCount(); blockIndex++) {
158+
blocks[blockIndex] = page.getBlock(blockIndex);
159+
}
160+
161+
ElementType newBlockType = randomValueOtherThanMany(
162+
x -> x == ElementType.DOC || x == ElementType.COMPOSITE || x == ElementType.UNKNOWN,
163+
() -> randomFrom(ElementType.values())
164+
);
165+
166+
blocks[blocks.length - 1] = newBlockType.newBlockBuilder(0, TestBlockFactory.getNonBreakingInstance()).build();
167+
return new Page(0, blocks);
153168
}
154-
return new Page(positions, blocks);
155169
};
156170

157171
int positions = randomIntBetween(0, 512);

0 commit comments

Comments
 (0)