Skip to content

rename ES|QL sample capability #129193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class RestSampleTestCase extends ESRestTestCase {
public void skipWhenSampleDisabled() throws IOException {
assumeTrue(
"Requires SAMPLE capability",
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.SAMPLE.capabilityName()))
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.SAMPLE_V2.capabilityName()))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// because the CSV tests don't support such assertions.

row
required_capability: sample
required_capability: sample_v2

ROW x = 1 | SAMPLE .999999999
;
Expand All @@ -20,7 +20,7 @@ x:integer


row and mv_expand
required_capability: sample
required_capability: sample_v2

ROW x = [1,2,3,4,5] | MV_EXPAND x | SAMPLE .999999999
;
Expand All @@ -35,7 +35,7 @@ x:integer


adjust stats for sampling
required_capability: sample
required_capability: sample_v2

FROM employees
| SAMPLE 0.5
Expand All @@ -53,7 +53,7 @@ true


before where
required_capability: sample
required_capability: sample_v2

FROM employees
| SAMPLE 0.5
Expand All @@ -71,7 +71,7 @@ true


after where
required_capability: sample
required_capability: sample_v2

FROM employees
| WHERE emp_no <= 10050
Expand All @@ -89,7 +89,7 @@ true


before sort
required_capability: sample
required_capability: sample_v2

FROM employees
| SAMPLE 0.5
Expand All @@ -107,7 +107,7 @@ true


after sort
required_capability: sample
required_capability: sample_v2

FROM employees
| SORT emp_no
Expand All @@ -125,7 +125,7 @@ true


before limit
required_capability: sample
required_capability: sample_v2

FROM employees
| SAMPLE 0.5
Expand All @@ -141,7 +141,7 @@ true


after limit
required_capability: sample
required_capability: sample_v2

FROM employees
| LIMIT 50
Expand All @@ -158,7 +158,7 @@ true


before mv_expand
required_capability: sample
required_capability: sample_v2

ROW x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50], y = [1,2]
| MV_EXPAND x
Expand All @@ -176,7 +176,7 @@ true


after mv_expand
required_capability: sample
required_capability: sample_v2

ROW x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50], y = [1,2]
| MV_EXPAND x
Expand All @@ -194,7 +194,7 @@ true


multiple samples
required_capability: sample
required_capability: sample_v2

FROM employees
| SAMPLE 0.7
Expand All @@ -213,7 +213,7 @@ true


after stats
required_capability: sample
required_capability: sample_v2

FROM employees
| SAMPLE 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ public enum Cap {
/**
* Support for the SAMPLE command
*/
SAMPLE(Build.current().isSnapshot()),
SAMPLE_V2(Build.current().isSnapshot()),

/**
* The {@code _query} API now gives a cast recommendation if multiple types are found in certain instances.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3460,7 +3460,7 @@ public void testRrfError() {
}

public void testRandomSampleProbability() {
assumeTrue("requires SAMPLE capability", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("requires SAMPLE capability", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

var e = expectThrows(VerificationException.class, () -> analyze("FROM test | SAMPLE 1."));
assertThat(e.getMessage(), containsString("RandomSampling probability must be strictly between 0.0 and 1.0, was [1.0]"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7858,7 +7858,7 @@ public void testPruneRedundantOrderBy() {
* \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
*/
public void testSampleMerged() {
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

var query = """
FROM TEST
Expand All @@ -7879,7 +7879,7 @@ public void testSampleMerged() {
}

public void testSamplePushDown() {
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

for (var command : List.of(
"ENRICH languages_idx on first_name",
Expand All @@ -7904,7 +7904,7 @@ public void testSamplePushDown() {
}

public void testSamplePushDown_sort() {
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

var query = "FROM TEST | WHERE emp_no > 0 | SAMPLE 0.5 | LIMIT 100";
var optimized = optimizedPlan(query);
Expand All @@ -7918,7 +7918,7 @@ public void testSamplePushDown_sort() {
}

public void testSamplePushDown_where() {
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

var query = "FROM TEST | SORT emp_no | SAMPLE 0.5 | LIMIT 100";
var optimized = optimizedPlan(query);
Expand All @@ -7931,7 +7931,7 @@ public void testSamplePushDown_where() {
}

public void testSampleNoPushDown() {
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

for (var command : List.of("LIMIT 100", "MV_EXPAND languages", "STATS COUNT()")) {
var query = "FROM TEST | " + command + " | SAMPLE .5";
Expand All @@ -7953,7 +7953,7 @@ public void testSampleNoPushDown() {
* \_EsRelation[languages_lookup][LOOKUP][language_code{f}#17, language_name{f}#18]
*/
public void testSampleNoPushDownLookupJoin() {
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

var query = """
FROM TEST
Expand All @@ -7979,7 +7979,7 @@ public void testSampleNoPushDownLookupJoin() {
* \_EsRelation[test][_meta_field{f}#12, emp_no{f}#6, first_name{f}#7, ge..]
*/
public void testSampleNoPushDownChangePoint() {
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

var query = """
FROM TEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8045,7 +8045,7 @@ public void testNotEqualsPushdownToDelegate() {
* [_doc{f}#24], limit[1000], sort[] estimatedRowSize[332]
*/
public void testSamplePushDown() {
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("sample must be enabled", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());

var plan = physicalPlan("""
FROM test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3482,7 +3482,7 @@ public void testInvalidCompletion() {
}

public void testSample() {
assumeTrue("SAMPLE requires corresponding capability", EsqlCapabilities.Cap.SAMPLE.isEnabled());
assumeTrue("SAMPLE requires corresponding capability", EsqlCapabilities.Cap.SAMPLE_V2.isEnabled());
expectError("FROM test | SAMPLE .1 2", "line 1:23: extraneous input '2' expecting <EOF>");
expectError("FROM test | SAMPLE .1 \"2\"", "line 1:23: extraneous input '\"2\"' expecting <EOF>");
expectError("FROM test | SAMPLE 1", "line 1:20: mismatched input '1' expecting {DECIMAL_LITERAL, '+', '-'}");
Expand Down