You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by bu...@apache.org on 2016/03/28 22:18:29 UTC

[02/51] [partial] incubator-asterixdb git commit: ASTERIXDB-1226: implement SQL++ core group-by semantics and syntatic sugars.

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
index 715999d..3b22218 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785-2/query-issue785-2.3.ast
@@ -1,6 +1,6 @@
 DataverseUse tpch
 Query:
-LetVariable [ Name=t ]
+Let Variable [ Name=$t ]
   :=
   (
     SELECT ELEMENT [
@@ -9,7 +9,7 @@ LetVariable [ Name=t ]
         LiteralExpr [STRING] [n_nationkey]
         :
         FieldAccessor [
-          Variable [ Name=nation ]
+          Variable [ Name=$nation ]
           Field=n_nationkey
         ]
       )
@@ -17,7 +17,7 @@ LetVariable [ Name=t ]
         LiteralExpr [STRING] [n_name]
         :
         FieldAccessor [
-          Variable [ Name=nation ]
+          Variable [ Name=$nation ]
           Field=n_name
         ]
       )
@@ -27,28 +27,28 @@ LetVariable [ Name=t ]
         LiteralExpr [STRING] [Nation]
       ]
       AS
-      Variable [ Name=nation ]
+      Variable [ Name=$nation ]
 ,
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [SelectedNation]
       ]
       AS
-      Variable [ Name=sn ]
+      Variable [ Name=$sn ]
     ]
     Where
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=nation ]
+          Variable [ Name=$nation ]
           Field=n_nationkey
         ]
         =
         FieldAccessor [
-          Variable [ Name=sn ]
+          Variable [ Name=$sn ]
           Field=n_nationkey
         ]
       ]
   )
-LetVariable [ Name=X ]
+Let Variable [ Name=$X ]
   :=
   (
     SELECT ELEMENT [
@@ -56,94 +56,101 @@ LetVariable [ Name=X ]
       (
         LiteralExpr [STRING] [nation_key]
         :
-        Variable [ Name=nation_key ]
+        Variable [ Name=$nation_key ]
       )
       (
         LiteralExpr [STRING] [order_date]
         :
-        Variable [ Name=orderdate ]
+        Variable [ Name=$orderdate ]
       )
       (
         LiteralExpr [STRING] [sum_price]
         :
-        Variable [ Name=sum ]
+        Variable [ Name=$sum ]
       )
     ]
     ]
-    FROM [      Variable [ Name=t ]
+    FROM [      Variable [ Name=$t ]
       AS
-      Variable [ Name=n ]
+      Variable [ Name=$n ]
 ,
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [Customer]
       ]
       AS
-      Variable [ Name=customer ]
+      Variable [ Name=$customer ]
 ,
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [Orders]
       ]
       AS
-      Variable [ Name=orders ]
+      Variable [ Name=$orders ]
     ]
     Where
       OperatorExpr [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=orders ]
+            Variable [ Name=$orders ]
             Field=o_custkey
           ]
           =
           FieldAccessor [
-            Variable [ Name=customer ]
+            Variable [ Name=$customer ]
             Field=c_custkey
           ]
         ]
         and
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=customer ]
+            Variable [ Name=$customer ]
             Field=c_nationkey
           ]
           =
           FieldAccessor [
-            Variable [ Name=n ]
+            Variable [ Name=$n ]
             Field=n_nationkey
           ]
         ]
       ]
     Groupby
-      Variable [ Name=orderdate ]
+      Variable [ Name=$orderdate ]
       :=
       FieldAccessor [
-        Variable [ Name=orders ]
+        Variable [ Name=$orders ]
         Field=o_orderdate
       ]
-      Variable [ Name=nation_key ]
+      Variable [ Name=$nation_key ]
       :=
       FieldAccessor [
-        Variable [ Name=n ]
+        Variable [ Name=$n ]
         Field=n_nationkey
       ]
-      With
-      Variable [ Name=orders ]
-      Variable [ Name=n ]
-      Variable [ Name=customer ]
-      Variable [ Name=t ]
+      GROUP AS
+      Variable [ Name=#1 ]
+      (
+      Variable [ Name=$orders ]
+       AS orders
+      Variable [ Name=$customer ]
+       AS customer
+      Variable [ Name=$n ]
+       AS n
+      Variable [ Name=$t ]
+       AS t
+      )
 
-    LetVariable [ Name=sum ]
+    Let Variable [ Name=$sum ]
       :=
       FunctionCall tpch.sum@1[
         (
           SELECT ELEMENT [
           FieldAccessor [
-            Variable [ Name=o ]
+            Variable [ Name=$o ]
             Field=o_totalprice
           ]
           ]
-          FROM [            Variable [ Name=orders ]
+          FROM [            Variable [ Name=$orders ]
             AS
-            Variable [ Name=o ]
+            Variable [ Name=$o ]
           ]
         )
       ]
@@ -153,7 +160,7 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [nation_key]
     :
-    Variable [ Name=nation_key ]
+    Variable [ Name=$nation_key ]
   )
   (
     LiteralExpr [STRING] [sum_price]
@@ -165,7 +172,7 @@ RecordConstructor [
           LiteralExpr [STRING] [orderdate]
           :
           FieldAccessor [
-            Variable [ Name=y ]
+            Variable [ Name=$y ]
             Field=order_date
           ]
         )
@@ -173,19 +180,19 @@ RecordConstructor [
           LiteralExpr [STRING] [sum_price]
           :
           FieldAccessor [
-            Variable [ Name=y ]
+            Variable [ Name=$y ]
             Field=sum_price
           ]
         )
       ]
       ]
-      FROM [        Variable [ Name=x ]
+      FROM [        Variable [ Name=$x ]
         AS
-        Variable [ Name=y ]
+        Variable [ Name=$y ]
       ]
       Orderby
         FieldAccessor [
-          Variable [ Name=y ]
+          Variable [ Name=$y ]
           Field=sum_price
         ]
         DESC
@@ -196,19 +203,25 @@ RecordConstructor [
   )
 ]
 ]
-FROM [  Variable [ Name=X ]
+FROM [  Variable [ Name=$X ]
   AS
-  Variable [ Name=x ]
+  Variable [ Name=$x ]
 ]
 Groupby
-  Variable [ Name=nation_key ]
+  Variable [ Name=$nation_key ]
   :=
   FieldAccessor [
-    Variable [ Name=x ]
+    Variable [ Name=$x ]
     Field=nation_key
   ]
-  With
-  Variable [ Name=x ]
-  Variable [ Name=X ]
-  Variable [ Name=t ]
+  GROUP AS
+  Variable [ Name=#2 ]
+  (
+  Variable [ Name=$x ]
+   AS x
+  Variable [ Name=$X ]
+   AS X
+  Variable [ Name=$t ]
+   AS t
+  )
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
index f69a6be..e59376e 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue785/query-issue785.3.ast
@@ -5,7 +5,7 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [nation_key]
     :
-    Variable [ Name=nation_key ]
+    Variable [ Name=$nation_key ]
   )
   (
     LiteralExpr [STRING] [sum_price]
@@ -16,49 +16,57 @@ RecordConstructor [
         (
           LiteralExpr [STRING] [orderdate]
           :
-          Variable [ Name=od ]
+          Variable [ Name=$od ]
         )
         (
           LiteralExpr [STRING] [sum_price]
           :
-          Variable [ Name=sum ]
+          Variable [ Name=$sum ]
         )
       ]
       ]
-      FROM [        Variable [ Name=x ]
+      FROM [        Variable [ Name=$x ]
         AS
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
       ]
       Groupby
-        Variable [ Name=od ]
+        Variable [ Name=$od ]
         :=
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=order_date
         ]
-        With
-        Variable [ Name=i ]
-        Variable [ Name=x ]
-        Variable [ Name=nation_key ]
+        GROUP AS
+        Variable [ Name=#3 ]
+        (
+        Variable [ Name=$i ]
+         AS i
+        Variable [ Name=$x ]
+         AS x
+        Variable [ Name=$nation_key ]
+         AS nation_key
+        Variable [ Name=#2 ]
+         AS #2
+        )
 
-      LetVariable [ Name=sum ]
+      Let Variable [ Name=$sum ]
         :=
         FunctionCall tpch.sum@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
-              Variable [ Name=s ]
+              Variable [ Name=$s ]
               Field=sum_price
             ]
             ]
-            FROM [              Variable [ Name=i ]
+            FROM [              Variable [ Name=$i ]
               AS
-              Variable [ Name=s ]
+              Variable [ Name=$s ]
             ]
           )
         ]
       Orderby
-        Variable [ Name=sum ]
+        Variable [ Name=$sum ]
         DESC
 
       Limit
@@ -73,12 +81,12 @@ FROM [  (
       (
         LiteralExpr [STRING] [nation_key]
         :
-        Variable [ Name=nation_key ]
+        Variable [ Name=$nation_key ]
       )
       (
         LiteralExpr [STRING] [order_date]
         :
-        Variable [ Name=orderdate ]
+        Variable [ Name=$orderdate ]
       )
       (
         LiteralExpr [STRING] [sum_price]
@@ -87,13 +95,13 @@ FROM [  (
           (
             SELECT ELEMENT [
             FieldAccessor [
-              Variable [ Name=o ]
+              Variable [ Name=$o ]
               Field=o_totalprice
             ]
             ]
-            FROM [              Variable [ Name=orders ]
+            FROM [              Variable [ Name=$orders ]
               AS
-              Variable [ Name=o ]
+              Variable [ Name=$o ]
             ]
           )
         ]
@@ -104,75 +112,85 @@ FROM [  (
         LiteralExpr [STRING] [Nation]
       ]
       AS
-      Variable [ Name=n ]
+      Variable [ Name=$n ]
 ,
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [Customer]
       ]
       AS
-      Variable [ Name=customer ]
+      Variable [ Name=$customer ]
 ,
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [Orders]
       ]
       AS
-      Variable [ Name=orders ]
+      Variable [ Name=$orders ]
     ]
     Where
       OperatorExpr [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=orders ]
+            Variable [ Name=$orders ]
             Field=o_custkey
           ]
           =
           FieldAccessor [
-            Variable [ Name=customer ]
+            Variable [ Name=$customer ]
             Field=c_custkey
           ]
         ]
         and
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=customer ]
+            Variable [ Name=$customer ]
             Field=c_nationkey
           ]
           =
           FieldAccessor [
-            Variable [ Name=n ]
+            Variable [ Name=$n ]
             Field=n_nationkey
           ]
         ]
       ]
     Groupby
-      Variable [ Name=orderdate ]
+      Variable [ Name=$orderdate ]
       :=
       FieldAccessor [
-        Variable [ Name=orders ]
+        Variable [ Name=$orders ]
         Field=o_orderdate
       ]
-      Variable [ Name=nation_key ]
+      Variable [ Name=$nation_key ]
       :=
       FieldAccessor [
-        Variable [ Name=n ]
+        Variable [ Name=$n ]
         Field=n_nationkey
       ]
-      With
-      Variable [ Name=orders ]
-      Variable [ Name=n ]
-      Variable [ Name=customer ]
+      GROUP AS
+      Variable [ Name=#1 ]
+      (
+      Variable [ Name=$orders ]
+       AS orders
+      Variable [ Name=$customer ]
+       AS customer
+      Variable [ Name=$n ]
+       AS n
+      )
 
   )
   AS
-  Variable [ Name=x ]
+  Variable [ Name=$x ]
 ]
 Groupby
-  Variable [ Name=nation_key ]
+  Variable [ Name=$nation_key ]
   :=
   FieldAccessor [
-    Variable [ Name=x ]
+    Variable [ Name=$x ]
     Field=nation_key
   ]
-  With
-  Variable [ Name=x ]
+  GROUP AS
+  Variable [ Name=#2 ]
+  (
+  Variable [ Name=$x ]
+   AS x
+  )
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
index dcd0269..4cd1b1f 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/query-issue786/query-issue786.3.ast
@@ -6,7 +6,7 @@ RecordConstructor [
     LiteralExpr [STRING] [nation_key]
     :
     FieldAccessor [
-      Variable [ Name=nation ]
+      Variable [ Name=$nation ]
       Field=n_nationkey
     ]
   )
@@ -14,7 +14,7 @@ RecordConstructor [
     LiteralExpr [STRING] [name]
     :
     FieldAccessor [
-      Variable [ Name=nation ]
+      Variable [ Name=$nation ]
       Field=n_name
     ]
   )
@@ -27,12 +27,12 @@ RecordConstructor [
         (
           LiteralExpr [STRING] [order_date]
           :
-          Variable [ Name=orderdate ]
+          Variable [ Name=$orderdate ]
         )
         (
           LiteralExpr [STRING] [sum_price]
           :
-          Variable [ Name=sum ]
+          Variable [ Name=$sum ]
         )
       ]
       ]
@@ -40,71 +40,78 @@ RecordConstructor [
           LiteralExpr [STRING] [Orders]
         ]
         AS
-        Variable [ Name=orders ]
+        Variable [ Name=$orders ]
 ,
         FunctionCall Metadata.dataset@1[
           LiteralExpr [STRING] [Customer]
         ]
         AS
-        Variable [ Name=customer ]
+        Variable [ Name=$customer ]
       ]
       Where
         OperatorExpr [
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=orders ]
+              Variable [ Name=$orders ]
               Field=o_custkey
             ]
             =
             FieldAccessor [
-              Variable [ Name=customer ]
+              Variable [ Name=$customer ]
               Field=c_custkey
             ]
           ]
           and
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=customer ]
+              Variable [ Name=$customer ]
               Field=c_nationkey
             ]
             =
             FieldAccessor [
-              Variable [ Name=nation ]
+              Variable [ Name=$nation ]
               Field=n_nationkey
             ]
           ]
         ]
       Groupby
-        Variable [ Name=orderdate ]
+        Variable [ Name=$orderdate ]
         :=
         FieldAccessor [
-          Variable [ Name=orders ]
+          Variable [ Name=$orders ]
           Field=o_orderdate
         ]
-        With
-        Variable [ Name=orders ]
-        Variable [ Name=customer ]
-        Variable [ Name=nation ]
-        Variable [ Name=sn ]
+        GROUP AS
+        Variable [ Name=#1 ]
+        (
+        Variable [ Name=$customer ]
+         AS customer
+        Variable [ Name=$orders ]
+         AS orders
+        Variable [ Name=$sn ]
+         AS sn
+        Variable [ Name=$nation ]
+         AS nation
+        )
 
-      LetVariable [ Name=sum ]
+      Let Variable [ Name=$sum ]
         :=
         FunctionCall tpch.sum@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
-              Variable [ Name=o ]
+              Variable [ Name=$o ]
               Field=o_totalprice
             ]
             ]
-            FROM [              Variable [ Name=orders ]
+            FROM [              Variable [ Name=$orders ]
               AS
-              Variable [ Name=o ]
+              Variable [ Name=$o ]
             ]
           )
         ]
       Orderby
-        Variable [ Name=sum ]
+        Variable [ Name=$sum ]
         DESC
 
       Limit
@@ -117,23 +124,23 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Nation]
   ]
   AS
-  Variable [ Name=nation ]
+  Variable [ Name=$nation ]
 ,
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [SelectedNation]
   ]
   AS
-  Variable [ Name=sn ]
+  Variable [ Name=$sn ]
 ]
 Where
   OperatorExpr [
     FieldAccessor [
-      Variable [ Name=nation ]
+      Variable [ Name=$nation ]
       Field=n_nationkey
     ]
     =
     FieldAccessor [
-      Variable [ Name=sn ]
+      Variable [ Name=$sn ]
       Field=sn_nationkey
     ]
   ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.3.ast
index b8d2c7f..1ffbc72 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/distinct_by/distinct_by.3.ast
@@ -6,7 +6,7 @@ RecordConstructor [
     LiteralExpr [STRING] [l_returnflag]
     :
     FieldAccessor [
-      Variable [ Name=l ]
+      Variable [ Name=$l ]
       Field=l_returnflag
     ]
   )
@@ -14,7 +14,7 @@ RecordConstructor [
     LiteralExpr [STRING] [l_linestatus]
     :
     FieldAccessor [
-      Variable [ Name=l ]
+      Variable [ Name=$l ]
       Field=l_linestatus
     ]
   )
@@ -22,7 +22,7 @@ RecordConstructor [
     LiteralExpr [STRING] [l_shipmode]
     :
     FieldAccessor [
-      Variable [ Name=l ]
+      Variable [ Name=$l ]
       Field=l_shipmode
     ]
   )
@@ -32,21 +32,21 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [LineItem]
   ]
   AS
-  Variable [ Name=l ]
+  Variable [ Name=$l ]
 ]
 Orderby
   FieldAccessor [
-    Variable [ Name=l ]
+    Variable [ Name=$l ]
     Field=l_returnflag
   ]
   ASC
   FieldAccessor [
-    Variable [ Name=l ]
+    Variable [ Name=$l ]
     Field=l_linestatus
   ]
   ASC
   FieldAccessor [
-    Variable [ Name=l ]
+    Variable [ Name=$l ]
     Field=l_shipmode
   ]
   ASC

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.3.ast
index 8a7df20..5a2efb6 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/group_no_agg/group_no_agg.3.ast
@@ -1,25 +1,29 @@
 DataverseUse tpch
 Query:
 SELECT ELEMENT [
-Variable [ Name=name ]
+Variable [ Name=$name ]
 ]
 FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Regions_group_no_agg]
   ]
   AS
-  Variable [ Name=r ]
+  Variable [ Name=$r ]
 ]
 Groupby
-  Variable [ Name=name ]
+  Variable [ Name=$name ]
   :=
   FieldAccessor [
-    Variable [ Name=r ]
+    Variable [ Name=$r ]
     Field=r_name
   ]
-  With
-  Variable [ Name=r ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$r ]
+   AS r
+  )
 
 Orderby
-  Variable [ Name=name ]
+  Variable [ Name=$name ]
   ASC
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.3.ast
index 47eea36..12d0a2e 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/nest_aggregate/nest_aggregate.3.ast
@@ -6,7 +6,7 @@ RecordConstructor [
     LiteralExpr [STRING] [nation_key]
     :
     FieldAccessor [
-      Variable [ Name=nation ]
+      Variable [ Name=$nation ]
       Field=n_nationkey
     ]
   )
@@ -14,7 +14,7 @@ RecordConstructor [
     LiteralExpr [STRING] [name]
     :
     FieldAccessor [
-      Variable [ Name=nation ]
+      Variable [ Name=$nation ]
       Field=n_name
     ]
   )
@@ -27,12 +27,12 @@ RecordConstructor [
         (
           LiteralExpr [STRING] [order_date]
           :
-          Variable [ Name=orderdate ]
+          Variable [ Name=$orderdate ]
         )
         (
           LiteralExpr [STRING] [sum_price]
           :
-          Variable [ Name=sum ]
+          Variable [ Name=$sum ]
         )
       ]
       ]
@@ -40,71 +40,78 @@ RecordConstructor [
           LiteralExpr [STRING] [Orders]
         ]
         AS
-        Variable [ Name=orders ]
+        Variable [ Name=$orders ]
 ,
         FunctionCall Metadata.dataset@1[
           LiteralExpr [STRING] [Customer]
         ]
         AS
-        Variable [ Name=customer ]
+        Variable [ Name=$customer ]
       ]
       Where
         OperatorExpr [
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=orders ]
+              Variable [ Name=$orders ]
               Field=o_custkey
             ]
             =
             FieldAccessor [
-              Variable [ Name=customer ]
+              Variable [ Name=$customer ]
               Field=c_custkey
             ]
           ]
           and
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=customer ]
+              Variable [ Name=$customer ]
               Field=c_nationkey
             ]
             =
             FieldAccessor [
-              Variable [ Name=nation ]
+              Variable [ Name=$nation ]
               Field=n_nationkey
             ]
           ]
         ]
       Groupby
-        Variable [ Name=orderdate ]
+        Variable [ Name=$orderdate ]
         :=
         FieldAccessor [
-          Variable [ Name=orders ]
+          Variable [ Name=$orders ]
           Field=o_orderdate
         ]
-        With
-        Variable [ Name=orders ]
-        Variable [ Name=customer ]
-        Variable [ Name=nation ]
-        Variable [ Name=sn ]
+        GROUP AS
+        Variable [ Name=#1 ]
+        (
+        Variable [ Name=$customer ]
+         AS customer
+        Variable [ Name=$orders ]
+         AS orders
+        Variable [ Name=$sn ]
+         AS sn
+        Variable [ Name=$nation ]
+         AS nation
+        )
 
-      LetVariable [ Name=sum ]
+      Let Variable [ Name=$sum ]
         :=
         FunctionCall tpch.sum@1[
           (
             SELECT ELEMENT [
             FieldAccessor [
-              Variable [ Name=o ]
+              Variable [ Name=$o ]
               Field=o_totalprice
             ]
             ]
-            FROM [              Variable [ Name=orders ]
+            FROM [              Variable [ Name=$orders ]
               AS
-              Variable [ Name=o ]
+              Variable [ Name=$o ]
             ]
           )
         ]
       Orderby
-        Variable [ Name=sum ]
+        Variable [ Name=$sum ]
         ASC
 
       Limit
@@ -117,29 +124,29 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Nation]
   ]
   AS
-  Variable [ Name=nation ]
+  Variable [ Name=$nation ]
 ,
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [SelectedNation]
   ]
   AS
-  Variable [ Name=sn ]
+  Variable [ Name=$sn ]
 ]
 Where
   OperatorExpr [
     FieldAccessor [
-      Variable [ Name=nation ]
+      Variable [ Name=$nation ]
       Field=n_nationkey
     ]
     =
     FieldAccessor [
-      Variable [ Name=sn ]
+      Variable [ Name=$sn ]
       Field=n_nationkey
     ]
   ]
 Orderby
   FieldAccessor [
-    Variable [ Name=nation ]
+    Variable [ Name=$nation ]
     Field=n_nationkey
   ]
   ASC

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
index 40474c7..cafd221 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q01_pricing_summary_report_nt/q01_pricing_summary_report_nt.3.ast
@@ -6,12 +6,12 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [l_returnflag]
     :
-    Variable [ Name=l_returnflag ]
+    Variable [ Name=$l_returnflag ]
   )
   (
     LiteralExpr [STRING] [l_linestatus]
     :
-    Variable [ Name=l_linestatus ]
+    Variable [ Name=$l_linestatus ]
   )
   (
     LiteralExpr [STRING] [sum_qty]
@@ -20,13 +20,13 @@ RecordConstructor [
       (
         SELECT ELEMENT [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=l_quantity
         ]
         ]
-        FROM [          Variable [ Name=l ]
+        FROM [          Variable [ Name=$l ]
           AS
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
       )
     ]
@@ -38,13 +38,13 @@ RecordConstructor [
       (
         SELECT ELEMENT [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=l_extendedprice
         ]
         ]
-        FROM [          Variable [ Name=l ]
+        FROM [          Variable [ Name=$l ]
           AS
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
       )
     ]
@@ -57,7 +57,7 @@ RecordConstructor [
         SELECT ELEMENT [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=i ]
+            Variable [ Name=$i ]
             Field=l_extendedprice
           ]
           *
@@ -65,15 +65,15 @@ RecordConstructor [
             LiteralExpr [LONG] [1]
             -
             FieldAccessor [
-              Variable [ Name=i ]
+              Variable [ Name=$i ]
               Field=l_discount
             ]
           ]
         ]
         ]
-        FROM [          Variable [ Name=l ]
+        FROM [          Variable [ Name=$l ]
           AS
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
       )
     ]
@@ -86,7 +86,7 @@ RecordConstructor [
         SELECT ELEMENT [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=i ]
+            Variable [ Name=$i ]
             Field=l_extendedprice
           ]
           *
@@ -94,7 +94,7 @@ RecordConstructor [
             LiteralExpr [LONG] [1]
             -
             FieldAccessor [
-              Variable [ Name=i ]
+              Variable [ Name=$i ]
               Field=l_discount
             ]
           ]
@@ -103,15 +103,15 @@ RecordConstructor [
             LiteralExpr [LONG] [1]
             +
             FieldAccessor [
-              Variable [ Name=i ]
+              Variable [ Name=$i ]
               Field=l_tax
             ]
           ]
         ]
         ]
-        FROM [          Variable [ Name=l ]
+        FROM [          Variable [ Name=$l ]
           AS
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
       )
     ]
@@ -123,13 +123,13 @@ RecordConstructor [
       (
         SELECT ELEMENT [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=l_quantity
         ]
         ]
-        FROM [          Variable [ Name=l ]
+        FROM [          Variable [ Name=$l ]
           AS
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
       )
     ]
@@ -141,13 +141,13 @@ RecordConstructor [
       (
         SELECT ELEMENT [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=l_extendedprice
         ]
         ]
-        FROM [          Variable [ Name=l ]
+        FROM [          Variable [ Name=$l ]
           AS
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
       )
     ]
@@ -159,13 +159,13 @@ RecordConstructor [
       (
         SELECT ELEMENT [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=l_discount
         ]
         ]
-        FROM [          Variable [ Name=l ]
+        FROM [          Variable [ Name=$l ]
           AS
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
       )
     ]
@@ -174,7 +174,18 @@ RecordConstructor [
     LiteralExpr [STRING] [count_order]
     :
     FunctionCall tpch.count@1[
-      Variable [ Name=l ]
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=#2 ]
+          Field=l
+        ]
+        ]
+        FROM [          Variable [ Name=#1 ]
+          AS
+          Variable [ Name=#2 ]
+        ]
+      )
     ]
   )
 ]
@@ -183,36 +194,40 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [LineItem]
   ]
   AS
-  Variable [ Name=l ]
+  Variable [ Name=$l ]
 ]
 Where
   OperatorExpr [
     FieldAccessor [
-      Variable [ Name=l ]
+      Variable [ Name=$l ]
       Field=l_shipdate
     ]
     <=
     LiteralExpr [STRING] [1998-09-02]
   ]
 Groupby
-  Variable [ Name=l_returnflag ]
+  Variable [ Name=$l_returnflag ]
   :=
   FieldAccessor [
-    Variable [ Name=l ]
+    Variable [ Name=$l ]
     Field=l_returnflag
   ]
-  Variable [ Name=l_linestatus ]
+  Variable [ Name=$l_linestatus ]
   :=
   FieldAccessor [
-    Variable [ Name=l ]
+    Variable [ Name=$l ]
     Field=l_linestatus
   ]
-  With
-  Variable [ Name=l ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$l ]
+   AS l
+  )
 
 Orderby
-  Variable [ Name=l_returnflag ]
+  Variable [ Name=$l_returnflag ]
   ASC
-  Variable [ Name=l_linestatus ]
+  Variable [ Name=$l_linestatus ]
   ASC
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
index 52df01f..bcdbaa0 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q02_minimum_cost_supplier/q02_minimum_cost_supplier.3.ast
@@ -7,7 +7,7 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [s_acctbal]
         :
         FieldAccessor [
-          Variable [ Name=pssrn ]
+          Variable [ Name=$pssrn ]
           Field=s_acctbal
         ]
       )
@@ -15,7 +15,7 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [s_name]
         :
         FieldAccessor [
-          Variable [ Name=pssrn ]
+          Variable [ Name=$pssrn ]
           Field=s_name
         ]
       )
@@ -23,7 +23,7 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [n_name]
         :
         FieldAccessor [
-          Variable [ Name=pssrn ]
+          Variable [ Name=$pssrn ]
           Field=n_name
         ]
       )
@@ -31,7 +31,7 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [p_partkey]
         :
         FieldAccessor [
-          Variable [ Name=p ]
+          Variable [ Name=$p ]
           Field=p_partkey
         ]
       )
@@ -39,7 +39,7 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [ps_supplycost]
         :
         FieldAccessor [
-          Variable [ Name=pssrn ]
+          Variable [ Name=$pssrn ]
           Field=ps_supplycost
         ]
       )
@@ -47,7 +47,7 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [p_mfgr]
         :
         FieldAccessor [
-          Variable [ Name=p ]
+          Variable [ Name=$p ]
           Field=p_mfgr
         ]
       )
@@ -55,7 +55,7 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [s_address]
         :
         FieldAccessor [
-          Variable [ Name=pssrn ]
+          Variable [ Name=$pssrn ]
           Field=s_address
         ]
       )
@@ -63,7 +63,7 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [s_phone]
         :
         FieldAccessor [
-          Variable [ Name=pssrn ]
+          Variable [ Name=$pssrn ]
           Field=s_phone
         ]
       )
@@ -71,15 +71,15 @@ FunctionDecl tmp1([]) {
         LiteralExpr [STRING] [s_comment]
         :
         FieldAccessor [
-          Variable [ Name=pssrn ]
+          Variable [ Name=$pssrn ]
           Field=s_comment
         ]
       )
     ]
     ]
-    FROM [      Variable [ Name=Part ]
+    FROM [      Variable [ Name=$Part ]
       AS
-      Variable [ Name=p ]
+      Variable [ Name=$p ]
 ,
       (
         SELECT ELEMENT [
@@ -88,7 +88,7 @@ FunctionDecl tmp1([]) {
             LiteralExpr [STRING] [n_name]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=n_name
             ]
           )
@@ -96,7 +96,7 @@ FunctionDecl tmp1([]) {
             LiteralExpr [STRING] [p_partkey]
             :
             FieldAccessor [
-              Variable [ Name=ps ]
+              Variable [ Name=$ps ]
               Field=ps_partkey
             ]
           )
@@ -104,7 +104,7 @@ FunctionDecl tmp1([]) {
             LiteralExpr [STRING] [ps_supplycost]
             :
             FieldAccessor [
-              Variable [ Name=ps ]
+              Variable [ Name=$ps ]
               Field=ps_supplycost
             ]
           )
@@ -112,7 +112,7 @@ FunctionDecl tmp1([]) {
             LiteralExpr [STRING] [s_name]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_name
             ]
           )
@@ -120,7 +120,7 @@ FunctionDecl tmp1([]) {
             LiteralExpr [STRING] [s_acctbal]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_acctbal
             ]
           )
@@ -128,7 +128,7 @@ FunctionDecl tmp1([]) {
             LiteralExpr [STRING] [s_address]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_address
             ]
           )
@@ -136,7 +136,7 @@ FunctionDecl tmp1([]) {
             LiteralExpr [STRING] [s_phone]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_phone
             ]
           )
@@ -144,15 +144,15 @@ FunctionDecl tmp1([]) {
             LiteralExpr [STRING] [s_comment]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_comment
             ]
           )
         ]
         ]
-        FROM [          Variable [ Name=Partsupp ]
+        FROM [          Variable [ Name=$Partsupp ]
           AS
-          Variable [ Name=ps ]
+          Variable [ Name=$ps ]
 ,
           (
             SELECT ELEMENT [
@@ -161,7 +161,7 @@ FunctionDecl tmp1([]) {
                 LiteralExpr [STRING] [s_suppkey]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_suppkey
                 ]
               )
@@ -169,7 +169,7 @@ FunctionDecl tmp1([]) {
                 LiteralExpr [STRING] [n_name]
                 :
                 FieldAccessor [
-                  Variable [ Name=rn ]
+                  Variable [ Name=$rn ]
                   Field=n_name
                 ]
               )
@@ -177,7 +177,7 @@ FunctionDecl tmp1([]) {
                 LiteralExpr [STRING] [s_name]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_name
                 ]
               )
@@ -185,7 +185,7 @@ FunctionDecl tmp1([]) {
                 LiteralExpr [STRING] [s_acctbal]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_acctbal
                 ]
               )
@@ -193,7 +193,7 @@ FunctionDecl tmp1([]) {
                 LiteralExpr [STRING] [s_address]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_address
                 ]
               )
@@ -201,7 +201,7 @@ FunctionDecl tmp1([]) {
                 LiteralExpr [STRING] [s_phone]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_phone
                 ]
               )
@@ -209,15 +209,15 @@ FunctionDecl tmp1([]) {
                 LiteralExpr [STRING] [s_comment]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_comment
                 ]
               )
             ]
             ]
-            FROM [              Variable [ Name=Supplier ]
+            FROM [              Variable [ Name=$Supplier ]
               AS
-              Variable [ Name=s ]
+              Variable [ Name=$s ]
 ,
               (
                 SELECT ELEMENT [
@@ -226,7 +226,7 @@ FunctionDecl tmp1([]) {
                     LiteralExpr [STRING] [n_nationkey]
                     :
                     FieldAccessor [
-                      Variable [ Name=n ]
+                      Variable [ Name=$n ]
                       Field=n_nationkey
                     ]
                   )
@@ -234,37 +234,37 @@ FunctionDecl tmp1([]) {
                     LiteralExpr [STRING] [n_name]
                     :
                     FieldAccessor [
-                      Variable [ Name=n ]
+                      Variable [ Name=$n ]
                       Field=n_name
                     ]
                   )
                 ]
                 ]
-                FROM [                  Variable [ Name=Region ]
+                FROM [                  Variable [ Name=$Region ]
                   AS
-                  Variable [ Name=r ]
+                  Variable [ Name=$r ]
 ,
-                  Variable [ Name=Nation ]
+                  Variable [ Name=$Nation ]
                   AS
-                  Variable [ Name=n ]
+                  Variable [ Name=$n ]
                 ]
                 Where
                   OperatorExpr [
                     OperatorExpr [
                       FieldAccessor [
-                        Variable [ Name=n ]
+                        Variable [ Name=$n ]
                         Field=n_regionkey
                       ]
                       =
                       FieldAccessor [
-                        Variable [ Name=r ]
+                        Variable [ Name=$r ]
                         Field=r_regionkey
                       ]
                     ]
                     and
                     OperatorExpr [
                       FieldAccessor [
-                        Variable [ Name=r ]
+                        Variable [ Name=$r ]
                         Field=r_name
                       ]
                       =
@@ -273,57 +273,57 @@ FunctionDecl tmp1([]) {
                   ]
               )
               AS
-              Variable [ Name=rn ]
+              Variable [ Name=$rn ]
             ]
             Where
               OperatorExpr [
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_nationkey
                 ]
                 =
                 FieldAccessor [
-                  Variable [ Name=rn ]
+                  Variable [ Name=$rn ]
                   Field=n_nationkey
                 ]
               ]
           )
           AS
-          Variable [ Name=srn ]
+          Variable [ Name=$srn ]
         ]
         Where
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_suppkey
             ]
             =
             FieldAccessor [
-              Variable [ Name=ps ]
+              Variable [ Name=$ps ]
               Field=ps_suppkey
             ]
           ]
       )
       AS
-      Variable [ Name=pssrn ]
+      Variable [ Name=$pssrn ]
     ]
     Where
       OperatorExpr [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=p ]
+            Variable [ Name=$p ]
             Field=p_partkey
           ]
           =
           FieldAccessor [
-            Variable [ Name=pssrn ]
+            Variable [ Name=$pssrn ]
             Field=p_partkey
           ]
         ]
         and
         FunctionCall tpch.like@2[
           FieldAccessor [
-            Variable [ Name=p ]
+            Variable [ Name=$p ]
             Field=p_type
           ]
           LiteralExpr [STRING] [%BRASS]
@@ -339,7 +339,7 @@ FunctionDecl tmp2([]) {
       (
         LiteralExpr [STRING] [p_partkey]
         :
-        Variable [ Name=p_partkey ]
+        Variable [ Name=$p_partkey ]
       )
       (
         LiteralExpr [STRING] [ps_min_supplycost]
@@ -348,22 +348,22 @@ FunctionDecl tmp2([]) {
           (
             SELECT ELEMENT [
             FieldAccessor [
-              Variable [ Name=i ]
+              Variable [ Name=$i ]
               Field=ps_supplycost
             ]
             ]
-            FROM [              Variable [ Name=pssrn ]
+            FROM [              Variable [ Name=$pssrn ]
               AS
-              Variable [ Name=i ]
+              Variable [ Name=$i ]
             ]
           )
         ]
       )
     ]
     ]
-    FROM [      Variable [ Name=Part ]
+    FROM [      Variable [ Name=$Part ]
       AS
-      Variable [ Name=p ]
+      Variable [ Name=$p ]
 ,
       (
         SELECT ELEMENT [
@@ -372,7 +372,7 @@ FunctionDecl tmp2([]) {
             LiteralExpr [STRING] [n_name]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=n_name
             ]
           )
@@ -380,7 +380,7 @@ FunctionDecl tmp2([]) {
             LiteralExpr [STRING] [p_partkey]
             :
             FieldAccessor [
-              Variable [ Name=ps ]
+              Variable [ Name=$ps ]
               Field=ps_partkey
             ]
           )
@@ -388,7 +388,7 @@ FunctionDecl tmp2([]) {
             LiteralExpr [STRING] [ps_supplycost]
             :
             FieldAccessor [
-              Variable [ Name=ps ]
+              Variable [ Name=$ps ]
               Field=ps_supplycost
             ]
           )
@@ -396,7 +396,7 @@ FunctionDecl tmp2([]) {
             LiteralExpr [STRING] [s_name]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_name
             ]
           )
@@ -404,7 +404,7 @@ FunctionDecl tmp2([]) {
             LiteralExpr [STRING] [s_acctbal]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_acctbal
             ]
           )
@@ -412,7 +412,7 @@ FunctionDecl tmp2([]) {
             LiteralExpr [STRING] [s_address]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_address
             ]
           )
@@ -420,7 +420,7 @@ FunctionDecl tmp2([]) {
             LiteralExpr [STRING] [s_phone]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_phone
             ]
           )
@@ -428,15 +428,15 @@ FunctionDecl tmp2([]) {
             LiteralExpr [STRING] [s_comment]
             :
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_comment
             ]
           )
         ]
         ]
-        FROM [          Variable [ Name=Partsupp ]
+        FROM [          Variable [ Name=$Partsupp ]
           AS
-          Variable [ Name=ps ]
+          Variable [ Name=$ps ]
 ,
           (
             SELECT ELEMENT [
@@ -445,7 +445,7 @@ FunctionDecl tmp2([]) {
                 LiteralExpr [STRING] [s_suppkey]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_suppkey
                 ]
               )
@@ -453,7 +453,7 @@ FunctionDecl tmp2([]) {
                 LiteralExpr [STRING] [n_name]
                 :
                 FieldAccessor [
-                  Variable [ Name=rn ]
+                  Variable [ Name=$rn ]
                   Field=n_name
                 ]
               )
@@ -461,7 +461,7 @@ FunctionDecl tmp2([]) {
                 LiteralExpr [STRING] [s_name]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_name
                 ]
               )
@@ -469,7 +469,7 @@ FunctionDecl tmp2([]) {
                 LiteralExpr [STRING] [s_acctbal]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_acctbal
                 ]
               )
@@ -477,7 +477,7 @@ FunctionDecl tmp2([]) {
                 LiteralExpr [STRING] [s_address]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_address
                 ]
               )
@@ -485,7 +485,7 @@ FunctionDecl tmp2([]) {
                 LiteralExpr [STRING] [s_phone]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_phone
                 ]
               )
@@ -493,15 +493,15 @@ FunctionDecl tmp2([]) {
                 LiteralExpr [STRING] [s_comment]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_comment
                 ]
               )
             ]
             ]
-            FROM [              Variable [ Name=Supplier ]
+            FROM [              Variable [ Name=$Supplier ]
               AS
-              Variable [ Name=s ]
+              Variable [ Name=$s ]
 ,
               (
                 SELECT ELEMENT [
@@ -510,7 +510,7 @@ FunctionDecl tmp2([]) {
                     LiteralExpr [STRING] [n_nationkey]
                     :
                     FieldAccessor [
-                      Variable [ Name=n ]
+                      Variable [ Name=$n ]
                       Field=n_nationkey
                     ]
                   )
@@ -518,37 +518,37 @@ FunctionDecl tmp2([]) {
                     LiteralExpr [STRING] [n_name]
                     :
                     FieldAccessor [
-                      Variable [ Name=n ]
+                      Variable [ Name=$n ]
                       Field=n_name
                     ]
                   )
                 ]
                 ]
-                FROM [                  Variable [ Name=Region ]
+                FROM [                  Variable [ Name=$Region ]
                   AS
-                  Variable [ Name=r ]
+                  Variable [ Name=$r ]
 ,
-                  Variable [ Name=Nation ]
+                  Variable [ Name=$Nation ]
                   AS
-                  Variable [ Name=n ]
+                  Variable [ Name=$n ]
                 ]
                 Where
                   OperatorExpr [
                     OperatorExpr [
                       FieldAccessor [
-                        Variable [ Name=n ]
+                        Variable [ Name=$n ]
                         Field=n_regionkey
                       ]
                       =
                       FieldAccessor [
-                        Variable [ Name=r ]
+                        Variable [ Name=$r ]
                         Field=r_regionkey
                       ]
                     ]
                     and
                     OperatorExpr [
                       FieldAccessor [
-                        Variable [ Name=r ]
+                        Variable [ Name=$r ]
                         Field=r_name
                       ]
                       =
@@ -557,67 +557,67 @@ FunctionDecl tmp2([]) {
                   ]
               )
               AS
-              Variable [ Name=rn ]
+              Variable [ Name=$rn ]
             ]
             Where
               OperatorExpr [
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_nationkey
                 ]
                 =
                 FieldAccessor [
-                  Variable [ Name=rn ]
+                  Variable [ Name=$rn ]
                   Field=n_nationkey
                 ]
               ]
           )
           AS
-          Variable [ Name=srn ]
+          Variable [ Name=$srn ]
         ]
         Where
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=srn ]
+              Variable [ Name=$srn ]
               Field=s_suppkey
             ]
             =
             FieldAccessor [
-              Variable [ Name=ps ]
+              Variable [ Name=$ps ]
               Field=ps_suppkey
             ]
           ]
       )
       AS
-      Variable [ Name=pssrn ]
+      Variable [ Name=$pssrn ]
     ]
     Where
       OperatorExpr [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=p ]
+            Variable [ Name=$p ]
             Field=p_partkey
           ]
           =
           FieldAccessor [
-            Variable [ Name=pssrn ]
+            Variable [ Name=$pssrn ]
             Field=p_partkey
           ]
         ]
         and
         FunctionCall tpch.like@2[
           FieldAccessor [
-            Variable [ Name=p ]
+            Variable [ Name=$p ]
             Field=p_type
           ]
           LiteralExpr [STRING] [%BRASS]
         ]
       ]
     Groupby
-      Variable [ Name=p_partkey ]
+      Variable [ Name=$p_partkey ]
       :=
       FieldAccessor [
-        Variable [ Name=pssrn ]
+        Variable [ Name=$pssrn ]
         Field=p_partkey
       ]
 
@@ -631,7 +631,7 @@ RecordConstructor [
     LiteralExpr [STRING] [s_acctbal]
     :
     FieldAccessor [
-      Variable [ Name=t1 ]
+      Variable [ Name=$t1 ]
       Field=s_acctbal
     ]
   )
@@ -639,7 +639,7 @@ RecordConstructor [
     LiteralExpr [STRING] [s_name]
     :
     FieldAccessor [
-      Variable [ Name=t1 ]
+      Variable [ Name=$t1 ]
       Field=s_name
     ]
   )
@@ -647,7 +647,7 @@ RecordConstructor [
     LiteralExpr [STRING] [n_name]
     :
     FieldAccessor [
-      Variable [ Name=t1 ]
+      Variable [ Name=$t1 ]
       Field=n_name
     ]
   )
@@ -655,7 +655,7 @@ RecordConstructor [
     LiteralExpr [STRING] [p_partkey]
     :
     FieldAccessor [
-      Variable [ Name=t1 ]
+      Variable [ Name=$t1 ]
       Field=p_partkey
     ]
   )
@@ -663,7 +663,7 @@ RecordConstructor [
     LiteralExpr [STRING] [p_mfgr]
     :
     FieldAccessor [
-      Variable [ Name=t1 ]
+      Variable [ Name=$t1 ]
       Field=p_mfgr
     ]
   )
@@ -671,7 +671,7 @@ RecordConstructor [
     LiteralExpr [STRING] [s_address]
     :
     FieldAccessor [
-      Variable [ Name=t1 ]
+      Variable [ Name=$t1 ]
       Field=s_address
     ]
   )
@@ -679,7 +679,7 @@ RecordConstructor [
     LiteralExpr [STRING] [s_phone]
     :
     FieldAccessor [
-      Variable [ Name=t1 ]
+      Variable [ Name=$t1 ]
       Field=s_phone
     ]
   )
@@ -687,7 +687,7 @@ RecordConstructor [
     LiteralExpr [STRING] [s_comment]
     :
     FieldAccessor [
-      Variable [ Name=t1 ]
+      Variable [ Name=$t1 ]
       Field=s_comment
     ]
   )
@@ -696,57 +696,57 @@ RecordConstructor [
 FROM [  FunctionCall tpch.tmp2@0[
   ]
   AS
-  Variable [ Name=t2 ]
+  Variable [ Name=$t2 ]
 ,
   FunctionCall tpch.tmp1@0[
   ]
   AS
-  Variable [ Name=t1 ]
+  Variable [ Name=$t1 ]
 ]
 Where
   OperatorExpr [
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=t1 ]
+        Variable [ Name=$t1 ]
         Field=p_partkey
       ]
       =
       FieldAccessor [
-        Variable [ Name=t2 ]
+        Variable [ Name=$t2 ]
         Field=p_partkey
       ]
     ]
     and
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=t1 ]
+        Variable [ Name=$t1 ]
         Field=ps_supplycost
       ]
       =
       FieldAccessor [
-        Variable [ Name=t2 ]
+        Variable [ Name=$t2 ]
         Field=ps_min_supplycost
       ]
     ]
   ]
 Orderby
   FieldAccessor [
-    Variable [ Name=t1 ]
+    Variable [ Name=$t1 ]
     Field=s_acctbal
   ]
   DESC
   FieldAccessor [
-    Variable [ Name=t1 ]
+    Variable [ Name=$t1 ]
     Field=n_name
   ]
   ASC
   FieldAccessor [
-    Variable [ Name=t1 ]
+    Variable [ Name=$t1 ]
     Field=s_name
   ]
   ASC
   FieldAccessor [
-    Variable [ Name=t1 ]
+    Variable [ Name=$t1 ]
     Field=p_partkey
   ]
   ASC

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
index 8193892..5bb4ef8 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q03_shipping_priority_nt/q03_shipping_priority_nt.3.ast
@@ -5,22 +5,22 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [l_orderkey]
     :
-    Variable [ Name=l_orderkey ]
+    Variable [ Name=$l_orderkey ]
   )
   (
     LiteralExpr [STRING] [revenue]
     :
-    Variable [ Name=revenue ]
+    Variable [ Name=$revenue ]
   )
   (
     LiteralExpr [STRING] [o_orderdate]
     :
-    Variable [ Name=o_orderdate ]
+    Variable [ Name=$o_orderdate ]
   )
   (
     LiteralExpr [STRING] [o_shippriority]
     :
-    Variable [ Name=o_shippriority ]
+    Variable [ Name=$o_shippriority ]
   )
 ]
 ]
@@ -28,26 +28,26 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Customer]
   ]
   AS
-  Variable [ Name=c ]
+  Variable [ Name=$c ]
 ,
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Orders]
   ]
   AS
-  Variable [ Name=o ]
+  Variable [ Name=$o ]
 ,
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [LineItem]
   ]
   AS
-  Variable [ Name=l ]
+  Variable [ Name=$l ]
 ]
 Where
   OperatorExpr [
     OperatorExpr [
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=c ]
+          Variable [ Name=$c ]
           Field=c_mktsegment
         ]
         =
@@ -56,12 +56,12 @@ Where
       and
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=c ]
+          Variable [ Name=$c ]
           Field=c_custkey
         ]
         =
         FieldAccessor [
-          Variable [ Name=o ]
+          Variable [ Name=$o ]
           Field=o_custkey
         ]
       ]
@@ -70,19 +70,19 @@ Where
     OperatorExpr [
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=l ]
+          Variable [ Name=$l ]
           Field=l_orderkey
         ]
         =
         FieldAccessor [
-          Variable [ Name=o ]
+          Variable [ Name=$o ]
           Field=o_orderkey
         ]
       ]
       and
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=o ]
+          Variable [ Name=$o ]
           Field=o_orderdate
         ]
         <
@@ -91,7 +91,7 @@ Where
       and
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=l ]
+          Variable [ Name=$l ]
           Field=l_shipdate
         ]
         >
@@ -100,37 +100,43 @@ Where
     ]
   ]
 Groupby
-  Variable [ Name=l_orderkey ]
+  Variable [ Name=$l_orderkey ]
   :=
   FieldAccessor [
-    Variable [ Name=l ]
+    Variable [ Name=$l ]
     Field=l_orderkey
   ]
-  Variable [ Name=o_orderdate ]
+  Variable [ Name=$o_orderdate ]
   :=
   FieldAccessor [
-    Variable [ Name=o ]
+    Variable [ Name=$o ]
     Field=o_orderdate
   ]
-  Variable [ Name=o_shippriority ]
+  Variable [ Name=$o_shippriority ]
   :=
   FieldAccessor [
-    Variable [ Name=o ]
+    Variable [ Name=$o ]
     Field=o_shippriority
   ]
-  With
-  Variable [ Name=c ]
-  Variable [ Name=l ]
-  Variable [ Name=o ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$l ]
+   AS l
+  Variable [ Name=$o ]
+   AS o
+  Variable [ Name=$c ]
+   AS c
+  )
 
-LetVariable [ Name=revenue ]
+Let Variable [ Name=$revenue ]
   :=
   FunctionCall tpch.sum@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=l_extendedprice
         ]
         *
@@ -138,22 +144,22 @@ LetVariable [ Name=revenue ]
           LiteralExpr [LONG] [1]
           -
           FieldAccessor [
-            Variable [ Name=i ]
+            Variable [ Name=$i ]
             Field=l_discount
           ]
         ]
       ]
       ]
-      FROM [        Variable [ Name=l ]
+      FROM [        Variable [ Name=$l ]
         AS
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
       ]
     )
   ]
 Orderby
-  Variable [ Name=revenue ]
+  Variable [ Name=$revenue ]
   DESC
-  Variable [ Name=o_orderdate ]
+  Variable [ Name=$o_orderdate ]
   ASC
 
 Limit

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.3.ast
index 2f4234e..b9aa68f 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q04_order_priority/q04_order_priority.3.ast
@@ -7,25 +7,25 @@ FunctionDecl tmp([]) {
         LiteralExpr [STRING] [o_orderkey]
         :
         FieldAccessor [
-          Variable [ Name=l ]
+          Variable [ Name=$l ]
           Field=l_orderkey
         ]
       )
     ]
     ]
-    FROM [      Variable [ Name=LineItem ]
+    FROM [      Variable [ Name=$LineItem ]
       AS
-      Variable [ Name=l ]
+      Variable [ Name=$l ]
     ]
     Where
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=l ]
+          Variable [ Name=$l ]
           Field=l_commitdate
         ]
         <
         FieldAccessor [
-          Variable [ Name=l ]
+          Variable [ Name=$l ]
           Field=l_receiptdate
         ]
       ]
@@ -38,13 +38,24 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [order_priority]
     :
-    Variable [ Name=o_orderpriority ]
+    Variable [ Name=$o_orderpriority ]
   )
   (
     LiteralExpr [STRING] [count]
     :
     FunctionCall tpch.count@1[
-      Variable [ Name=o ]
+      (
+        SELECT ELEMENT [
+        FieldAccessor [
+          Variable [ Name=#2 ]
+          Field=o
+        ]
+        ]
+        FROM [          Variable [ Name=#1 ]
+          AS
+          Variable [ Name=#2 ]
+        ]
+      )
     ]
   )
 ]
@@ -53,21 +64,21 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Orders]
   ]
   AS
-  Variable [ Name=o ]
+  Variable [ Name=$o ]
   INNER JOIN
     FunctionCall tpch.tmp@0[
     ]
     AS
-    Variable [ Name=t ]
+    Variable [ Name=$t ]
     ON
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=o ]
+        Variable [ Name=$o ]
         Field=o_orderkey
       ]
       =
       FieldAccessor [
-        Variable [ Name=t ]
+        Variable [ Name=$t ]
         Field=o_orderkey
       ]
     ]
@@ -76,7 +87,7 @@ Where
   OperatorExpr [
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=o ]
+        Variable [ Name=$o ]
         Field=o_orderdate
       ]
       >=
@@ -85,7 +96,7 @@ Where
     and
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=o ]
+        Variable [ Name=$o ]
         Field=o_orderdate
       ]
       <
@@ -93,17 +104,22 @@ Where
     ]
   ]
 Groupby
-  Variable [ Name=o_orderpriority ]
+  Variable [ Name=$o_orderpriority ]
   :=
   FieldAccessor [
-    Variable [ Name=o ]
+    Variable [ Name=$o ]
     Field=o_orderpriority
   ]
-  With
-  Variable [ Name=t ]
-  Variable [ Name=o ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$t ]
+   AS t
+  Variable [ Name=$o ]
+   AS o
+  )
 
 Orderby
-  Variable [ Name=o_orderpriority ]
+  Variable [ Name=$o_orderpriority ]
   ASC
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
index 2b505fb..92d992a 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q05_local_supplier_volume/q05_local_supplier_volume.3.ast
@@ -5,12 +5,12 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [n_name]
     :
-    Variable [ Name=n_name ]
+    Variable [ Name=$n_name ]
   )
   (
     LiteralExpr [STRING] [revenue]
     :
-    Variable [ Name=revenue ]
+    Variable [ Name=$revenue ]
   )
 ]
 ]
@@ -18,7 +18,7 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Customer]
   ]
   AS
-  Variable [ Name=c ]
+  Variable [ Name=$c ]
 ,
   (
     SELECT ELEMENT [
@@ -27,7 +27,7 @@ FROM [  FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [n_name]
         :
         FieldAccessor [
-          Variable [ Name=l1 ]
+          Variable [ Name=$l1 ]
           Field=n_name
         ]
       )
@@ -35,7 +35,7 @@ FROM [  FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [l_extendedprice]
         :
         FieldAccessor [
-          Variable [ Name=l1 ]
+          Variable [ Name=$l1 ]
           Field=l_extendedprice
         ]
       )
@@ -43,7 +43,7 @@ FROM [  FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [l_discount]
         :
         FieldAccessor [
-          Variable [ Name=l1 ]
+          Variable [ Name=$l1 ]
           Field=l_discount
         ]
       )
@@ -51,7 +51,7 @@ FROM [  FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [s_nationkey]
         :
         FieldAccessor [
-          Variable [ Name=l1 ]
+          Variable [ Name=$l1 ]
           Field=s_nationkey
         ]
       )
@@ -59,7 +59,7 @@ FROM [  FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [o_custkey]
         :
         FieldAccessor [
-          Variable [ Name=o ]
+          Variable [ Name=$o ]
           Field=o_custkey
         ]
       )
@@ -69,7 +69,7 @@ FROM [  FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [Orders]
       ]
       AS
-      Variable [ Name=o ]
+      Variable [ Name=$o ]
 ,
       (
         SELECT ELEMENT [
@@ -78,7 +78,7 @@ FROM [  FunctionCall Metadata.dataset@1[
             LiteralExpr [STRING] [n_name]
             :
             FieldAccessor [
-              Variable [ Name=s1 ]
+              Variable [ Name=$s1 ]
               Field=n_name
             ]
           )
@@ -86,7 +86,7 @@ FROM [  FunctionCall Metadata.dataset@1[
             LiteralExpr [STRING] [l_extendedprice]
             :
             FieldAccessor [
-              Variable [ Name=l ]
+              Variable [ Name=$l ]
               Field=l_extendedprice
             ]
           )
@@ -94,7 +94,7 @@ FROM [  FunctionCall Metadata.dataset@1[
             LiteralExpr [STRING] [l_discount]
             :
             FieldAccessor [
-              Variable [ Name=l ]
+              Variable [ Name=$l ]
               Field=l_discount
             ]
           )
@@ -102,7 +102,7 @@ FROM [  FunctionCall Metadata.dataset@1[
             LiteralExpr [STRING] [l_orderkey]
             :
             FieldAccessor [
-              Variable [ Name=l ]
+              Variable [ Name=$l ]
               Field=l_orderkey
             ]
           )
@@ -110,7 +110,7 @@ FROM [  FunctionCall Metadata.dataset@1[
             LiteralExpr [STRING] [s_nationkey]
             :
             FieldAccessor [
-              Variable [ Name=s1 ]
+              Variable [ Name=$s1 ]
               Field=s_nationkey
             ]
           )
@@ -120,7 +120,7 @@ FROM [  FunctionCall Metadata.dataset@1[
             LiteralExpr [STRING] [LineItem]
           ]
           AS
-          Variable [ Name=l ]
+          Variable [ Name=$l ]
 ,
           (
             SELECT ELEMENT [
@@ -129,7 +129,7 @@ FROM [  FunctionCall Metadata.dataset@1[
                 LiteralExpr [STRING] [n_name]
                 :
                 FieldAccessor [
-                  Variable [ Name=n1 ]
+                  Variable [ Name=$n1 ]
                   Field=n_name
                 ]
               )
@@ -137,7 +137,7 @@ FROM [  FunctionCall Metadata.dataset@1[
                 LiteralExpr [STRING] [s_suppkey]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_suppkey
                 ]
               )
@@ -145,7 +145,7 @@ FROM [  FunctionCall Metadata.dataset@1[
                 LiteralExpr [STRING] [s_nationkey]
                 :
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_nationkey
                 ]
               )
@@ -155,7 +155,7 @@ FROM [  FunctionCall Metadata.dataset@1[
                 LiteralExpr [STRING] [Supplier]
               ]
               AS
-              Variable [ Name=s ]
+              Variable [ Name=$s ]
 ,
               (
                 SELECT ELEMENT [
@@ -164,7 +164,7 @@ FROM [  FunctionCall Metadata.dataset@1[
                     LiteralExpr [STRING] [n_name]
                     :
                     FieldAccessor [
-                      Variable [ Name=n ]
+                      Variable [ Name=$n ]
                       Field=n_name
                     ]
                   )
@@ -172,7 +172,7 @@ FROM [  FunctionCall Metadata.dataset@1[
                     LiteralExpr [STRING] [n_nationkey]
                     :
                     FieldAccessor [
-                      Variable [ Name=n ]
+                      Variable [ Name=$n ]
                       Field=n_nationkey
                     ]
                   )
@@ -182,79 +182,79 @@ FROM [  FunctionCall Metadata.dataset@1[
                     LiteralExpr [STRING] [Nation]
                   ]
                   AS
-                  Variable [ Name=n ]
+                  Variable [ Name=$n ]
 ,
                   FunctionCall Metadata.dataset@1[
                     LiteralExpr [STRING] [Region]
                   ]
                   AS
-                  Variable [ Name=r ]
+                  Variable [ Name=$r ]
                 ]
                 Where
                   OperatorExpr [
                     FieldAccessor [
-                      Variable [ Name=n ]
+                      Variable [ Name=$n ]
                       Field=n_regionkey
                     ]
                     =
                     FieldAccessor [
-                      Variable [ Name=r ]
+                      Variable [ Name=$r ]
                       Field=r_regionkey
                     ]
                   ]
               )
               AS
-              Variable [ Name=n1 ]
+              Variable [ Name=$n1 ]
             ]
             Where
               OperatorExpr [
                 FieldAccessor [
-                  Variable [ Name=s ]
+                  Variable [ Name=$s ]
                   Field=s_nationkey
                 ]
                 =
                 FieldAccessor [
-                  Variable [ Name=n1 ]
+                  Variable [ Name=$n1 ]
                   Field=n_nationkey
                 ]
               ]
           )
           AS
-          Variable [ Name=s1 ]
+          Variable [ Name=$s1 ]
         ]
         Where
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=l ]
+              Variable [ Name=$l ]
               Field=l_suppkey
             ]
             =
             FieldAccessor [
-              Variable [ Name=s1 ]
+              Variable [ Name=$s1 ]
               Field=s_suppkey
             ]
           ]
       )
       AS
-      Variable [ Name=l1 ]
+      Variable [ Name=$l1 ]
     ]
     Where
       OperatorExpr [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=l1 ]
+            Variable [ Name=$l1 ]
             Field=l_orderkey
           ]
           =
           FieldAccessor [
-            Variable [ Name=o ]
+            Variable [ Name=$o ]
             Field=o_orderkey
           ]
         ]
         and
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=o ]
+            Variable [ Name=$o ]
             Field=o_orderdate
           ]
           >=
@@ -263,7 +263,7 @@ FROM [  FunctionCall Metadata.dataset@1[
         and
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=o ]
+            Variable [ Name=$o ]
             Field=o_orderdate
           ]
           <
@@ -272,53 +272,58 @@ FROM [  FunctionCall Metadata.dataset@1[
       ]
   )
   AS
-  Variable [ Name=o1 ]
+  Variable [ Name=$o1 ]
 ]
 Where
   OperatorExpr [
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=c ]
+        Variable [ Name=$c ]
         Field=c_nationkey
       ]
       =
       FieldAccessor [
-        Variable [ Name=o1 ]
+        Variable [ Name=$o1 ]
         Field=s_nationkey
       ]
     ]
     and
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=c ]
+        Variable [ Name=$c ]
         Field=c_custkey
       ]
       =
       FieldAccessor [
-        Variable [ Name=o1 ]
+        Variable [ Name=$o1 ]
         Field=o_custkey
       ]
     ]
   ]
 Groupby
-  Variable [ Name=n_name ]
+  Variable [ Name=$n_name ]
   :=
   FieldAccessor [
-    Variable [ Name=o1 ]
+    Variable [ Name=$o1 ]
     Field=n_name
   ]
-  With
-  Variable [ Name=o1 ]
-  Variable [ Name=c ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$o1 ]
+   AS o1
+  Variable [ Name=$c ]
+   AS c
+  )
 
-LetVariable [ Name=revenue ]
+Let Variable [ Name=$revenue ]
   :=
   FunctionCall tpch.sum@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=l_extendedprice
         ]
         *
@@ -326,19 +331,19 @@ LetVariable [ Name=revenue ]
           LiteralExpr [LONG] [1]
           -
           FieldAccessor [
-            Variable [ Name=i ]
+            Variable [ Name=$i ]
             Field=l_discount
           ]
         ]
       ]
       ]
-      FROM [        Variable [ Name=o1 ]
+      FROM [        Variable [ Name=$o1 ]
         AS
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
       ]
     )
   ]
 Orderby
-  Variable [ Name=revenue ]
+  Variable [ Name=$revenue ]
   DESC
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
index f802e5e..592238f 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q06_forecast_revenue_change/q06_forecast_revenue_change.3.ast
@@ -9,12 +9,12 @@ RecordConstructor [
         SELECT ELEMENT [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=l ]
+            Variable [ Name=$l ]
             Field=l_extendedprice
           ]
           *
           FieldAccessor [
-            Variable [ Name=l ]
+            Variable [ Name=$l ]
             Field=l_discount
           ]
         ]
@@ -23,13 +23,13 @@ RecordConstructor [
             LiteralExpr [STRING] [LineItem]
           ]
           AS
-          Variable [ Name=l ]
+          Variable [ Name=$l ]
         ]
         Where
           OperatorExpr [
             OperatorExpr [
               FieldAccessor [
-                Variable [ Name=l ]
+                Variable [ Name=$l ]
                 Field=l_shipdate
               ]
               >=
@@ -38,7 +38,7 @@ RecordConstructor [
             and
             OperatorExpr [
               FieldAccessor [
-                Variable [ Name=l ]
+                Variable [ Name=$l ]
                 Field=l_shipdate
               ]
               <
@@ -47,7 +47,7 @@ RecordConstructor [
             and
             OperatorExpr [
               FieldAccessor [
-                Variable [ Name=l ]
+                Variable [ Name=$l ]
                 Field=l_discount
               ]
               >=
@@ -56,7 +56,7 @@ RecordConstructor [
             and
             OperatorExpr [
               FieldAccessor [
-                Variable [ Name=l ]
+                Variable [ Name=$l ]
                 Field=l_discount
               ]
               <=
@@ -65,7 +65,7 @@ RecordConstructor [
             and
             OperatorExpr [
               FieldAccessor [
-                Variable [ Name=l ]
+                Variable [ Name=$l ]
                 Field=l_quantity
               ]
               <

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.ast b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.ast
index deed492..ac8fbda 100644
--- a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.ast
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q07_volume_shipping/q07_volume_shipping.3.ast
@@ -7,7 +7,7 @@ FunctionDecl q7_volume_shipping_tmp([]) {
         LiteralExpr [STRING] [supp_nation]
         :
         FieldAccessor [
-          Variable [ Name=n1 ]
+          Variable [ Name=$n1 ]
           Field=n_name
         ]
       )
@@ -15,7 +15,7 @@ FunctionDecl q7_volume_shipping_tmp([]) {
         LiteralExpr [STRING] [cust_nation]
         :
         FieldAccessor [
-          Variable [ Name=n2 ]
+          Variable [ Name=$n2 ]
           Field=n_name
         ]
       )
@@ -23,7 +23,7 @@ FunctionDecl q7_volume_shipping_tmp([]) {
         LiteralExpr [STRING] [s_nationkey]
         :
         FieldAccessor [
-          Variable [ Name=n1 ]
+          Variable [ Name=$n1 ]
           Field=n_nationkey
         ]
       )
@@ -31,25 +31,25 @@ FunctionDecl q7_volume_shipping_tmp([]) {
         LiteralExpr [STRING] [c_nationkey]
         :
         FieldAccessor [
-          Variable [ Name=n2 ]
+          Variable [ Name=$n2 ]
           Field=n_nationkey
         ]
       )
     ]
     ]
-    FROM [      Variable [ Name=Nation ]
+    FROM [      Variable [ Name=$Nation ]
       AS
-      Variable [ Name=n1 ]
+      Variable [ Name=$n1 ]
 ,
-      Variable [ Name=Nation ]
+      Variable [ Name=$Nation ]
       AS
-      Variable [ Name=n2 ]
+      Variable [ Name=$n2 ]
     ]
     Where
       OperatorExpr [
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=n2 ]
+            Variable [ Name=$n2 ]
             Field=n_name
           ]
           =
@@ -58,7 +58,7 @@ FunctionDecl q7_volume_shipping_tmp([]) {
         or
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=n1 ]
+            Variable [ Name=$n1 ]
             Field=n_name
           ]
           =
@@ -74,22 +74,22 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [supp_nation]
     :
-    Variable [ Name=supp_nation ]
+    Variable [ Name=$supp_nation ]
   )
   (
     LiteralExpr [STRING] [cust_nation]
     :
-    Variable [ Name=cust_nation ]
+    Variable [ Name=$cust_nation ]
   )
   (
     LiteralExpr [STRING] [l_year]
     :
-    Variable [ Name=l_year ]
+    Variable [ Name=$l_year ]
   )
   (
     LiteralExpr [STRING] [revenue]
     :
-    Variable [ Name=revenue ]
+    Variable [ Name=$revenue ]
   )
 ]
 ]
@@ -100,7 +100,7 @@ FROM [  (
         LiteralExpr [STRING] [l_shipdate]
         :
         FieldAccessor [
-          Variable [ Name=loc ]
+          Variable [ Name=$loc ]
           Field=l_shipdate
         ]
       )
@@ -108,7 +108,7 @@ FROM [  (
         LiteralExpr [STRING] [l_extendedprice]
         :
         FieldAccessor [
-          Variable [ Name=loc ]
+          Variable [ Name=$loc ]
           Field=l_extendedprice
         ]
       )
@@ -116,7 +116,7 @@ FROM [  (
         LiteralExpr [STRING] [l_discount]
         :
         FieldAccessor [
-          Variable [ Name=loc ]
+          Variable [ Name=$loc ]
           Field=l_discount
         ]
       )
@@ -124,7 +124,7 @@ FROM [  (
         LiteralExpr [STRING] [c_nationkey]
         :
         FieldAccessor [
-          Variable [ Name=loc ]
+          Variable [ Name=$loc ]
           Field=c_nationkey
         ]
       )
@@ -132,7 +132,7 @@ FROM [  (
         LiteralExpr [STRING] [s_nationkey]
         :
         FieldAccessor [
-          Variable [ Name=s ]
+          Variable [ Name=$s ]
           Field=s_nationkey
         ]
       )
@@ -145,7 +145,7 @@ FROM [  (
             LiteralExpr [STRING] [l_shipdate]
             :
             FieldAccessor [
-              Variable [ Name=lo ]
+              Variable [ Name=$lo ]
               Field=l_shipdate
             ]
           )
@@ -153,7 +153,7 @@ FROM [  (
             LiteralExpr [STRING] [l_extendedprice]
             :
             FieldAccessor [
-              Variable [ Name=lo ]
+              Variable [ Name=$lo ]
               Field=l_extendedprice
             ]
           )
@@ -161,7 +161,7 @@ FROM [  (
             LiteralExpr [STRING] [l_discount]
             :
             FieldAccessor [
-              Variable [ Name=lo ]
+              Variable [ Name=$lo ]
               Field=l_discount
             ]
           )
@@ -169,7 +169,7 @@ FROM [  (
             LiteralExpr [STRING] [l_suppkey]
             :
             FieldAccessor [
-              Variable [ Name=lo ]
+              Variable [ Name=$lo ]
               Field=l_suppkey
             ]
           )
@@ -177,7 +177,7 @@ FROM [  (
             LiteralExpr [STRING] [c_nationkey]
             :
             FieldAccessor [
-              Variable [ Name=c ]
+              Variable [ Name=$c ]
               Field=c_nationkey
             ]
           )
@@ -190,7 +190,7 @@ FROM [  (
                 LiteralExpr [STRING] [l_shipdate]
                 :
                 FieldAccessor [
-                  Variable [ Name=l ]
+                  Variable [ Name=$l ]
                   Field=l_shipdate
                 ]
               )
@@ -198,7 +198,7 @@ FROM [  (
                 LiteralExpr [STRING] [l_extendedprice]
                 :
                 FieldAccessor [
-                  Variable [ Name=l ]
+                  Variable [ Name=$l ]
                   Field=l_extendedprice
                 ]
               )
@@ -206,7 +206,7 @@ FROM [  (
                 LiteralExpr [STRING] [l_discount]
                 :
                 FieldAccessor [
-                  Variable [ Name=l ]
+                  Variable [ Name=$l ]
                   Field=l_discount
                 ]
               )
@@ -214,7 +214,7 @@ FROM [  (
                 LiteralExpr [STRING] [l_suppkey]
                 :
                 FieldAccessor [
-                  Variable [ Name=l ]
+                  Variable [ Name=$l ]
                   Field=l_suppkey
                 ]
               )
@@ -222,7 +222,7 @@ FROM [  (
                 LiteralExpr [STRING] [o_custkey]
                 :
                 FieldAccessor [
-                  Variable [ Name=o ]
+                  Variable [ Name=$o ]
                   Field=o_custkey
                 ]
               )
@@ -232,31 +232,31 @@ FROM [  (
                 LiteralExpr [STRING] [LineItem]
               ]
               AS
-              Variable [ Name=l ]
+              Variable [ Name=$l ]
 ,
               FunctionCall Metadata.dataset@1[
                 LiteralExpr [STRING] [Orders]
               ]
               AS
-              Variable [ Name=o ]
+              Variable [ Name=$o ]
             ]
             Where
               OperatorExpr [
                 OperatorExpr [
                   FieldAccessor [
-                    Variable [ Name=o ]
+                    Variable [ Name=$o ]
                     Field=o_orderkey
                   ]
                   =
                   FieldAccessor [
-                    Variable [ Name=l ]
+                    Variable [ Name=$l ]
                     Field=l_orderkey
                   ]
                 ]
                 and
                 OperatorExpr [
                   FieldAccessor [
-                    Variable [ Name=l ]
+                    Variable [ Name=$l ]
                     Field=l_shipdate
                   ]
                   >=
@@ -265,7 +265,7 @@ FROM [  (
                 and
                 OperatorExpr [
                   FieldAccessor [
-                    Variable [ Name=l ]
+                    Variable [ Name=$l ]
                     Field=l_shipdate
                   ]
                   <=
@@ -274,62 +274,62 @@ FROM [  (
               ]
           )
           AS
-          Variable [ Name=lo ]
+          Variable [ Name=$lo ]
 ,
           FunctionCall Metadata.dataset@1[
             LiteralExpr [STRING] [Customer]
           ]
           AS
-          Variable [ Name=c ]
+          Variable [ Name=$c ]
         ]
         Where
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=c ]
+              Variable [ Name=$c ]
               Field=c_custkey
             ]
             =
             FieldAccessor [
-              Variable [ Name=lo ]
+              Variable [ Name=$lo ]
               Field=o_custkey
             ]
           ]
       )
       AS
-      Variable [ Name=loc ]
+      Variable [ Name=$loc ]
 ,
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [Supplier]
       ]
       AS
-      Variable [ Name=s ]
+      Variable [ Name=$s ]
     ]
     Where
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=s ]
+          Variable [ Name=$s ]
           Field=s_suppkey
         ]
         =
         FieldAccessor [
-          Variable [ Name=loc ]
+          Variable [ Name=$loc ]
           Field=l_suppkey
         ]
       ]
   )
   AS
-  Variable [ Name=locs ]
+  Variable [ Name=$locs ]
 ,
   FunctionCall tpch.q7_volume_shipping_tmp@0[
   ]
   AS
-  Variable [ Name=t ]
+  Variable [ Name=$t ]
 ]
-LetVariable [ Name=l_year0 ]
+Let Variable [ Name=$l_year0 ]
   :=
   FunctionCall tpch.get-year@1[
     FieldAccessor [
-      Variable [ Name=locs ]
+      Variable [ Name=$locs ]
       Field=l_shipdate
     ]
   ]
@@ -337,57 +337,63 @@ Where
   OperatorExpr [
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=locs ]
+        Variable [ Name=$locs ]
         Field=c_nationkey
       ]
       =
       FieldAccessor [
-        Variable [ Name=t ]
+        Variable [ Name=$t ]
         Field=c_nationkey
       ]
     ]
     and
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=locs ]
+        Variable [ Name=$locs ]
         Field=s_nationkey
       ]
       =
       FieldAccessor [
-        Variable [ Name=t ]
+        Variable [ Name=$t ]
         Field=s_nationkey
       ]
     ]
   ]
 Groupby
-  Variable [ Name=supp_nation ]
+  Variable [ Name=$supp_nation ]
   :=
   FieldAccessor [
-    Variable [ Name=t ]
+    Variable [ Name=$t ]
     Field=supp_nation
   ]
-  Variable [ Name=cust_nation ]
+  Variable [ Name=$cust_nation ]
   :=
   FieldAccessor [
-    Variable [ Name=t ]
+    Variable [ Name=$t ]
     Field=cust_nation
   ]
-  Variable [ Name=l_year ]
+  Variable [ Name=$l_year ]
   :=
-  Variable [ Name=l_year0 ]
-  With
-  Variable [ Name=l_year0 ]
-  Variable [ Name=locs ]
-  Variable [ Name=t ]
+  Variable [ Name=$l_year0 ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$l_year0 ]
+   AS l_year0
+  Variable [ Name=$t ]
+   AS t
+  Variable [ Name=$locs ]
+   AS locs
+  )
 
-LetVariable [ Name=revenue ]
+Let Variable [ Name=$revenue ]
   :=
   FunctionCall tpch.sum@1[
     (
       SELECT ELEMENT [
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=l_extendedprice
         ]
         *
@@ -395,23 +401,23 @@ LetVariable [ Name=revenue ]
           LiteralExpr [LONG] [1]
           -
           FieldAccessor [
-            Variable [ Name=i ]
+            Variable [ Name=$i ]
             Field=l_discount
           ]
         ]
       ]
       ]
-      FROM [        Variable [ Name=locs ]
+      FROM [        Variable [ Name=$locs ]
         AS
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
       ]
     )
   ]
 Orderby
-  Variable [ Name=supp_nation ]
+  Variable [ Name=$supp_nation ]
   ASC
-  Variable [ Name=cust_nation ]
+  Variable [ Name=$cust_nation ]
   ASC
-  Variable [ Name=l_year ]
+  Variable [ Name=$l_year ]
   ASC