Dmitry Lychagin has uploaded a new change for review.

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

Change subject: [NO ISSUE][COMP] Clean up error messages for unresolvable 
identifiers
......................................................................

[NO ISSUE][COMP] Clean up error messages for unresolvable identifiers

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

Details:
- Cleanup error messages for undefined and ambiguous identifiers
- Add negative test case for undefined identifier in SQL aggregate function

Change-Id: I82efc98f7661eaacaded1ce86a27f0a8f4bd4d87
---
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-07-negative/sugar-07-negative.1.ddl.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-07-negative/sugar-07-negative.2.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/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByAggregationSugarVisitor.java
M 
asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
6 files changed, 75 insertions(+), 9 deletions(-)


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

diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-07-negative/sugar-07-negative.1.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-07-negative/sugar-07-negative.1.ddl.sqlpp
new file mode 100644
index 0000000..a5b4314
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-07-negative/sugar-07-negative.1.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+drop dataverse gby if exists;
+create dataverse gby;
+
+use gby;
+
+create type testType as open {
+  id : string
+};
+
+create dataset customers(testType) primary key id;
+create dataset orders(testType) primary key id;
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-07-negative/sugar-07-negative.2.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-07-negative/sugar-07-negative.2.query.sqlpp
new file mode 100644
index 0000000..d54d797
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/group-by/sugar-07-negative/sugar-07-negative.2.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+/*
+ * Description: Test error message for an undefined variable reference in SQL 
aggregate function
+ */
+
+use gby;
+
+select c_id, min(UNDEF_VAR)
+from customers c, orders o
+where c.c_id = o.c_id
+group by c.c_id
+
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 a806bf6..997d368 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -1562,7 +1562,7 @@
     <test-case FilePath="custord">
       <compilation-unit name="join_q_09">
         <output-dir compare="Text">join_q_01</output-dir>
-        <expected-error>Cannot resolve ambiguous alias reference for undefined 
identifier age</expected-error>
+        <expected-error>Cannot resolve ambiguous alias reference for 
identifier age</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="custord">
@@ -1631,7 +1631,7 @@
     <test-case FilePath="dapd">
       <compilation-unit name="q2-3">
         <output-dir compare="Text">q2</output-dir>
-        <expected-error>Cannot resolve ambiguous alias reference for undefined 
identifier sig_id</expected-error>
+        <expected-error>Cannot resolve ambiguous alias reference for 
identifier sig_id</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="dapd">
@@ -2977,13 +2977,13 @@
     <test-case FilePath="group-by">
       <compilation-unit name="sugar-02">
         <output-dir compare="Text">core-02</output-dir>
-        <expected-error>Cannot resolve ambiguous alias reference for undefined 
identifier deptId</expected-error>
+        <expected-error>Cannot resolve ambiguous alias reference for 
identifier deptId</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="group-by">
       <compilation-unit name="sugar-02-2">
         <output-dir compare="Text">core-02</output-dir>
-        <expected-error>Cannot resolve ambiguous alias reference for undefined 
identifier deptId</expected-error>
+        <expected-error>Cannot resolve ambiguous alias reference for 
identifier deptId</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="group-by">
@@ -3019,6 +3019,12 @@
     <test-case FilePath="group-by">
       <compilation-unit name="sugar-06-distinct">
         <output-dir compare="Text">sugar-06-distinct</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="group-by">
+      <compilation-unit name="sugar-07-negative">
+        <output-dir compare="Text">core-01</output-dir>
+        <expected-error>Cannot resolve alias reference for undefined 
identifier UNDEF_VAR</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="group-by">
@@ -5665,7 +5671,7 @@
     <test-case FilePath="resolution">
       <compilation-unit name="conflict-fields-dataset">
         <output-dir compare="Text">conflict-field-dataset</output-dir>
-        <expected-error>Cannot resolve ambiguous alias reference for undefined 
identifier samptable</expected-error>
+        <expected-error>Cannot resolve ambiguous alias reference for 
identifier samptable</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="resolution">
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 d600762..46326e1 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -141,8 +141,8 @@
 1070 = Metadata error. %1$s
 1071 = A dataverse with this name %1$s already exists.
 1072 = A dataset with this name %1$s already exists.
-1073 = Cannot resolve alias reference for undefined identifier %1$s in %2$s
-1074 = Cannot resolve ambiguous alias reference for undefined identifier %1$s 
in %2$s
+1073 = Cannot resolve alias reference for undefined identifier %1$s
+1074 = Cannot resolve ambiguous alias reference for identifier %1$s
 1075 = Inside limit clauses, it is disallowed to reference a variable having 
the same name as any variable bound in the same scope as the limit clause.
 1076 = Cannot find dataset %1$s because there is no dataverse declared, nor an 
alias with name %1$s!
 1077 = Cannot find dataset %1$s in dataverse %2$s nor an alias with name %1$s!
diff --git 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByAggregationSugarVisitor.java
 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByAggregationSugarVisitor.java
index e133bad..baf143b 100644
--- 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByAggregationSugarVisitor.java
+++ 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByAggregationSugarVisitor.java
@@ -294,7 +294,7 @@
                     varExprMap.put(usedVar, faOuter);
                 } else {
                     throw new 
CompilationException(ErrorCode.UNDEFINED_IDENTIFIER, 
usedVar.getSourceLocation(),
-                            usedVar.getVar().getValue(), 
String.valueOf(fieldVars));
+                            
SqlppVariableUtil.toUserDefinedVariableName(usedVar.getVar().getValue()).getValue());
                 }
             }
 
diff --git 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
index 20071e3..b5fd996 100644
--- 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
+++ 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/VariableCheckAndRewriteVisitor.java
@@ -128,7 +128,7 @@
             default:
                 // More than one possibilities.
                 throw new CompilationException(ErrorCode.AMBIGUOUS_IDENTIFIER, 
sourceLoc,
-                        
SqlppVariableUtil.toUserDefinedVariableName(varName).getValue(), 
String.valueOf(localVars));
+                        
SqlppVariableUtil.toUserDefinedVariableName(varName).getValue());
         }
     }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I82efc98f7661eaacaded1ce86a27f0a8f4bd4d87
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Dmitry Lychagin <dmitry.lycha...@couchbase.com>

Reply via email to