Skip to content

Commit 4e7959c

Browse files
committed
rename RANDOM_SAMPLE -> SAMPLE
1 parent f03d2cc commit 4e7959c

34 files changed

+1289
-1295
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.util.Objects;
2626
import java.util.SplittableRandom;
2727

28-
public class RandomSampleOperator implements Operator {
28+
public class SampleOperator implements Operator {
2929

3030
private boolean finished;
3131
private final Deque<Page> outputPages;
@@ -39,7 +39,7 @@ public class RandomSampleOperator implements Operator {
3939
private long collectNanos;
4040
private long emitNanos;
4141

42-
public RandomSampleOperator(double probability, int seed) {
42+
public SampleOperator(double probability, int seed) {
4343
finished = false;
4444
outputPages = new LinkedList<>();
4545
SplittableRandom random = new SplittableRandom(seed);
@@ -50,13 +50,13 @@ public RandomSampleOperator(double probability, int seed) {
5050
public record Factory(double probability, int seed) implements OperatorFactory {
5151

5252
@Override
53-
public RandomSampleOperator get(DriverContext driverContext) {
54-
return new RandomSampleOperator(probability, seed);
53+
public SampleOperator get(DriverContext driverContext) {
54+
return new SampleOperator(probability, seed);
5555
}
5656

5757
@Override
5858
public String describe() {
59-
return "RandomSampleOperator[probability = " + probability + ", seed = " + seed + "]";
59+
return "SampleOperator[probability = " + probability + ", seed = " + seed + "]";
6060
}
6161
}
6262

@@ -139,7 +139,7 @@ public void close() {
139139

140140
@Override
141141
public String toString() {
142-
return "RandomSampleOperator[sampled = " + rowsEmitted + "/" + rowsCollected + "]";
142+
return "SampleOperator[sampled = " + rowsEmitted + "/" + rowsCollected + "]";
143143
}
144144

145145
@Override
@@ -153,7 +153,7 @@ private record Status(long collectNanos, long emitNanos, int pagesCollected, int
153153

154154
public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
155155
Operator.Status.class,
156-
"random_sample",
156+
"sample",
157157
Status::new
158158
);
159159

x-pack/plugin/esql/qa/testFixtures/src/main/resources/random_sample.csv-spec renamed to x-pack/plugin/esql/qa/testFixtures/src/main/resources/sample.csv-spec

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
// Tests focused on the RANDOM_SAMPLE command
1+
// Tests focused on the SAMPLE command
22

33
row
4-
required_capability: random_sample
4+
required_capability: sample
55

66
ROW x = 1
7-
| RANDOM_SAMPLE .99 9
7+
| SAMPLE .99 9
88
;
99

1010
x:integer
1111
1
1212
;
1313

1414
topN_PushedDown
15-
required_capability: random_sample
15+
required_capability: sample
1616

1717
FROM employees
18-
| RANDOM_SAMPLE .5 0
18+
| SAMPLE .5 0
1919
| SORT emp_no
2020
| LIMIT 5
2121
| STATS empNoMax = MAX(emp_no)
@@ -28,11 +28,11 @@ true
2828
;
2929

3030
topN_Operator
31-
required_capability: random_sample
31+
required_capability: sample
3232

3333
FROM employees
3434
| WHERE LENGTH(CONCAT(last_name, "foo")) > 3
35-
| RANDOM_SAMPLE .5 0
35+
| SAMPLE .5 0
3636
| SORT emp_no
3737
| LIMIT 5
3838
| STATS empNoMax = MAX(emp_no)
@@ -45,10 +45,10 @@ true
4545
;
4646

4747
aggCount_PushedDown
48-
required_capability: random_sample
48+
required_capability: sample
4949

5050
FROM employees
51-
| RANDOM_SAMPLE .5 123
51+
| SAMPLE .5 123
5252
| STATS count = COUNT(*)
5353
| EVAL correct = count > 50 AND count < 150
5454
| KEEP correct
@@ -59,11 +59,11 @@ true
5959
;
6060

6161
aggCount_Operator
62-
required_capability: random_sample
62+
required_capability: sample
6363

6464
FROM employees
6565
| WHERE LENGTH(CONCAT(last_name, "foo")) > 3
66-
| RANDOM_SAMPLE .5 123
66+
| SAMPLE .5 123
6767
| STATS count = COUNT(*)
6868
| EVAL correct = count > 50 AND count < 150
6969
| KEEP correct
@@ -74,10 +74,10 @@ true
7474
;
7575

7676
aggCountNoSeed_PushedDown
77-
required_capability: random_sample
77+
required_capability: sample
7878

7979
FROM employees
80-
| RANDOM_SAMPLE .5
80+
| SAMPLE .5
8181
| STATS count = COUNT(*)
8282
| EVAL correct = count > 50 AND count < 150
8383
| KEEP correct
@@ -88,11 +88,11 @@ true
8888
;
8989

9090
aggCountNoSeed_Operator
91-
required_capability: random_sample
91+
required_capability: sample
9292

9393
FROM employees
9494
| WHERE LENGTH(CONCAT(last_name, "foo")) > 3
95-
| RANDOM_SAMPLE .5
95+
| SAMPLE .5
9696
| STATS count = COUNT(*)
9797
| EVAL inRange = count > 50 AND count < 150
9898
| KEEP inRange
@@ -103,10 +103,10 @@ true
103103
;
104104

105105
withPostFilter_PushDown
106-
required_capability: random_sample
106+
required_capability: sample
107107

108108
FROM employees
109-
| RANDOM_SAMPLE .5 0
109+
| SAMPLE .5 0
110110
| WHERE emp_no > 10050
111111
| STATS count = COUNT(*)
112112
| EVAL correct = count > 20 AND count < 80
@@ -118,11 +118,11 @@ true
118118
;
119119

120120
withPostFilter_Operator
121-
required_capability: random_sample
121+
required_capability: sample
122122

123123
FROM employees
124124
| WHERE LENGTH(CONCAT(last_name, "foo")) > 3
125-
| RANDOM_SAMPLE .5 0
125+
| SAMPLE .5 0
126126
| WHERE emp_no > 10050
127127
| STATS count = COUNT(*)
128128
| EVAL correct = count > 20 AND count < 80
@@ -134,12 +134,12 @@ true
134134
;
135135

136136
combined_PushDown
137-
required_capability: random_sample
137+
required_capability: sample
138138

139139
FROM employees
140-
| RANDOM_SAMPLE .6 11
140+
| SAMPLE .6 11
141141
| EVAL e1 = emp_no + 1
142-
| RANDOM_SAMPLE .7 11111
142+
| SAMPLE .7 11111
143143
| STATS count = COUNT(e1)
144144
| EVAL correct = count > 50 AND count < 150
145145
| KEEP correct
@@ -150,13 +150,13 @@ true
150150
;
151151

152152
combined_Operator
153-
required_capability: random_sample
153+
required_capability: sample
154154

155155
FROM employees
156156
| WHERE LENGTH(CONCAT(last_name, "foo")) > 3
157-
| RANDOM_SAMPLE .6 11
157+
| SAMPLE .6 11
158158
| EVAL e1 = emp_no + 1
159-
| RANDOM_SAMPLE .7 11111
159+
| SAMPLE .7 11111
160160
| STATS count = COUNT(e1)
161161
| EVAL correct = count > 50 AND count < 150
162162
| KEEP correct
@@ -167,14 +167,14 @@ true
167167
;
168168

169169
combined2_PushDown
170-
required_capability: random_sample
170+
required_capability: sample
171171

172172
FROM employees
173-
| RANDOM_SAMPLE .6 11
173+
| SAMPLE .6 11
174174
| EVAL e1 = emp_no + 1
175-
| RANDOM_SAMPLE .7 11111
175+
| SAMPLE .7 11111
176176
| EVAL e1s = e1::KEYWORD
177-
| RANDOM_SAMPLE .1
177+
| SAMPLE .1
178178
| STATS count = COUNT(e1s)
179179
| EVAL correct = count > 0 AND count < 250
180180
| KEEP correct
@@ -185,15 +185,15 @@ true
185185
;
186186

187187
combined2_Operator
188-
required_capability: random_sample
188+
required_capability: sample
189189

190190
FROM employees
191191
| WHERE LENGTH(CONCAT(last_name, "foo")) > 3
192-
| RANDOM_SAMPLE .6 11
192+
| SAMPLE .6 11
193193
| EVAL e1 = emp_no + 1
194-
| RANDOM_SAMPLE .7 11111
194+
| SAMPLE .7 11111
195195
| EVAL e1s = e1::KEYWORD
196-
| RANDOM_SAMPLE .1
196+
| SAMPLE .1
197197
| STATS count = COUNT(e1s)
198198
| EVAL correct = count > 0 AND count < 250
199199
| KEEP correct

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.tokens

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ processingCommand
6262
| {this.isDevVersion()}? insistCommand
6363
| {this.isDevVersion()}? forkCommand
6464
| {this.isDevVersion()}? rrfCommand
65-
| {this.isDevVersion()}? randomSampleCommand
65+
| {this.isDevVersion()}? sampleCommand
6666
;
6767

6868
whereCommand
@@ -290,6 +290,6 @@ rrfCommand
290290
: DEV_RRF
291291
;
292292

293-
randomSampleCommand
294-
: DEV_RANDOM_SAMPLE probability=decimalValue seed=integerValue?
293+
sampleCommand
294+
: DEV_SAMPLE probability=decimalValue seed=integerValue?
295295
;

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.tokens

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/antlr/lexer/Expression.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ STATS : 'stats' -> pushMode(EXPRESSION_MODE);
1919
WHERE : 'where' -> pushMode(EXPRESSION_MODE);
2020

2121
DEV_INLINESTATS : {this.isDevVersion()}? 'inlinestats' -> pushMode(EXPRESSION_MODE);
22-
DEV_RANDOM_SAMPLE : {this.isDevVersion()}? 'random_sample' -> pushMode(EXPRESSION_MODE);
22+
DEV_SAMPLE : {this.isDevVersion()}? 'sample' -> pushMode(EXPRESSION_MODE);
2323

2424

2525
mode EXPRESSION_MODE;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,9 @@ public enum Cap {
940940
MAKE_NUMBER_OF_CHANNELS_CONSISTENT_WITH_LAYOUT,
941941

942942
/**
943-
* Support for the RANDOM_SAMPLE command
943+
* Support for the SAMPLE command
944944
*/
945-
RANDOM_SAMPLE(Build.current().isSnapshot());
945+
SAMPLE(Build.current().isSnapshot());
946946

947947
private final boolean enabled;
948948

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LocalPhysicalPlanOptimizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.InsertFieldExtraction;
1414
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.PushFiltersToSource;
1515
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.PushLimitToSource;
16-
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.PushRandomSampleToSource;
16+
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.PushSampleToSource;
1717
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.PushStatsToSource;
1818
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.PushTopNToSource;
1919
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.ReplaceSourceAttributes;
@@ -66,7 +66,7 @@ protected List<Batch<PhysicalPlan>> rules(boolean optimizeForEsSource) {
6666
esSourceRules.add(new PushTopNToSource());
6767
esSourceRules.add(new PushLimitToSource());
6868
esSourceRules.add(new PushFiltersToSource());
69-
esSourceRules.add(new PushRandomSampleToSource());
69+
esSourceRules.add(new PushSampleToSource());
7070
esSourceRules.add(new PushStatsToSource());
7171
esSourceRules.add(new EnableSpatialDistancePushdown());
7272
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineFilters;
4040
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineLimits;
4141
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineOrderBy;
42-
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineRandomSample;
42+
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineSample;
4343
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEnrich;
4444
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEval;
4545
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownRegexExtract;
@@ -191,7 +191,7 @@ protected static Batch<LogicalPlan> operators() {
191191
new PruneLiteralsInOrderBy(),
192192
new PushDownAndCombineLimits(),
193193
new PushDownAndCombineFilters(),
194-
new PushDownAndCombineRandomSample(),
194+
new PushDownAndCombineSample(),
195195
new PushDownEval(),
196196
new PushDownRegexExtract(),
197197
new PushDownEnrich(),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.elasticsearch.xpack.esql.expression.function.aggregate.HasSampleCorrection;
1313
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
1414
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
15-
import org.elasticsearch.xpack.esql.plan.logical.RandomSample;
15+
import org.elasticsearch.xpack.esql.plan.logical.Sample;
1616
import org.elasticsearch.xpack.esql.rule.Rule;
1717

1818
public class ApplySampleCorrections extends Rule<LogicalPlan, LogicalPlan> {
@@ -21,8 +21,8 @@ public class ApplySampleCorrections extends Rule<LogicalPlan, LogicalPlan> {
2121
public LogicalPlan apply(LogicalPlan logicalPlan) {
2222
Holder<Expression> sampleProbability = new Holder<>(null);
2323
return logicalPlan.transformUp(plan -> {
24-
if (plan instanceof RandomSample randomSample) {
25-
sampleProbability.set(randomSample.probability());
24+
if (plan instanceof Sample sample) {
25+
sampleProbability.set(sample.probability());
2626
}
2727
if (plan instanceof Aggregate && sampleProbability.get() != null) {
2828
plan = plan.transformExpressionsOnly(

0 commit comments

Comments
 (0)