File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 88package org .elasticsearch .xpack .esql .optimizer .rules .logical ;
99
1010import org .elasticsearch .xpack .esql .core .expression .Expression ;
11+ import org .elasticsearch .xpack .esql .core .util .Holder ;
1112import org .elasticsearch .xpack .esql .expression .function .aggregate .AggregateFunction ;
13+ import org .elasticsearch .xpack .esql .plan .logical .Aggregate ;
1214import org .elasticsearch .xpack .esql .plan .logical .LogicalPlan ;
1315import org .elasticsearch .xpack .esql .plan .logical .RandomSample ;
1416import org .elasticsearch .xpack .esql .rule .Rule ;
1517
16- import java .util .concurrent .atomic .AtomicReference ;
17-
1818public class PropagateSampleFrequencyToAggs extends Rule <LogicalPlan , LogicalPlan > {
1919 @ Override
2020 public LogicalPlan apply (LogicalPlan logicalPlan ) {
21- AtomicReference <Expression > sampleProbability = new AtomicReference <>(null );
21+ Holder <Expression > sampleProbability = new Holder <>(null );
2222 return logicalPlan .transformUp (plan -> {
2323 if (plan instanceof RandomSample randomSample ) {
2424 sampleProbability .set (randomSample .probability ());
2525 }
26- if (sampleProbability .get () != null ) {
26+ if (plan instanceof Aggregate && sampleProbability .get () != null ) {
2727 plan = plan .transformExpressionsOnly (AggregateFunction .class , af -> af .correctForSampling (sampleProbability .get ()));
28+ sampleProbability .set (null );
2829 }
2930 return plan ;
3031 });
You can’t perform that action at this time.
0 commit comments