-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[ES|QL] Fix aggregate_metric_double sorting and mv_expand issues #131658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
limotova
merged 13 commits into
elastic:main
from
limotova:agg-metric-sorting-from-multiple-indices
Jul 26, 2025
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c0fe071
[ES|QL] Fix aggregate_metric_double sorting and mv_expand issues
limotova 1c904d7
Update docs/changelog/131658.yaml
limotova 13ab33f
add ExtractorTests and make ConstantNullBlock implement AggregateMetr…
limotova f36d1ac
Merge branch 'main' into agg-metric-sorting-from-multiple-indices
limotova f739ae1
Merge branch 'main' into agg-metric-sorting-from-multiple-indices
limotova 667d549
Merge branch 'main' into agg-metric-sorting-from-multiple-indices
limotova a5f8ae6
change how agg metric block equals and hashcode is determined
limotova b19c517
rewrite equals, add parentheses
limotova 2fb844a
rewrite hashcode
limotova db8d2f7
Merge branch 'main' into agg-metric-sorting-from-multiple-indices
limotova 0b0f7c2
Merge branch 'main' into agg-metric-sorting-from-multiple-indices
limotova b367e39
add tests checking equality with null blocks for aggregate metric double
limotova 82fc6d4
fix wording: vectors -> blocks
limotova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...src/test/java/org/elasticsearch/compute/data/AggregateMetricDoubleBlockEqualityTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.compute.data; | ||
|
||
import org.elasticsearch.compute.test.ComputeTestCase; | ||
import org.elasticsearch.compute.test.TestBlockFactory; | ||
import org.elasticsearch.core.Releasables; | ||
|
||
import java.util.List; | ||
|
||
public class AggregateMetricDoubleBlockEqualityTests extends ComputeTestCase { | ||
|
||
static final BlockFactory blockFactory = TestBlockFactory.getNonBreakingInstance(); | ||
|
||
// TODO: Add additional tests | ||
|
||
public void testEmptyBlock() { | ||
// all these "empty" vectors should be equivalent | ||
var partialMetricBuilder = blockFactory.newAggregateMetricDoubleBlockBuilder(0); | ||
for (var subBuilder : List.of( | ||
partialMetricBuilder.min(), | ||
partialMetricBuilder.max(), | ||
partialMetricBuilder.sum(), | ||
partialMetricBuilder.count() | ||
)) { | ||
if (randomBoolean()) { | ||
subBuilder.appendNull(); | ||
} else { | ||
if (subBuilder instanceof DoubleBlockBuilder doubleBlockBuilder) { | ||
doubleBlockBuilder.appendDouble(0.0); | ||
} else if (subBuilder instanceof IntBlockBuilder intBlockBuilder) { | ||
intBlockBuilder.appendInt(0); | ||
} | ||
} | ||
} | ||
|
||
List<AggregateMetricDoubleBlock> blocks = List.of( | ||
blockFactory.newAggregateMetricDoubleBlockBuilder(0).build(), | ||
blockFactory.newAggregateMetricDoubleBlockBuilder(0).appendNull().build().filter(), | ||
partialMetricBuilder.build().filter(), | ||
blockFactory.newConstantAggregateMetricDoubleBlock( | ||
new AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral(0.0, 0.0, 0.0, 0), | ||
0 | ||
).filter(), | ||
(ConstantNullBlock) blockFactory.newConstantNullBlock(0) | ||
); | ||
|
||
assertAllEquals(blocks); | ||
Releasables.close(blocks); | ||
} | ||
|
||
public void testSimpleBlockWithManyNulls() { | ||
int positions = randomIntBetween(1, 256); | ||
boolean grow = randomBoolean(); | ||
AggregateMetricDoubleBlockBuilder builder1 = blockFactory.newAggregateMetricDoubleBlockBuilder(grow ? 0 : positions); | ||
AggregateMetricDoubleBlockBuilder builder2 = blockFactory.newAggregateMetricDoubleBlockBuilder(grow ? 0 : positions); | ||
ConstantNullBlock.Builder builder3 = new ConstantNullBlock.Builder(blockFactory); | ||
for (int p = 0; p < positions; p++) { | ||
builder1.appendNull(); | ||
builder2.appendNull(); | ||
builder3.appendNull(); | ||
} | ||
AggregateMetricDoubleBlock block1 = builder1.build(); | ||
AggregateMetricDoubleBlock block2 = builder2.build(); | ||
Block block3 = builder3.build(); | ||
assertEquals(positions, block1.getPositionCount()); | ||
assertTrue(block1.mayHaveNulls()); | ||
assertTrue(block1.isNull(0)); | ||
|
||
List<Block> blocks = List.of(block1, block2, block3); | ||
assertAllEquals(blocks); | ||
} | ||
|
||
static void assertAllEquals(List<?> objs) { | ||
for (Object obj1 : objs) { | ||
for (Object obj2 : objs) { | ||
assertEquals(obj1, obj2); | ||
assertEquals(obj2, obj1); | ||
// equal objects must generate the same hash code | ||
assertEquals(obj1.hashCode(), obj2.hashCode()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am making a list of tests where AggregateMetricDoubleBlock is missing and making a github issue out of it and it is the first thing I will work on after I get this PR and the initial CSV tests PR merged in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test issue: #131951