asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject incubator-asterixdb git commit: add toString() to debug the SQL++ compiler
Date Fri, 20 May 2016 14:53:23 GMT
Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 20dd96741 -> 60e1699b4


add toString() to debug the SQL++ compiler

Change-Id: I32cf6b5c3be0211c10b1e379d19a6014350fc798
Reviewed-on: https://asterix-gerrit.ics.uci.edu/799
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/commit/60e1699b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/tree/60e1699b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/diff/60e1699b

Branch: refs/heads/master
Commit: 60e1699b495abe95c62ae31c2512b3b3d85c6729
Parents: 20dd967
Author: Till Westmann <tillw@apache.org>
Authored: Wed Apr 13 17:53:20 2016 -0700
Committer: Till Westmann <tillw@apache.org>
Committed: Fri May 20 07:53:19 2016 -0700

----------------------------------------------------------------------
 .../org/apache/asterix/lang/common/expression/CallExpr.java    | 5 +++++
 .../apache/asterix/lang/common/expression/FieldAccessor.java   | 4 ++++
 .../java/org/apache/asterix/lang/sqlpp/clause/FromClause.java  | 6 ++++++
 .../java/org/apache/asterix/lang/sqlpp/clause/FromTerm.java    | 4 ++++
 .../java/org/apache/asterix/lang/sqlpp/clause/Projection.java  | 5 +++++
 .../org/apache/asterix/lang/sqlpp/clause/SelectClause.java     | 5 +++++
 .../org/apache/asterix/lang/sqlpp/clause/SelectElement.java    | 5 +++++
 .../org/apache/asterix/lang/sqlpp/clause/SelectRegular.java    | 6 ++++++
 .../lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java  | 3 +--
 9 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
index c7d48b6..44a40c4 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/CallExpr.java
@@ -65,4 +65,9 @@ public class CallExpr extends AbstractExpression {
     public <R, T> R accept(ILangVisitor<R, T> visitor, T arg) throws AsterixException
{
         return visitor.visit(this, arg);
     }
+
+    @Override
+    public String toString() {
+        return "call " + String.valueOf(functionSignature);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/FieldAccessor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/FieldAccessor.java
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/FieldAccessor.java
index 2517add..e23c799 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/FieldAccessor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/FieldAccessor.java
@@ -49,4 +49,8 @@ public class FieldAccessor extends AbstractAccessor {
         return visitor.visit(this, arg);
     }
 
+    @Override
+    public String toString() {
+        return String.valueOf(expr) + "." + ident.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromClause.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromClause.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromClause.java
index 802869d..da6c512 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromClause.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromClause.java
@@ -21,6 +21,7 @@ package org.apache.asterix.lang.sqlpp.clause;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.lang.common.base.Clause;
@@ -48,4 +49,9 @@ public class FromClause implements Clause {
     public List<FromTerm> getFromTerms() {
         return fromTerms;
     }
+
+    @Override
+    public String toString() {
+        return fromTerms.stream().map(String::valueOf).collect(Collectors.joining(", "));
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromTerm.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromTerm.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromTerm.java
index 5e8cd9c..8a756c7 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromTerm.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/FromTerm.java
@@ -82,4 +82,8 @@ public class FromTerm implements Clause {
         return posVar != null;
     }
 
+    @Override
+    public String toString() {
+        return String.valueOf(leftExpr) + " AS " + String.valueOf(leftVar);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/Projection.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/Projection.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/Projection.java
index 6ca9b71..f73ec1e 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/Projection.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/Projection.java
@@ -76,4 +76,9 @@ public class Projection implements Clause {
     public boolean exprStar() {
         return exprStar;
     }
+
+    @Override
+    public String toString() {
+        return star ? "*" : (String.valueOf(expr) + (exprStar ? ".*" : (hasName() ? " as
" + getName() : "")));
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectClause.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectClause.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectClause.java
index c6b4e24..42c8b29 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectClause.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectClause.java
@@ -66,4 +66,9 @@ public class SelectClause implements Clause {
         return distinct;
     }
 
+    @Override
+    public String toString() {
+        return "select " + (distinct ? "distinct " : "")
+                + (selectElement() ? "element " + String.valueOf(selectElement) : String.valueOf(selectRegular));
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectElement.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectElement.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectElement.java
index e13506a..14efd0f 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectElement.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectElement.java
@@ -50,4 +50,9 @@ public class SelectElement implements Clause {
     public void setExpression(Expression expr) {
         this.expr = expr;
     }
+
+    @Override
+    public String toString() {
+        return String.valueOf(expr);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectRegular.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectRegular.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectRegular.java
index e8a14ea..4703e01 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectRegular.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/clause/SelectRegular.java
@@ -20,6 +20,7 @@
 package org.apache.asterix.lang.sqlpp.clause;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.lang.common.base.Clause;
@@ -47,4 +48,9 @@ public class SelectRegular implements Clause {
     public List<Projection> getProjections() {
         return projections;
     }
+
+    @Override
+    public String toString() {
+        return projections.stream().map(String::valueOf).collect(Collectors.joining(", "));
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/60e1699b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
index be9c697..6db1ea3 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
@@ -135,8 +135,7 @@ public class SqlppGroupBySugarVisitor extends AbstractSqlppExpressionScopingVisi
         // Construct the select expression.
         SelectBlock selectBlock = new SelectBlock(selectClause, fromClause, null, null, null,
null, null);
         SelectSetOperation selectSetOperation = new SelectSetOperation(new SetOperationInput(selectBlock,
null), null);
-        SelectExpression selectExpression = new SelectExpression(null, selectSetOperation,
null, null, false);
-        selectExpression.setSubquery(true);
+        SelectExpression selectExpression = new SelectExpression(null, selectSetOperation,
null, null, true);
 
         // replace variable expressions with field access
         Map<VariableExpr, Expression> varExprMap = new HashMap<>();


Mime
View raw message