asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [1/7] asterixdb git commit: [ASTERIXDB-1753][SQL] Disable auto-plural for group-by.
Date Fri, 30 Jun 2017 23:44:09 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master b55ff7a42 -> 9c2e9f0ef


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c2e9f0e/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.3.ast
b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.3.ast
index 1657bd5..0fe8f7e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810-3/query-issue810-3.3.ast
@@ -69,7 +69,7 @@ Groupby
     Variable [ Name=$l ]
     Field=l_linestatus
   ]
-  GROUP AS Variable [ Name=#1 ]
+  GROUP AS Variable [ Name=$g ]
   (
     l:=Variable [ Name=$l ]
   )
@@ -83,7 +83,19 @@ Let Variable [ Name=$expensives ]
       Field=l_discount
     ]
     ]
-    FROM [      Variable [ Name=$l ]
+    FROM [      (
+        SELECT ELEMENT [
+        FunctionCall Metadata.resolve@-1[
+          LiteralExpr [STRING] [l]
+          Variable [ Name=$g ]
+          Variable [ Name=$l_linestatus ]
+          Variable [ Name=$l_returnflag ]
+        ]
+        ]
+        FROM [          Variable [ Name=$g ]
+          AS Variable [ Name=$g ]
+        ]
+      )
       AS Variable [ Name=$i ]
     ]
     Where
@@ -102,7 +114,20 @@ Let Variable [ Name=$cheaps ]
     SELECT ELEMENT [
     Variable [ Name=$i ]
     ]
-    FROM [      Variable [ Name=$l ]
+    FROM [      (
+        SELECT ELEMENT [
+        FunctionCall Metadata.resolve@-1[
+          LiteralExpr [STRING] [l]
+          Variable [ Name=$expensives ]
+          Variable [ Name=$g ]
+          Variable [ Name=$l_linestatus ]
+          Variable [ Name=$l_returnflag ]
+        ]
+        ]
+        FROM [          Variable [ Name=$g ]
+          AS Variable [ Name=$g ]
+        ]
+      )
       AS Variable [ Name=$i ]
     ]
     Where
@@ -144,7 +169,21 @@ Let Variable [ Name=$charges ]
       ]
     ]
     ]
-    FROM [      Variable [ Name=$l ]
+    FROM [      (
+        SELECT ELEMENT [
+        FunctionCall Metadata.resolve@-1[
+          LiteralExpr [STRING] [l]
+          Variable [ Name=$expensives ]
+          Variable [ Name=$g ]
+          Variable [ Name=$l_linestatus ]
+          Variable [ Name=$l_returnflag ]
+          Variable [ Name=$cheaps ]
+        ]
+        ]
+        FROM [          Variable [ Name=$g ]
+          AS Variable [ Name=$g ]
+        ]
+      )
       AS Variable [ Name=$i ]
     ]
   )
@@ -168,7 +207,22 @@ Let Variable [ Name=$disc_prices ]
       ]
     ]
     ]
-    FROM [      Variable [ Name=$l ]
+    FROM [      (
+        SELECT ELEMENT [
+        FunctionCall Metadata.resolve@-1[
+          LiteralExpr [STRING] [l]
+          Variable [ Name=$expensives ]
+          Variable [ Name=$g ]
+          Variable [ Name=$l_linestatus ]
+          Variable [ Name=$l_returnflag ]
+          Variable [ Name=$charges ]
+          Variable [ Name=$cheaps ]
+        ]
+        ]
+        FROM [          Variable [ Name=$g ]
+          AS Variable [ Name=$g ]
+        ]
+      )
       AS Variable [ Name=$i ]
     ]
   )

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c2e9f0e/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.3.ast
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.3.ast
b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.3.ast
index 9c62a28..6787c4f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue810/query-issue810.3.ast
@@ -55,7 +55,7 @@ Groupby
     Variable [ Name=$l ]
     Field=l_linestatus
   ]
-  GROUP AS Variable [ Name=#1 ]
+  GROUP AS Variable [ Name=$g ]
   (
     l:=Variable [ Name=$l ]
   )
@@ -64,15 +64,21 @@ Let Variable [ Name=$cheap ]
   :=
   (
     SELECT ELEMENT [
-    Variable [ Name=$m ]
+    FieldAccessor [
+      Variable [ Name=$m ]
+      Field=l
+    ]
     ]
-    FROM [      Variable [ Name=$l ]
+    FROM [      Variable [ Name=$g ]
       AS Variable [ Name=$m ]
     ]
     Where
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=$m ]
+          FieldAccessor [
+            Variable [ Name=$m ]
+            Field=l
+          ]
           Field=l_discount
         ]
         >
@@ -83,15 +89,21 @@ Let Variable [ Name=$expensive ]
   :=
   (
     SELECT ELEMENT [
-    Variable [ Name=$a ]
+    FieldAccessor [
+      Variable [ Name=$a ]
+      Field=l
+    ]
     ]
-    FROM [      Variable [ Name=$l ]
+    FROM [      Variable [ Name=$g ]
       AS Variable [ Name=$a ]
     ]
     Where
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=$a ]
+          FieldAccessor [
+            Variable [ Name=$a ]
+            Field=l
+          ]
           Field=l_discount
         ]
         <=

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c2e9f0e/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
----------------------------------------------------------------------
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 0ad80c0..0ad091f 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -2585,7 +2585,7 @@
     <test-case FilePath="global-aggregate">
       <compilation-unit name="q05_error">
         <output-dir compare="Text">q01</output-dir>
-        <expected-error>Type mismatch: function field-access-by-name expects its 1st
input parameter to be type object, but the actual input type is array</expected-error>
+        <expected-error>Cannot find dataset u in dataverse TinySocial nor an alias
with name u</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="global-aggregate">
@@ -2649,6 +2649,18 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="group-by">
+      <compilation-unit name="core-01-error">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>Cannot find dataset e in dataverse gby nor an alias with name
e</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="group-by">
+      <compilation-unit name="core-02-error">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>Cannot find dataset f in dataverse gby nor an alias with name
f</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="group-by">
       <compilation-unit name="core-02">
         <output-dir compare="Text">core-02</output-dir>
       </compilation-unit>

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/9c2e9f0e/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByVisitor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByVisitor.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByVisitor.java
index b928285..7f2e6c9 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupByVisitor.java
@@ -184,7 +184,7 @@ public class SqlppGroupByVisitor extends AbstractSqlppExpressionScopingVisitor
{
             if (needResolution) {
                 // Tracks used variables, including WITH variables.
                 decorVars.retainAll(freeVariables);
-                // Adds all non-WITH outer scope variables, for path resolution.
+                // Adds all outer scope variables, for path resolution.
                 Collection<VariableExpr> visibleOuterScopeNonWithVars = SqlppVariableUtil.getLiveVariables(
                         scopeChecker.getCurrentScope(), false);
                 visibleOuterScopeNonWithVars.removeAll(visibleVarsInCurrentScope);
@@ -220,18 +220,9 @@ public class SqlppGroupByVisitor extends AbstractSqlppExpressionScopingVisitor
{
 
     @Override
     public Expression visit(GroupbyClause gc, ILangExpression arg) throws CompilationException
{
-        // Puts all FROM binding variables into withVarList.
         FromClause fromClause = (FromClause) arg;
         Collection<VariableExpr> fromBindingVars =
                 fromClause == null ? new ArrayList<>() : SqlppVariableUtil.getBindingVariables(fromClause);
-        Map<Expression, VariableExpr> withVarMap = new HashMap<>();
-        for (VariableExpr fromBindingVar : fromBindingVars) {
-            VariableExpr varExpr = new VariableExpr();
-            varExpr.setIsNewVar(false);
-            varExpr.setVar(fromBindingVar.getVar());
-            VariableExpr newVarExpr = (VariableExpr) SqlppRewriteUtil.deepCopy(varExpr);
-            withVarMap.put(varExpr, newVarExpr);
-        }
         // Sets the field list for the group variable.
         List<Pair<Expression, Identifier>> groupFieldList = new ArrayList<>();
         if (!gc.hasGroupFieldList()) {
@@ -245,12 +236,9 @@ public class SqlppGroupByVisitor extends AbstractSqlppExpressionScopingVisitor
{
             for (Pair<Expression, Identifier> groupField : gc.getGroupFieldList())
{
                 Expression newFieldExpr = groupField.first.accept(this, arg);
                 groupFieldList.add(new Pair<>(newFieldExpr, groupField.second));
-                // Adds a field binding variable into withVarList.
-                VariableExpr bindingVar = new VariableExpr(
-                        new VarIdentifier(SqlppVariableUtil.toInternalVariableName(groupField.second.getValue())));
-                withVarMap.put(newFieldExpr, bindingVar);
             }
         }
+
         gc.setGroupFieldList(groupFieldList);
 
         // Sets the group variable.
@@ -262,6 +250,7 @@ public class SqlppGroupByVisitor extends AbstractSqlppExpressionScopingVisitor
{
         // Adds the group variable into the "with" (i.e., re-binding) variable list.
         VariableExpr gbyVarRef = new VariableExpr(gc.getGroupVar().getVar());
         gbyVarRef.setIsNewVar(false);
+        Map<Expression, VariableExpr> withVarMap = new HashMap<>();
         withVarMap.put(gbyVarRef, (VariableExpr) SqlppRewriteUtil.deepCopy(gbyVarRef));
         gc.setWithVarMap(withVarMap);
 


Mime
View raw message