diff --git a/docs/user/dql/troubleshooting.rst b/docs/user/dql/troubleshooting.rst index b57479c374..20a9f0e531 100644 --- a/docs/user/dql/troubleshooting.rst +++ b/docs/user/dql/troubleshooting.rst @@ -25,9 +25,9 @@ Query: .. code-block:: JSON - POST /_plugins/_sql + POST /_plugins/_ppl { - "query" : "SELECT * FROM sample:data" + "query" : "SOURCE = test_index | where a > 0)" } Result: @@ -35,12 +35,12 @@ Result: .. code-block:: JSON { - "reason": "Invalid SQL query", - "details": "Failed to parse query due to offending symbol [:] at: 'SELECT * FROM xxx WHERE xxx:' <--- HERE... - More details: Expecting tokens in {, 'AND', 'BETWEEN', 'GROUP', 'HAVING', 'IN', 'IS', 'LIKE', 'LIMIT', - 'NOT', 'OR', 'ORDER', 'REGEXP', '*', '/', '%', '+', '-', 'DIV', 'MOD', '=', '>', '<', '!', - '|', '&', '^', '.', DOT_ID}", - "type": "SyntaxAnalysisException" + "error": { + "reason": "Invalid Query", + "details": "[)] is not a valid term at this part of the query: '..._index | where a > 0)' <-- HERE. extraneous input ')' expecting ", + "type": "SyntaxCheckException" + }, + "status": 400 } **Workaround** diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/DescribeCommandIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/DescribeCommandIT.java index aee32e08d1..9af6b1a9a7 100644 --- a/integ-test/src/test/java/org/opensearch/sql/ppl/DescribeCommandIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/DescribeCommandIT.java @@ -80,7 +80,7 @@ public void describeCommandWithoutIndexShouldFailToParse() throws IOException { fail(); } catch (ResponseException e) { assertTrue(e.getMessage().contains("RuntimeException")); - assertTrue(e.getMessage().contains("Failed to parse query due to offending symbol")); + assertTrue(e.getMessage().contains("is not a valid term at this part of the query")); } } } diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/QueryAnalysisIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/QueryAnalysisIT.java index 80a89ed9c3..2892967be7 100644 --- a/integ-test/src/test/java/org/opensearch/sql/ppl/QueryAnalysisIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/QueryAnalysisIT.java @@ -82,25 +82,25 @@ public void queryShouldBeCaseInsensitiveInKeywords() { @Test public void queryNotStartingWithSearchCommandShouldFailSyntaxCheck() { String query = "fields firstname"; - queryShouldThrowSyntaxException(query, "Failed to parse query due to offending symbol"); + queryShouldThrowSyntaxException(query, "is not a valid term at this part of the query"); } @Test public void queryWithIncorrectCommandShouldFailSyntaxCheck() { String query = String.format("search source=%s | field firstname", TEST_INDEX_ACCOUNT); - queryShouldThrowSyntaxException(query, "Failed to parse query due to offending symbol"); + queryShouldThrowSyntaxException(query, "is not a valid term at this part of the query"); } @Test public void queryWithIncorrectKeywordsShouldFailSyntaxCheck() { String query = String.format("search sources=%s", TEST_INDEX_ACCOUNT); - queryShouldThrowSyntaxException(query, "Failed to parse query due to offending symbol"); + queryShouldThrowSyntaxException(query, "is not a valid term at this part of the query"); } @Test public void unsupportedAggregationFunctionShouldFailSyntaxCheck() { String query = String.format("search source=%s | stats range(age)", TEST_INDEX_ACCOUNT); - queryShouldThrowSyntaxException(query, "Failed to parse query due to offending symbol"); + queryShouldThrowSyntaxException(query, "is not a valid term at this part of the query"); } /** Commands that fail semantic analysis should throw {@link SemanticCheckException}. */ diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandIT.java index 5d1b0203d7..e91a255b8c 100644 --- a/integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandIT.java @@ -64,7 +64,7 @@ public void searchCommandWithoutSourceShouldFailToParse() throws IOException { fail(); } catch (ResponseException e) { assertTrue(e.getMessage().contains("RuntimeException")); - assertTrue(e.getMessage().contains("Failed to parse query due to offending symbol")); + assertTrue(e.getMessage().contains("is not a valid term at this part of the query")); } } } diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java index 2645be3aca..09c67ebf24 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java @@ -95,7 +95,7 @@ public void testSearchFieldsCommandCrossClusterShouldPass() { @Test public void testSearchCommandWithoutSourceShouldFail() { exceptionRule.expect(RuntimeException.class); - exceptionRule.expectMessage("Failed to parse query due to offending symbol"); + exceptionRule.expectMessage("is not a valid term at this part of the query"); new PPLSyntaxParser().parse("search a=1"); } @@ -337,7 +337,7 @@ public void testDescribeFieldsCommandShouldPass() { @Test public void testDescribeCommandWithSourceShouldFail() { exceptionRule.expect(RuntimeException.class); - exceptionRule.expectMessage("Failed to parse query due to offending symbol"); + exceptionRule.expectMessage("is not a valid term at this part of the query"); new PPLSyntaxParser().parse("describe source=t"); }