Skip to content

Commit bc7ec4c

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 410eb58 commit bc7ec4c

File tree

16 files changed

+665
-55
lines changed

16 files changed

+665
-55
lines changed

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

@@ -562,6 +575,13 @@ protected boolean supportsTook() throws IOException {
562575
return supportsTook;
563576
}
564577

578+
protected boolean supportsViews() {
579+
if (supportsViews == null) {
580+
supportsViews = hasCapabilities(adminClient(), List.of("views_with_no_branching"));
581+
}
582+
return supportsViews;
583+
}
584+
565585
private String tookKey(long took) {
566586
if (took < 10) {
567587
return "lt_10ms";

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ protected void shouldSkipTest(String testName) throws IOException {
7070
testCase.requiredCapabilities.contains(METRICS_GROUP_BY_ALL.capabilityName())
7171
);
7272

73+
assumeFalse(
74+
"Tests using VIEWS not supported for now (until we merge VIEWS and Subqueries/FORK including branch merging)",
75+
testCase.requiredCapabilities.contains(VIEWS_WITH_BRANCHING.capabilityName())
76+
);
77+
7378
assumeTrue("Cluster needs to support FORK", hasCapabilities(adminClient(), List.of(FORK_V9.capabilityName())));
7479
}
7580
}

0 commit comments

Comments
 (0)