Skip to content

Commit f7b0523

Browse files
committed
[ES|QL] Register AggregateMetricDoubleLiteral
This literal was not previously being registered because it was primarily being used in testing code, but when aggregate_metric_double is folded it is used as the java object representation, so it requires registering.
1 parent aae1ffc commit f7b0523

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ public String getLabel() {
206206
}
207207
}
208208

209+
/**
210+
* Literal to represent AggregateMetricDouble and primarily used for testing and during folding.
211+
* For all other purposes it is preferred to use the builders over the literal for generating blocks when possible.
212+
*/
209213
public record AggregateMetricDoubleLiteral(Double min, Double max, Double sum, Integer count) implements GenericNamedWriteable {
210214
public AggregateMetricDoubleLiteral {
211215
min = (min == null || min.isNaN()) ? null : min;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
package org.elasticsearch.xpack.esql.expression;
99

1010
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
11+
import org.elasticsearch.compute.data.AggregateMetricDoubleBlockBuilder;
12+
import org.elasticsearch.plugins.SearchPlugin;
1113
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1214
import org.elasticsearch.xpack.esql.core.expression.ExpressionCoreWritables;
1315
import org.elasticsearch.xpack.esql.expression.function.UnsupportedAttribute;
@@ -123,6 +125,12 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
123125
return entries;
124126
}
125127

128+
public static List<SearchPlugin.GenericNamedWriteableSpec> getGenericNamedWriteables() {
129+
List<SearchPlugin.GenericNamedWriteableSpec> entries = new ArrayList<>();
130+
entries.addAll(literals());
131+
return entries;
132+
}
133+
126134
public static List<NamedWriteableRegistry.Entry> attributes() {
127135
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
128136
entries.addAll(ExpressionCoreWritables.attributes());
@@ -265,4 +273,13 @@ private static List<NamedWriteableRegistry.Entry> fullText() {
265273
private static List<NamedWriteableRegistry.Entry> vector() {
266274
return VectorWritables.getNamedWritables();
267275
}
276+
277+
public static List<SearchPlugin.GenericNamedWriteableSpec> literals() {
278+
return List.of(
279+
new SearchPlugin.GenericNamedWriteableSpec(
280+
"AggregateMetricDoubleLiteral",
281+
AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral::new
282+
)
283+
);
284+
}
268285
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlPlugin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.elasticsearch.plugins.ActionPlugin;
4343
import org.elasticsearch.plugins.ExtensiblePlugin;
4444
import org.elasticsearch.plugins.Plugin;
45+
import org.elasticsearch.plugins.SearchPlugin;
4546
import org.elasticsearch.rest.RestController;
4647
import org.elasticsearch.rest.RestHandler;
4748
import org.elasticsearch.threadpool.ExecutorBuilder;
@@ -90,7 +91,7 @@
9091
import java.util.function.Predicate;
9192
import java.util.function.Supplier;
9293

93-
public class EsqlPlugin extends Plugin implements ActionPlugin, ExtensiblePlugin {
94+
public class EsqlPlugin extends Plugin implements ActionPlugin, ExtensiblePlugin, SearchPlugin {
9495
public static final boolean INLINE_STATS_FEATURE_FLAG = new FeatureFlag("esql_inline_stats").isEnabled();
9596

9697
public static final String ESQL_WORKER_THREAD_POOL_NAME = "esql_worker";
@@ -371,4 +372,9 @@ public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
371372
public void loadExtensions(ExtensionLoader loader) {
372373
extraCheckerProviders.addAll(loader.loadExtensions(PlanCheckerProvider.class));
373374
}
375+
376+
@Override
377+
public List<SearchPlugin.GenericNamedWriteableSpec> getGenericNamedWriteables() {
378+
return ExpressionWritables.getGenericNamedWriteables();
379+
}
374380
}

0 commit comments

Comments
 (0)