Skip to content

Commit 837cf7b

Browse files
committed
Make ES|QL SAMPLE not a pipeline breaker
1 parent 057d78c commit 837cf7b

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/mapper/LocalMapper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.elasticsearch.xpack.esql.plan.logical.LeafPlan;
1818
import org.elasticsearch.xpack.esql.plan.logical.Limit;
1919
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
20-
import org.elasticsearch.xpack.esql.plan.logical.Sample;
2120
import org.elasticsearch.xpack.esql.plan.logical.TopN;
2221
import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan;
2322
import org.elasticsearch.xpack.esql.plan.logical.join.Join;
@@ -29,7 +28,6 @@
2928
import org.elasticsearch.xpack.esql.plan.physical.LocalSourceExec;
3029
import org.elasticsearch.xpack.esql.plan.physical.LookupJoinExec;
3130
import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan;
32-
import org.elasticsearch.xpack.esql.plan.physical.SampleExec;
3331
import org.elasticsearch.xpack.esql.plan.physical.TopNExec;
3432

3533
import java.util.List;
@@ -71,7 +69,6 @@ private PhysicalPlan mapUnary(UnaryPlan unary) {
7169
//
7270
// Pipeline breakers
7371
//
74-
7572
if (unary instanceof Aggregate aggregate) {
7673
List<Attribute> intermediate = MapperUtils.intermediateAttributes(aggregate);
7774
return MapperUtils.aggExec(aggregate, mappedChild, AggregatorMode.INITIAL, intermediate);
@@ -85,14 +82,9 @@ private PhysicalPlan mapUnary(UnaryPlan unary) {
8582
return new TopNExec(topN.source(), mappedChild, topN.order(), topN.limit(), null);
8683
}
8784

88-
if (unary instanceof Sample sample) {
89-
return new SampleExec(sample.source(), mappedChild, sample.probability());
90-
}
91-
9285
//
9386
// Pipeline operators
9487
//
95-
9688
return MapperUtils.mapUnary(unary, mappedChild);
9789
}
9890

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/mapper/Mapper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.elasticsearch.xpack.esql.plan.logical.Limit;
2222
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
2323
import org.elasticsearch.xpack.esql.plan.logical.PipelineBreaker;
24-
import org.elasticsearch.xpack.esql.plan.logical.Sample;
2524
import org.elasticsearch.xpack.esql.plan.logical.TopN;
2625
import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan;
2726
import org.elasticsearch.xpack.esql.plan.logical.inference.Rerank;
@@ -37,7 +36,6 @@
3736
import org.elasticsearch.xpack.esql.plan.physical.LookupJoinExec;
3837
import org.elasticsearch.xpack.esql.plan.physical.MergeExec;
3938
import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan;
40-
import org.elasticsearch.xpack.esql.plan.physical.SampleExec;
4139
import org.elasticsearch.xpack.esql.plan.physical.TopNExec;
4240
import org.elasticsearch.xpack.esql.plan.physical.UnaryExec;
4341
import org.elasticsearch.xpack.esql.plan.physical.inference.RerankExec;
@@ -187,12 +185,6 @@ private PhysicalPlan mapUnary(UnaryPlan unary) {
187185
);
188186
}
189187

190-
// TODO: share code with local LocalMapper?
191-
if (unary instanceof Sample sample) {
192-
mappedChild = addExchangeForFragment(sample, mappedChild);
193-
return new SampleExec(sample.source(), mappedChild, sample.probability());
194-
}
195-
196188
//
197189
// Pipeline operators
198190
//

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/mapper/MapperUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.xpack.esql.plan.logical.MvExpand;
2626
import org.elasticsearch.xpack.esql.plan.logical.Project;
2727
import org.elasticsearch.xpack.esql.plan.logical.RrfScoreEval;
28+
import org.elasticsearch.xpack.esql.plan.logical.Sample;
2829
import org.elasticsearch.xpack.esql.plan.logical.TimeSeriesAggregate;
2930
import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan;
3031
import org.elasticsearch.xpack.esql.plan.logical.inference.Completion;
@@ -43,6 +44,7 @@
4344
import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan;
4445
import org.elasticsearch.xpack.esql.plan.physical.ProjectExec;
4546
import org.elasticsearch.xpack.esql.plan.physical.RrfScoreEvalExec;
47+
import org.elasticsearch.xpack.esql.plan.physical.SampleExec;
4648
import org.elasticsearch.xpack.esql.plan.physical.ShowExec;
4749
import org.elasticsearch.xpack.esql.plan.physical.TimeSeriesAggregateExec;
4850
import org.elasticsearch.xpack.esql.plan.physical.inference.CompletionExec;
@@ -139,6 +141,10 @@ static PhysicalPlan mapUnary(UnaryPlan p, PhysicalPlan child) {
139141
return new RrfScoreEvalExec(rrf.source(), child, rrf.scoreAttribute(), rrf.forkAttribute());
140142
}
141143

144+
if (p instanceof Sample sample) {
145+
return new SampleExec(sample.source(), child, sample.probability());
146+
}
147+
142148
return unsupported(p);
143149
}
144150

0 commit comments

Comments
 (0)