diff --git a/x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java b/x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java index 4a01001d92e2f..4be827600eaaa 100644 --- a/x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java +++ b/x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java @@ -48,6 +48,7 @@ import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.CSV_DATASET_MAP; import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.ENRICH_SOURCE_INDICES; import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources; +import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.ENABLE_FORK_FOR_REMOTE_INDICES_V2; import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.ENABLE_LOOKUP_JOIN_ON_REMOTE; import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.FORK_V9; import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINE_STATS; @@ -167,7 +168,12 @@ protected void shouldSkipTest(String testName) throws IOException { // Tests that do SORT before LOOKUP JOIN - not supported in CCS assumeFalse("LOOKUP JOIN after SORT not yet supported in CCS", testName.contains("OnTheCoordinator")); - assumeFalse("FORK not yet supported with CCS", testCase.requiredCapabilities.contains(FORK_V9.capabilityName())); + if (testCase.requiredCapabilities.contains(FORK_V9.capabilityName())) { + assumeTrue( + "FORK not yet supported with CCS", + hasCapabilities(adminClient(), List.of(ENABLE_FORK_FOR_REMOTE_INDICES_V2.capabilityName())) + ); + } } private TestFeatureService remoteFeaturesService() throws IOException { diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/subquery.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/subquery.csv-spec index eb24d6191d08e..9eafeb2663cb8 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/subquery.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/subquery.csv-spec @@ -319,10 +319,9 @@ null | null | 4 | 172.21.3.15 ; subqueryWithCountStarAndDateTrunc -required_capability: fork_v9 required_capability: subquery_in_from_command -FROM employees, (FROM sample_data +FROM employees, (FROM sample_data metadata _index | STATS cnt = count(*) by ts=date_trunc(1 hour, @timestamp) | SORT cnt DESC ) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java index 065507459b200..a44f4933aeb4b 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java @@ -1470,7 +1470,7 @@ public enum Cap { /** * FORK with remote indices */ - ENABLE_FORK_FOR_REMOTE_INDICES(Build.current().isSnapshot()), + ENABLE_FORK_FOR_REMOTE_INDICES_V2(Build.current().isSnapshot()), /** * Support for the Present function diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java index c124a7972c714..79a0d304f6789 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java @@ -972,7 +972,7 @@ public PlanFactory visitForkCommand(EsqlBaseParser.ForkCommandContext ctx) { } return input -> { - if (EsqlCapabilities.Cap.ENABLE_FORK_FOR_REMOTE_INDICES.isEnabled() == false) { + if (EsqlCapabilities.Cap.ENABLE_FORK_FOR_REMOTE_INDICES_V2.isEnabled() == false) { checkForRemoteClusters(input, source(ctx), "FORK"); } List subPlans = subQueries.stream().map(planFactory -> planFactory.apply(input)).toList(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java index c06ad0269194b..ba4a05515419e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java @@ -3580,7 +3580,7 @@ public void testInvalidFork() { expectError("FROM foo* | FORK (where true) ()", "line 1:32: mismatched input ')'"); expectError("FROM foo* | FORK () (where true)", "line 1:19: mismatched input ')'"); - if (EsqlCapabilities.Cap.ENABLE_FORK_FOR_REMOTE_INDICES.isEnabled() == false) { + if (EsqlCapabilities.Cap.ENABLE_FORK_FOR_REMOTE_INDICES_V2.isEnabled() == false) { var fromPatterns = randomIndexPatterns(CROSS_CLUSTER); expectError( "FROM " + fromPatterns + " | FORK (EVAL a = 1) (EVAL a = 2)",