Class ReplaceSampledStatsByExactStats
java.lang.Object
org.elasticsearch.xpack.esql.rule.Rule<SampledAggregateExec,PhysicalPlan>
org.elasticsearch.xpack.esql.rule.ParameterizedRule<SampledAggregateExec,PhysicalPlan,LocalPhysicalOptimizerContext>
org.elasticsearch.xpack.esql.optimizer.PhysicalOptimizerRules.ParameterizedOptimizerRule<SampledAggregateExec,LocalPhysicalOptimizerContext>
org.elasticsearch.xpack.esql.optimizer.rules.physical.local.ReplaceSampledStatsByExactStats
public class ReplaceSampledStatsByExactStats
extends PhysicalOptimizerRules.ParameterizedOptimizerRule<SampledAggregateExec,LocalPhysicalOptimizerContext>
If the original aggregate wrapped by the sampled aggregate can be
pushed down to Lucene (so that it will execute exact and fast), sampling
should be skipped and the original aggregate should be executed.
In that case, this rule replaces the sampled aggregate by a regular aggregate and replicates the exact intermediate values to all bucket intermediates. The plan:
FROM data | EVAL bucket_id=... | SAMPLED_STATS original_aggs, bucket_aggs
is (loosely) transformed into:
FROM data | ES_STATS_QUERY original_aggs | EVAL bucket_aggs=original_aggs
Replicating the exact value to all buckets makes exact data appear as
zero-variance sampled data, so confidence intervals remain correct in
mixed exact/sampled scenarios (where some nodes push down exact stats and
others use sampling).-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PhysicalPlanrule(SampledAggregateExec plan, LocalPhysicalOptimizerContext context) Methods inherited from class org.elasticsearch.xpack.esql.optimizer.PhysicalOptimizerRules.ParameterizedOptimizerRule
applyMethods inherited from class org.elasticsearch.xpack.esql.rule.ParameterizedRule
apply
-
Constructor Details
-
ReplaceSampledStatsByExactStats
public ReplaceSampledStatsByExactStats()
-
-
Method Details
-
rule
- Specified by:
rulein classPhysicalOptimizerRules.ParameterizedOptimizerRule<SampledAggregateExec,LocalPhysicalOptimizerContext>
-