|
@@ -961,14 +961,12 @@ public class StatementParserTests extends AbstractStatementParserTests {
|
|
|
}
|
|
|
|
|
|
public void testSubquery() {
|
|
|
- assertEquals(new Explain(EMPTY, PROCESSING_CMD_INPUT), statement("explain ( row a = 1 )"));
|
|
|
- }
|
|
|
-
|
|
|
- public void testSubqueryWithPipe() {
|
|
|
+ assumeTrue("Requires EXPLAIN capability", EsqlCapabilities.Cap.EXPLAIN.isEnabled());
|
|
|
assertEquals(new Explain(EMPTY, PROCESSING_CMD_INPUT), statement("explain ( row a = 1 )"));
|
|
|
}
|
|
|
|
|
|
public void testBlockComments() {
|
|
|
+ assumeTrue("Requires EXPLAIN capability", EsqlCapabilities.Cap.EXPLAIN.isEnabled());
|
|
|
String query = " explain ( from foo )";
|
|
|
LogicalPlan expected = statement(query);
|
|
|
|
|
@@ -984,6 +982,7 @@ public class StatementParserTests extends AbstractStatementParserTests {
|
|
|
}
|
|
|
|
|
|
public void testSingleLineComments() {
|
|
|
+ assumeTrue("Requires EXPLAIN capability", EsqlCapabilities.Cap.EXPLAIN.isEnabled());
|
|
|
String query = " explain ( from foo ) ";
|
|
|
LogicalPlan expected = statement(query);
|
|
|
|
|
@@ -1009,16 +1008,19 @@ public class StatementParserTests extends AbstractStatementParserTests {
|
|
|
}
|
|
|
|
|
|
public void testSuggestAvailableSourceCommandsOnParsingError() {
|
|
|
- for (Tuple<String, String> queryWithUnexpectedCmd : List.of(
|
|
|
- Tuple.tuple("frm foo", "frm"),
|
|
|
- Tuple.tuple("expln[from bar]", "expln"),
|
|
|
- Tuple.tuple("not-a-thing logs", "not-a-thing"),
|
|
|
- Tuple.tuple("high5 a", "high5"),
|
|
|
- Tuple.tuple("a+b = c", "a+b"),
|
|
|
- Tuple.tuple("a//hi", "a"),
|
|
|
- Tuple.tuple("a/*hi*/", "a"),
|
|
|
- Tuple.tuple("explain ( frm a )", "frm")
|
|
|
- )) {
|
|
|
+ var cases = new ArrayList<Tuple<String, String>>();
|
|
|
+ cases.add(Tuple.tuple("frm foo", "frm"));
|
|
|
+ cases.add(Tuple.tuple("expln[from bar]", "expln"));
|
|
|
+ cases.add(Tuple.tuple("not-a-thing logs", "not-a-thing"));
|
|
|
+ cases.add(Tuple.tuple("high5 a", "high5"));
|
|
|
+ cases.add(Tuple.tuple("a+b = c", "a+b"));
|
|
|
+ cases.add(Tuple.tuple("a//hi", "a"));
|
|
|
+ cases.add(Tuple.tuple("a/*hi*/", "a"));
|
|
|
+ if (EsqlCapabilities.Cap.EXPLAIN.isEnabled()) {
|
|
|
+ cases.add(Tuple.tuple("explain ( frm a )", "frm"));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Tuple<String, String> queryWithUnexpectedCmd : cases) {
|
|
|
expectThrows(
|
|
|
ParsingException.class,
|
|
|
allOf(
|
|
@@ -1084,7 +1086,12 @@ public class StatementParserTests extends AbstractStatementParserTests {
|
|
|
public void testMetadataFieldOnOtherSources() {
|
|
|
expectError("row a = 1 metadata _index", "line 1:20: extraneous input '_index' expecting <EOF>");
|
|
|
expectError("show info metadata _index", "line 1:11: token recognition error at: 'm'");
|
|
|
- expectError("explain ( from foo ) metadata _index", "line 1:22: mismatched input 'metadata' expecting {'|', ',', ')', 'metadata'}");
|
|
|
+ if (EsqlCapabilities.Cap.EXPLAIN.isEnabled()) {
|
|
|
+ expectError(
|
|
|
+ "explain ( from foo ) metadata _index",
|
|
|
+ "line 1:22: mismatched input 'metadata' expecting {'|', ',', ')', 'metadata'}"
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void testMetadataFieldMultipleDeclarations() {
|
|
@@ -3473,8 +3480,8 @@ public class StatementParserTests extends AbstractStatementParserTests {
|
|
|
}
|
|
|
|
|
|
// [ and ( are used to trigger a double mode causing their symbol name (instead of text) to be used in error reporting
|
|
|
- // this test checks that their are properly replaced in the error message
|
|
|
- public void testPreserveParanthesis() {
|
|
|
+ // this test checks that they are properly replaced in the error message
|
|
|
+ public void testPreserveParentheses() {
|
|
|
// test for (
|
|
|
expectError("row a = 1 not in", "line 1:17: mismatched input '<EOF>' expecting '('");
|
|
|
expectError("row a = 1 | where a not in", "line 1:27: mismatched input '<EOF>' expecting '('");
|
|
@@ -3482,9 +3489,11 @@ public class StatementParserTests extends AbstractStatementParserTests {
|
|
|
expectError("row a = 1 | where a not in [1", "line 1:28: missing '(' at '['");
|
|
|
expectError("row a = 1 | where a not in 123", "line 1:28: missing '(' at '123'");
|
|
|
// test for [
|
|
|
- expectError("explain", "line 1:8: mismatched input '<EOF>' expecting '('");
|
|
|
- expectError("explain ]", "line 1:9: token recognition error at: ']'");
|
|
|
- expectError("explain ( row x = 1", "line 1:20: missing ')' at '<EOF>'");
|
|
|
+ if (EsqlCapabilities.Cap.EXPLAIN.isEnabled()) {
|
|
|
+ expectError("explain", "line 1:8: mismatched input '<EOF>' expecting '('");
|
|
|
+ expectError("explain ]", "line 1:9: token recognition error at: ']'");
|
|
|
+ expectError("explain ( row x = 1", "line 1:20: missing ')' at '<EOF>'");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void testRerankDefaultInferenceIdAndScoreAttribute() {
|