Skip to content

Commit 67a9194

Browse files
committed
ESQL: Views prototype
Initial work on getting views integrated with ES|QL * Access views within FROM command * Add csv-spec tests for non-branching and branching views * Get CsvTests working on views * Updated command-line CsvTestDataLoader for views, and multiple runs
1 parent cbaf51f commit 67a9194

File tree

21 files changed

+828
-205
lines changed

21 files changed

+828
-205
lines changed

docs/changelog/134995.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 134995
2+
summary: ES|QL Views prototype
3+
area: ES|QL
4+
type: feature
5+
issues: []

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METADATA_FIELDS_REMOTE_TEST;
5858
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SUBQUERY_IN_FROM_COMMAND;
5959
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.UNMAPPED_FIELDS;
60+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.VIEWS_WITH_NO_BRANCHING;
6061
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.hasCapabilities;
6162
import static org.mockito.ArgumentMatchers.any;
6263
import static org.mockito.Mockito.doAnswer;
@@ -174,6 +175,7 @@ protected void shouldSkipTest(String testName) throws IOException {
174175
"Subqueries in FROM command not yet supported in CCS",
175176
testCase.requiredCapabilities.contains(SUBQUERY_IN_FROM_COMMAND.capabilityName())
176177
);
178+
assumeFalse("VIEWS not yet supported in CCS", testCase.requiredCapabilities.contains(VIEWS_WITH_NO_BRANCHING.capabilityName()));
177179
}
178180

179181
private TestFeatureService remoteFeaturesService() throws IOException {

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@
7676
import static org.elasticsearch.xpack.esql.CsvTestUtils.loadCsvSpecValues;
7777
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.createInferenceEndpoints;
7878
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.deleteInferenceEndpoints;
79+
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.deleteViews;
7980
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadDataSetIntoEs;
81+
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadViewsIntoEs;
8082
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
8183
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.COMPLETION;
8284
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.KNN_FUNCTION_V5;
@@ -103,6 +105,7 @@ public abstract class EsqlSpecTestCase extends ESRestTestCase {
103105
protected final String instructions;
104106
protected final Mode mode;
105107
protected static Boolean supportsTook;
108+
protected static Boolean supportsViews;
106109

107110
@ParametersFactory(argumentFormatting = "csv-spec:%2$s.%3$s")
108111
public static List<Object[]> readScriptSpec() throws Exception {
@@ -168,6 +171,7 @@ private synchronized void reset() {
168171
}
169172

170173
private static final Protected INGEST = new Protected();
174+
private static final Protected VIEWS = new Protected();
171175
protected static boolean testClustersOk = true;
172176

173177
@Before
@@ -188,6 +192,13 @@ public void setup() {
188192
);
189193
return null;
190194
});
195+
// Views can be created before or after ingest, since index resolution is currently only done on the combined query
196+
VIEWS.protectedBlock(() -> {
197+
if (supportsViews()) {
198+
loadViewsIntoEs(adminClient());
199+
}
200+
return null;
201+
});
191202
}
192203

193204
@AfterClass
@@ -204,6 +215,8 @@ public static void wipeTestData() throws IOException {
204215
}
205216
}
206217
INGEST.reset();
218+
deleteViews(adminClient());
219+
VIEWS.reset();
207220
deleteInferenceEndpoints(adminClient());
208221
}
209222

@@ -545,6 +558,13 @@ protected boolean supportsTook() throws IOException {
545558
return supportsTook;
546559
}
547560

561+
protected boolean supportsViews() {
562+
if (supportsViews == null) {
563+
supportsViews = hasCapabilities(adminClient(), List.of("views_with_no_branching"));
564+
}
565+
return supportsViews;
566+
}
567+
548568
private String tookKey(long took) {
549569
if (took < 10) {
550570
return "lt_10ms";

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeForkRestTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import java.io.IOException;
1414
import java.util.List;
1515

16-
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.*;
16+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.FORK_V9;
17+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SUBQUERY_IN_FROM_COMMAND;
18+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.UNMAPPED_FIELDS;
19+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.VIEWS_WITH_BRANCHING;
1720
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.hasCapabilities;
1821

1922
/**
@@ -60,6 +63,11 @@ protected void shouldSkipTest(String testName) throws IOException {
6063
testCase.requiredCapabilities.contains(SUBQUERY_IN_FROM_COMMAND.capabilityName())
6164
);
6265

66+
assumeFalse(
67+
"Tests using VIEWS not supported for now (until we merge VIEWS and Subqueries/FORK including branch merging)",
68+
testCase.requiredCapabilities.contains(VIEWS_WITH_BRANCHING.capabilityName())
69+
);
70+
6371
assumeTrue("Cluster needs to support FORK", hasCapabilities(adminClient(), List.of(FORK_V9.capabilityName())));
6472
}
6573
}

0 commit comments

Comments
 (0)