Skip to content

Commit f12b156

Browse files
committed
Fix more tests
1 parent bfd8e23 commit f12b156

File tree

7 files changed

+25
-4
lines changed

7 files changed

+25
-4
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/ExponentialHistogramArrayBlock.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ public double min() {
246246
return Double.NaN;
247247
}
248248

249+
@Override
250+
public double max() {
251+
// TODO: implement
252+
return Double.NaN;
253+
}
254+
249255
@Override
250256
public long ramBytesUsed() {
251257
return 0;

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/topn/TopNOperatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public void testCollectAllValues_RandomMultiValues() {
603603

604604
for (int type = 0; type < blocksCount; type++) {
605605
ElementType e = randomFrom(ElementType.values());
606-
if (e == ElementType.UNKNOWN || e == COMPOSITE || e == AGGREGATE_METRIC_DOUBLE) {
606+
if (e == ElementType.UNKNOWN || e == COMPOSITE || e == AGGREGATE_METRIC_DOUBLE || e == EXPONENTIAL_HISTOGRAM) {
607607
continue;
608608
}
609609
elementTypes.add(e);

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,13 +893,19 @@ public static Literal randomLiteral(DataType type) {
893893
}
894894
}
895895
case DENSE_VECTOR -> Arrays.asList(randomArray(10, 10, i -> new Float[10], ESTestCase::randomFloat));
896+
case EXPONENTIAL_HISTOGRAM -> new WriteableExponentialHistogram(randomExponentialHistogram());
896897
// TODO: implement
897-
case UNSUPPORTED, OBJECT, DOC_DATA_TYPE, TSID_DATA_TYPE, PARTIAL_AGG, EXPONENTIAL_HISTOGRAM -> throw new IllegalArgumentException(
898+
case UNSUPPORTED, OBJECT, DOC_DATA_TYPE, TSID_DATA_TYPE, PARTIAL_AGG -> throw new IllegalArgumentException(
898899
"can't make random values for [" + type.typeName() + "]"
899900
);
900901
}, type);
901902
}
902903

904+
private static ExponentialHistogram randomExponentialHistogram() {
905+
//TODO: implement properly with an actual histogram from random data
906+
return ExponentialHistogram.empty();
907+
}
908+
903909
static Version randomVersion() {
904910
// TODO degenerate versions and stuff
905911
return switch (between(0, 2)) {

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/JsonBackedExponentialHistogram.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ public double min() {
8080
return Double.NaN;
8181
}
8282

83+
@Override
84+
public double max() {
85+
// TODO: implement
86+
return Double.NaN;
87+
}
88+
8389
@Override
8490
public ZeroBucket zeroBucket() {
8591
//TODO: implement
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
package org.elasticsearch.compute.test;
8+
package org.elasticsearch.xpack.esql;
99

1010
import org.elasticsearch.TransportVersion;
1111
import org.elasticsearch.common.io.stream.GenericNamedWriteable;
@@ -27,7 +27,7 @@
2727
* so that it can be used e.g. in {@link org.elasticsearch.xpack.esql.core.expression.Literal}s.
2828
* Only intended for testing purposes.
2929
*/
30-
class WriteableExponentialHistogram extends AbstractExponentialHistogram implements GenericNamedWriteable {
30+
public class WriteableExponentialHistogram extends AbstractExponentialHistogram implements GenericNamedWriteable {
3131

3232
private static final String WRITEABLE_NAME = "test_exponential_histogram";
3333

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public static NamedWriteableRegistry writableRegistry() {
123123
AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral::new
124124
)
125125
);
126+
entries.add(WriteableExponentialHistogram.ENTRY);
126127
return new NamedWriteableRegistry(entries);
127128
}
128129
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/physical/AbstractPhysicalPlanSerializationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.common.settings.Settings;
1212
import org.elasticsearch.compute.data.AggregateMetricDoubleBlockBuilder;
1313
import org.elasticsearch.search.SearchModule;
14+
import org.elasticsearch.xpack.esql.WriteableExponentialHistogram;
1415
import org.elasticsearch.xpack.esql.core.tree.Node;
1516
import org.elasticsearch.xpack.esql.expression.ExpressionWritables;
1617
import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.Add;
@@ -53,6 +54,7 @@ protected final NamedWriteableRegistry getNamedWriteableRegistry() {
5354
entries.addAll(new SearchModule(Settings.EMPTY, List.of()).getNamedWriteables()); // Query builders
5455
entries.add(Add.ENTRY); // Used by the eval tests
5556
entries.add(AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral.ENTRY);
57+
entries.add(WriteableExponentialHistogram.ENTRY);
5658
return new NamedWriteableRegistry(entries);
5759
}
5860

0 commit comments

Comments
 (0)