Skip to content

Commit 34832df

Browse files
committed
Add reliable computation
1 parent 0954e9d commit 34832df

File tree

7 files changed

+536
-5
lines changed

7 files changed

+536
-5
lines changed

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/approximate/ReliableDoubleEvaluator.java

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/approximate/ReliableIntEvaluator.java

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/approximate/ReliableLongEvaluator.java

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.elasticsearch.xpack.esql.expression.function.aggregate.WeightedAvg;
3333
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
3434
import org.elasticsearch.xpack.esql.expression.function.scalar.approximate.ConfidenceInterval;
35+
import org.elasticsearch.xpack.esql.expression.function.scalar.approximate.Reliable;
3536
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToLong;
3637
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvAppend;
3738
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvContains;
@@ -581,7 +582,7 @@ private LogicalPlan approximatePlan(double sampleProbability) {
581582
});
582583

583584
// Compute the confidence interval for all output fields that have buckets.
584-
List<Alias> confidenceIntervals = new ArrayList<>();
585+
List<Alias> confidenceIntervalsAndReliable = new ArrayList<>();
585586
for (Attribute output : logicalPlan.output()) {
586587
if (fieldBuckets.containsKey(output.id())) {
587588
List<Alias> buckets = fieldBuckets.get(output.id());
@@ -591,16 +592,23 @@ private LogicalPlan approximatePlan(double sampleProbability) {
591592
for (int i = 1; i < BUCKET_COUNT; i++) {
592593
bucketsMv = new MvAppend(Source.EMPTY, bucketsMv, buckets.get(i).toAttribute());
593594
}
594-
confidenceIntervals.add(
595+
confidenceIntervalsAndReliable.add(
595596
new Alias(
596597
Source.EMPTY,
597598
"CONFIDENCE_INTERVAL(" + output.name() + ")",
598599
new ConfidenceInterval(Source.EMPTY, output, bucketsMv)
599600
)
600601
);
602+
confidenceIntervalsAndReliable.add(
603+
new Alias(
604+
Source.EMPTY,
605+
"RELIABLE(" + output.name() + ")",
606+
new Reliable(Source.EMPTY, bucketsMv)
607+
)
608+
);
601609
}
602610
}
603-
approximatePlan = new Eval(Source.EMPTY, approximatePlan, confidenceIntervals);
611+
approximatePlan = new Eval(Source.EMPTY, approximatePlan, confidenceIntervalsAndReliable);
604612

605613
// Finally, drop all bucket fields from the output.
606614
Set<Attribute> dropAttributes = fieldBuckets.values()

0 commit comments

Comments
 (0)