Skip to content

Commit 4b5f3a8

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 dde0a7e commit 4b5f3a8

File tree

15 files changed

+641
-51
lines changed

15 files changed

+641
-51
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

@@ -548,6 +561,13 @@ protected boolean supportsTook() throws IOException {
548561
return supportsTook;
549562
}
550563

564+
protected boolean supportsViews() {
565+
if (supportsViews == null) {
566+
supportsViews = hasCapabilities(adminClient(), List.of("views_with_no_branching"));
567+
}
568+
return supportsViews;
569+
}
570+
551571
private String tookKey(long took) {
552572
if (took < 10) {
553573
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
@@ -62,6 +62,11 @@ protected void shouldSkipTest(String testName) throws IOException {
6262

6363
assumeFalse("Tests using PROMQL are not supported for now", testCase.requiredCapabilities.contains(PROMQL_V0.capabilityName()));
6464

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

0 commit comments

Comments
 (0)