Skip to content

Commit 2133560

Browse files
committed
Don't push sample correction through limit
1 parent 141c0dc commit 2133560

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/ApplySampleCorrections.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.xpack.esql.core.util.Holder;
1212
import org.elasticsearch.xpack.esql.expression.function.aggregate.HasSampleCorrection;
1313
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
14+
import org.elasticsearch.xpack.esql.plan.logical.Limit;
1415
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
1516
import org.elasticsearch.xpack.esql.plan.logical.Sample;
1617
import org.elasticsearch.xpack.esql.rule.Rule;
@@ -24,6 +25,9 @@ public LogicalPlan apply(LogicalPlan logicalPlan) {
2425
if (plan instanceof Sample sample) {
2526
sampleProbability.set(sample.probability());
2627
}
28+
if (plan instanceof Limit) {
29+
sampleProbability.set(null);
30+
}
2731
if (plan instanceof Aggregate && sampleProbability.get() != null) {
2832
plan = plan.transformExpressionsOnly(
2933
e -> e instanceof HasSampleCorrection hsc && hsc.isSampleCorrected() == false

0 commit comments

Comments
 (0)