Skip to content

Commit cb6b571

Browse files
committed
Add node reduction capability
1 parent 771fe53 commit cb6b571

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,11 @@ public enum Cap {
17911791
*/
17921792
FN_MV_INTERSECTION,
17931793

1794+
/**
1795+
* Enables late materialization on node reduce. See also QueryPragmas.NODE_LEVEL_REDUCTION
1796+
*/
1797+
ENABLE_REDUCE_NODE_LATE_MATERIALIZATION(Build.current().isSnapshot()),
1798+
17941799
// Last capability should still have a comma for fewer merge conflicts when adding new ones :)
17951800
// This comment prevents the semicolon from being on the previous capability when Spotless formats the file.
17961801
;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.elasticsearch.transport.TransportRequestHandler;
4949
import org.elasticsearch.transport.TransportRequestOptions;
5050
import org.elasticsearch.transport.TransportService;
51+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
5152
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
5253
import org.elasticsearch.xpack.esql.plan.physical.ExchangeSinkExec;
5354
import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan;
@@ -192,7 +193,8 @@ protected void sendRequest(
192193
final boolean sameNodeAsCoordinator = transportService.getLocalNode()
193194
.getId()
194195
.equals(connection.getNode().getId());
195-
boolean enableReduceNodeLateMaterialization = Build.current().isSnapshot();
196+
boolean enableReduceNodeLateMaterialization = EsqlCapabilities.Cap.ENABLE_REDUCE_NODE_LATE_MATERIALIZATION
197+
.isEnabled();
196198
var dataNodeRequest = new DataNodeRequest(
197199
childSessionId,
198200
configuration,

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package org.elasticsearch.xpack.esql.optimizer;
99

1010
import org.apache.lucene.util.BytesRef;
11-
import org.elasticsearch.Build;
1211
import org.elasticsearch.common.io.stream.StreamOutput;
1312
import org.elasticsearch.common.util.Maps;
1413
import org.elasticsearch.index.IndexMode;
@@ -2041,7 +2040,7 @@ private static PhysicalPlan physicalPlan(LogicalPlan logicalPlan, Analyzer analy
20412040
}
20422041

20432042
public void testReductionPlanForTopNWithPushedDownFunctions() {
2044-
assumeTrue("Reduction is just enabled for snapshot builds", Build.current().isSnapshot());
2043+
assumeTrue("Node reduction must be enabled", EsqlCapabilities.Cap.ENABLE_REDUCE_NODE_LATE_MATERIALIZATION.isEnabled());
20452044
var query = String.format(Locale.ROOT, """
20462045
FROM test_all
20472046
| EVAL score = V_DOT_PRODUCT(dense_vector, [1.0, 2.0, 3.0])
@@ -2104,7 +2103,7 @@ public void testReductionPlanForTopNWithPushedDownFunctions() {
21042103
}
21052104

21062105
public void testReductionPlanForTopNWithPushedDownFunctionsInOrder() {
2107-
assumeTrue("Reduction is just enabled for snapshot builds", Build.current().isSnapshot());
2106+
assumeTrue("Node reduction must be enabled", EsqlCapabilities.Cap.ENABLE_REDUCE_NODE_LATE_MATERIALIZATION.isEnabled());
21082107
var query = String.format(Locale.ROOT, """
21092108
FROM test_all
21102109
| EVAL fieldLength = LENGTH(text)

0 commit comments

Comments
 (0)