Dmitry Lychagin has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2572

Change subject: [ASTERIXDB-2355][SQL] Incorrect error reporting by SQL++ parser
......................................................................

[ASTERIXDB-2355][SQL] Incorrect error reporting by SQL++ parser

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Fixes incorrect error reporting by SQL++ parser.
  Error messages like: “Flags=“, “Conversion=“

Change-Id: Id68f2b039c8198509658a90a60b8a8dc95361a84
---
M 
asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-2355/query-ASTERIXDB-2355.1.query.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
M asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
5 files changed, 36 insertions(+), 6 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/72/2572/1

diff --git 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java
 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java
index 890667a..a356d23 100644
--- 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java
+++ 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ResultExtractor.java
@@ -171,14 +171,14 @@
         return IOUtils.toInputStream(resultBuilder.toString(), 
StandardCharsets.UTF_8);
     }
 
-    private static void checkForErrors(ObjectNode result) throws 
AsterixException {
+    private static void checkForErrors(ObjectNode result) throws Exception {
         final JsonNode errorsField = 
result.get(ResultField.ERRORS.getFieldName());
         if (errorsField != null) {
             final JsonNode errors = errorsField.get(0).get("msg");
             if 
(!result.get(ResultField.METRICS.getFieldName()).has("errorCount")) {
-                throw new AsterixException("Request reported error but not an 
errorCount");
+                throw new Exception("Request reported error but not an 
errorCount");
             }
-            throw new AsterixException(errors.asText());
+            throw new Exception(errors.asText());
         }
     }
 }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-2355/query-ASTERIXDB-2355.1.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-2355/query-ASTERIXDB-2355.1.query.sqlpp
new file mode 100644
index 0000000..68d7f4a
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-2355/query-ASTERIXDB-2355.1.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Invalid syntax */
+
+ %%%
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 1b49358..3b1363c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -1895,7 +1895,7 @@
     <test-case FilePath="dml">
       <compilation-unit name="load-with-autogenerated-no-field">
         <output-dir 
compare="Text">load-with-autogenerated-no-field</output-dir>
-        <expected-error>org.apache.asterix.common.exceptions.AsterixException: 
ASX1014: Field "not_id" is not found</expected-error>
+        <expected-error>ASX1014: Field "not_id" is not found</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="dml">
@@ -3715,6 +3715,12 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="misc">
+      <compilation-unit name="query-ASTERIXDB-2355">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error><![CDATA[ASX1001: Syntax error: In line 22 >> %%%<< 
Encountered "%" at column 2.]]></expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="misc">
       <compilation-unit name="unsupported_parameter">
         <output-dir compare="Text">none</output-dir>
         <expected-error>Query parameter compiler.joinmem is not 
supported</expected-error>
diff --git 
a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties 
b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index 92aac98..175f144 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -74,6 +74,7 @@
 200 = External UDF cannot produce expected result. Please check the UDF 
configuration
 
 # Compile-time check errors
+1001 = Syntax error: %1$s
 1007 = Invalid expression: function %1$s expects its %2$s input parameter to 
be a %3$s expression, but the actual expression is %4$s
 1008 = Invalid parameter number: function %1$s cannot take %2$s parameters
 1010 = Phrase search in Full-text is not yet supported. Only one keyword per 
expression is permitted
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 
b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index 9af114b..b8b7622 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -64,6 +64,7 @@
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.common.config.DatasetConfig.IndexType;
 import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.common.functions.FunctionConstants;
 import org.apache.asterix.common.functions.FunctionSignature;
 import org.apache.asterix.lang.common.base.Expression;
@@ -296,9 +297,9 @@
             // this is here as the JavaCharStream that's below the lexer 
somtimes throws Errors that are not handled
             // by the ANTLR-generated lexer or parser (e.g it does this for 
invalid backslash u + 4 hex digits escapes)
             final String msg = e.getClass().getSimpleName() + (e.getMessage() 
!= null ? ": " + e.getMessage() : "");
-            throw new CompilationException(new ParseException(msg));
+            throw new CompilationException(ErrorCode.PARSE_ERROR, msg);
         } catch (ParseException e) {
-            throw new CompilationException("Syntax error: " + getMessage(e));
+            throw new CompilationException(ErrorCode.PARSE_ERROR, 
getMessage(e));
         }
     }
 

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2572
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id68f2b039c8198509658a90a60b8a8dc95361a84
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: release-0.9.4-pre-rc
Gerrit-Owner: Dmitry Lychagin <[email protected]>

Reply via email to