Skip to content

Commit be8357e

Browse files
committed
rename sampleId -> bucketId
1 parent ed675f6 commit be8357e

File tree

1 file changed

+12
-12
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/approximate

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -298,32 +298,32 @@ private LogicalPlan approximatePlan(double sampleProbability) {
298298
return new Sample(Source.EMPTY, Literal.fromDouble(Source.EMPTY, sampleProbability), plan);
299299
} else if (encounteredStats.get() == false && plan instanceof Aggregate aggregate) {
300300
encounteredStats.set(true);
301-
Alias sampleId = new Alias(
301+
Alias bucketId = new Alias(
302302
Source.EMPTY,
303-
".sample_id",
303+
".bucket_id",
304304
new MvAppend(
305305
Source.EMPTY,
306306
Literal.integer(Source.EMPTY, -1),
307307
new Random(Source.EMPTY, Literal.integer(Source.EMPTY, BUCKET_COUNT))
308308
)
309309
);
310-
Eval addSampleId = new Eval(Source.EMPTY, aggregate.child(), List.of(sampleId));
310+
Eval addBucketId = new Eval(Source.EMPTY, aggregate.child(), List.of(bucketId));
311311
List<NamedExpression> aggregates = new ArrayList<>();
312312
for (NamedExpression aggr : aggregate.aggregates()) {
313313
if (aggr instanceof Alias alias && alias.child() instanceof AggregateFunction) {
314-
aggregates.add(new Alias(Source.EMPTY, ".sampled-" + alias.name(), alias.child()));
314+
aggregates.add(new Alias(Source.EMPTY, ".bucketed-" + alias.name(), alias.child()));
315315
} else {
316316
aggregates.add(aggr);
317317
}
318318
}
319319
List<Expression> groupings = new ArrayList<>(aggregate.groupings());
320-
groupings.add(sampleId.toAttribute());
321-
aggregates.add(sampleId.toAttribute());
322-
Aggregate aggregateWithSampledId = (Aggregate) aggregate.with(addSampleId, groupings, aggregates)
320+
groupings.add(bucketId.toAttribute());
321+
aggregates.add(bucketId.toAttribute());
322+
Aggregate aggregateWithBucketId = (Aggregate) aggregate.with(addBucketId, groupings, aggregates)
323323
.transformExpressionsOnlyUp(
324324
expr -> expr instanceof NeedsSampleCorrection nsc ? nsc.sampleCorrection(
325325
new Case(Source.EMPTY,
326-
new Equals(Source.EMPTY, sampleId.toAttribute(), Literal.integer(Source.EMPTY, -1)),
326+
new Equals(Source.EMPTY, bucketId.toAttribute(), Literal.integer(Source.EMPTY, -1)),
327327
List.of(
328328
Literal.fromDouble(Source.EMPTY, sampleProbability),
329329
Literal.fromDouble(Source.EMPTY, sampleProbability / BUCKET_COUNT)
@@ -333,7 +333,7 @@ private LogicalPlan approximatePlan(double sampleProbability) {
333333
aggregates = new ArrayList<>();
334334
for (int i = 0; i < aggregate.aggregates().size(); i++) {
335335
NamedExpression aggr = aggregate.aggregates().get(i);
336-
NamedExpression sampledAggr = aggregateWithSampledId.aggregates().get(i);
336+
NamedExpression sampledAggr = aggregateWithBucketId.aggregates().get(i);
337337
if (aggr instanceof Alias alias && alias.child() instanceof AggregateFunction aggFn) {
338338
// TODO: probably filter low non-empty bucket counts. They're inaccurate and for skew, you need >=3.
339339
aggregates.add(
@@ -343,12 +343,12 @@ private LogicalPlan approximatePlan(double sampleProbability) {
343343
new Min(
344344
Source.EMPTY,
345345
sampledAggr.toAttribute(),
346-
new Equals(Source.EMPTY, sampleId.toAttribute(), Literal.integer(Source.EMPTY, -1))
346+
new Equals(Source.EMPTY, bucketId.toAttribute(), Literal.integer(Source.EMPTY, -1))
347347
),
348348
new Top(
349349
Source.EMPTY,
350350
sampledAggr.toAttribute(),
351-
new NotEquals(Source.EMPTY, sampleId.toAttribute(), Literal.integer(Source.EMPTY, -1)),
351+
new NotEquals(Source.EMPTY, bucketId.toAttribute(), Literal.integer(Source.EMPTY, -1)),
352352
Literal.integer(Source.EMPTY, BUCKET_COUNT),
353353
Literal.keyword(Source.EMPTY, "ASC")
354354
),
@@ -363,7 +363,7 @@ private LogicalPlan approximatePlan(double sampleProbability) {
363363
}
364364
plan = new Aggregate(
365365
Source.EMPTY,
366-
aggregateWithSampledId,
366+
aggregateWithBucketId,
367367
aggregate.groupings().stream().map(e -> e instanceof Alias a ? a.toAttribute() : e).toList(),
368368
aggregates
369369
);

0 commit comments

Comments
 (0)