asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [33/51] [partial] incubator-asterixdb git commit: ASTERIXDB-1226: implement SQL++ core group-by semantics and syntatic sugars.
Date Mon, 28 Mar 2016 20:19:00 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-2.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-2.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-2.ast
index c55e4a6..c534506 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-2.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index-2.ast
@@ -10,19 +10,19 @@ TypeDecl TestType [
 DatasetDecl testdst(TestType) partitioned by [[id]]
 Query:
 SELECT ELEMENT [
-Variable [ Name=emp ]
+Variable [ Name=$emp ]
 ]
 FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [testdst]
   ]
   AS
-  Variable [ Name=emp ]
+  Variable [ Name=$emp ]
 ]
 Where
   OperatorExpr [
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=emp ]
+        Variable [ Name=$emp ]
         Field=fname
       ]
       >=
@@ -31,7 +31,7 @@ Where
     and
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=emp ]
+        Variable [ Name=$emp ]
         Field=fname
       ]
       <=

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index.ast
index c55e4a6..c534506 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-secondary-btree-index.ast
@@ -10,19 +10,19 @@ TypeDecl TestType [
 DatasetDecl testdst(TestType) partitioned by [[id]]
 Query:
 SELECT ELEMENT [
-Variable [ Name=emp ]
+Variable [ Name=$emp ]
 ]
 FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [testdst]
   ]
   AS
-  Variable [ Name=emp ]
+  Variable [ Name=$emp ]
 ]
 Where
   OperatorExpr [
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=emp ]
+        Variable [ Name=$emp ]
         Field=fname
       ]
       >=
@@ -31,7 +31,7 @@ Where
     and
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=emp ]
+        Variable [ Name=$emp ]
         Field=fname
       ]
       <=

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index.ast
index e9bf2f5..1212e22 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/skip-index/skip-word-index.ast
@@ -12,20 +12,20 @@ DatasetDecl DBLP(DBLPType) partitioned by [[id]]
 WriteOutputTo asterix_nc1:rttest/inverted-index-basic_word-jaccard.adm
 Query:
 SELECT ELEMENT [
-Variable [ Name=o ]
+Variable [ Name=$o ]
 ]
 FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [DBLP]
   ]
   AS
-  Variable [ Name=o ]
+  Variable [ Name=$o ]
 ]
-LetVariable [ Name=jacc ]
+Let Variable [ Name=$jacc ]
   :=
   FunctionCall test.similarity-jaccard@2[
     FunctionCall test.word-tokens@1[
       FieldAccessor [
-        Variable [ Name=o ]
+        Variable [ Name=$o ]
         Field=title
       ]
     ]
@@ -35,7 +35,7 @@ LetVariable [ Name=jacc ]
   ]
 Where
   OperatorExpr [
-    Variable [ Name=jacc ]
+    Variable [ Name=$jacc ]
     >=
     LiteralExpr [FLOAT] [0.5]
   ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/sort-cust.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/sort-cust.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/sort-cust.ast
index 3be6afa..b9baf55 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/sort-cust.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/sort-cust.ast
@@ -28,7 +28,7 @@ RecordConstructor [
     LiteralExpr [STRING] [custname]
     :
     FieldAccessor [
-      Variable [ Name=c ]
+      Variable [ Name=$c ]
       Field=name
     ]
   )
@@ -36,7 +36,7 @@ RecordConstructor [
     LiteralExpr [STRING] [custage]
     :
     FieldAccessor [
-      Variable [ Name=c ]
+      Variable [ Name=$c ]
       Field=age
     ]
   )
@@ -46,11 +46,11 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Customers]
   ]
   AS
-  Variable [ Name=c ]
+  Variable [ Name=$c ]
 ]
 Orderby
   FieldAccessor [
-    Variable [ Name=c ]
+    Variable [ Name=$c ]
     Field=age
   ]
   ASC

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization-above-join.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization-above-join.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization-above-join.ast
index 41669f9..80a8ba9 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization-above-join.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization-above-join.ast
@@ -16,18 +16,18 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [left]
     :
-    Variable [ Name=paperLeft ]
+    Variable [ Name=$paperLeft ]
   )
   (
     LiteralExpr [STRING] [right]
     :
-    Variable [ Name=paperRight ]
+    Variable [ Name=$paperRight ]
   )
   (
     LiteralExpr [STRING] [sim]
     :
     FieldAccessor [
-      Variable [ Name=ridpair ]
+      Variable [ Name=$ridpair ]
       Field=sim
     ]
   )
@@ -37,13 +37,13 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [DBLP]
   ]
   AS
-  Variable [ Name=paperLeft ]
+  Variable [ Name=$paperLeft ]
 ,
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [DBLP]
   ]
   AS
-  Variable [ Name=paperRight ]
+  Variable [ Name=$paperRight ]
 ,
   (
     SELECT ELEMENT [
@@ -51,18 +51,18 @@ FROM [  FunctionCall Metadata.dataset@1[
       (
         LiteralExpr [STRING] [idLeft]
         :
-        Variable [ Name=idLeft ]
+        Variable [ Name=$idLeft ]
       )
       (
         LiteralExpr [STRING] [idRight]
         :
-        Variable [ Name=idRight ]
+        Variable [ Name=$idRight ]
       )
       (
         LiteralExpr [STRING] [sim]
         :
         IndexAccessor [
-          Variable [ Name=sim ]
+          Variable [ Name=$sim ]
           Index:           LiteralExpr [LONG] [0]
         ]
       )
@@ -72,7 +72,7 @@ FROM [  FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [DBLP]
       ]
       AS
-      Variable [ Name=paperLeft ]
+      Variable [ Name=$paperLeft ]
 ,
       FunctionCall fuzzyjoin.subset-collection@3[
         FunctionCall Metadata.dataset@1[
@@ -87,13 +87,13 @@ FROM [  FunctionCall Metadata.dataset@1[
         ]
       ]
       AS
-      Variable [ Name=prefixTokenLeft ]
+      Variable [ Name=$prefixTokenLeft ]
 ,
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [DBLP]
       ]
       AS
-      Variable [ Name=paperRight ]
+      Variable [ Name=$paperRight ]
 ,
       FunctionCall fuzzyjoin.subset-collection@3[
         FunctionCall Metadata.dataset@1[
@@ -108,276 +108,334 @@ FROM [  FunctionCall Metadata.dataset@1[
         ]
       ]
       AS
-      Variable [ Name=prefixTokenRight ]
+      Variable [ Name=$prefixTokenRight ]
     ]
-    LetVariable [ Name=lenLeft ]
+    Let Variable [ Name=$lenLeft ]
       :=
       FunctionCall fuzzyjoin.len@1[
         FunctionCall fuzzyjoin.counthashed-word-tokens@1[
           FieldAccessor [
-            Variable [ Name=paperLeft ]
+            Variable [ Name=$paperLeft ]
             Field=title
           ]
         ]
       ]
-    LetVariable [ Name=tokensLeft ]
+    Let Variable [ Name=$tokensLeft ]
       :=
       (
         SELECT ELEMENT [
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
         ]
         FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
             FieldAccessor [
-              Variable [ Name=paperLeft ]
+              Variable [ Name=$paperLeft ]
               Field=title
             ]
           ]
           AS
-          Variable [ Name=tokenUnranked ]
+          Variable [ Name=$tokenUnranked ]
 ,
           (
             SELECT ELEMENT [
-            Variable [ Name=tokenGroupped ]
+            Variable [ Name=$tokenGroupped ]
             ]
             FROM [              FunctionCall Metadata.dataset@1[
                 LiteralExpr [STRING] [DBLP]
               ]
               AS
-              Variable [ Name=paper ]
+              Variable [ Name=$paper ]
 ,
               FunctionCall fuzzyjoin.counthashed-word-tokens@1[
                 FieldAccessor [
-                  Variable [ Name=paper ]
+                  Variable [ Name=$paper ]
                   Field=title
                 ]
               ]
               AS
-              Variable [ Name=token ]
+              Variable [ Name=$token ]
             ]
             Groupby
-              Variable [ Name=tokenGroupped ]
+              Variable [ Name=$tokenGroupped ]
               :=
-              Variable [ Name=token ]
-              With
-              Variable [ Name=paper ]
-              Variable [ Name=token ]
-              Variable [ Name=tokenUnranked ]
-              Variable [ Name=lenLeft ]
-              Variable [ Name=paperLeft ]
-              Variable [ Name=paperRight ]
-              Variable [ Name=prefixTokenRight ]
-              Variable [ Name=prefixTokenLeft ]
+              Variable [ Name=$token ]
+              GROUP AS
+              Variable [ Name=#1 ]
+              (
+              Variable [ Name=$token ]
+               AS token
+              Variable [ Name=$paper ]
+               AS paper
+              Variable [ Name=$tokenUnranked ]
+               AS tokenUnranked
+              Variable [ Name=$lenLeft ]
+               AS lenLeft
+              Variable [ Name=$prefixTokenRight ]
+               AS prefixTokenRight
+              Variable [ Name=$paperRight ]
+               AS paperRight
+              Variable [ Name=$prefixTokenLeft ]
+               AS prefixTokenLeft
+              Variable [ Name=$paperLeft ]
+               AS paperLeft
+              )
 
             Orderby
               FunctionCall fuzzyjoin.count@1[
-                Variable [ Name=paper ]
+                (
+                  SELECT ELEMENT [
+                  FieldAccessor [
+                    Variable [ Name=#2 ]
+                    Field=paper
+                  ]
+                  ]
+                  FROM [                    Variable [ Name=#1 ]
+                    AS
+                    Variable [ Name=#2 ]
+                  ]
+                )
               ]
               ASC
-              Variable [ Name=tokenGroupped ]
+              Variable [ Name=$tokenGroupped ]
               ASC
 
           )
           AS
-          Variable [ Name=tokenRanked ]
+          Variable [ Name=$tokenRanked ]
           AT
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
         Where
           OperatorExpr [
-            Variable [ Name=tokenUnranked ]
+            Variable [ Name=$tokenUnranked ]
             =
-            Variable [ Name=tokenRanked ]
+            Variable [ Name=$tokenRanked ]
           ]
         Orderby
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           ASC
 
       )
-    LetVariable [ Name=lenRight ]
+    Let Variable [ Name=$lenRight ]
       :=
       FunctionCall fuzzyjoin.len@1[
         FunctionCall fuzzyjoin.counthashed-word-tokens@1[
           FieldAccessor [
-            Variable [ Name=paperRight ]
+            Variable [ Name=$paperRight ]
             Field=title
           ]
         ]
       ]
-    LetVariable [ Name=tokensRight ]
+    Let Variable [ Name=$tokensRight ]
       :=
       (
         SELECT ELEMENT [
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
         ]
         FROM [          FunctionCall fuzzyjoin.counthashed-word-tokens@1[
             FieldAccessor [
-              Variable [ Name=paperRight ]
+              Variable [ Name=$paperRight ]
               Field=title
             ]
           ]
           AS
-          Variable [ Name=tokenUnranked ]
+          Variable [ Name=$tokenUnranked ]
 ,
           (
             SELECT ELEMENT [
-            Variable [ Name=tokenGroupped ]
+            Variable [ Name=$tokenGroupped ]
             ]
             FROM [              FunctionCall Metadata.dataset@1[
                 LiteralExpr [STRING] [DBLP]
               ]
               AS
-              Variable [ Name=paper ]
+              Variable [ Name=$paper ]
 ,
               FunctionCall fuzzyjoin.counthashed-word-tokens@1[
                 FieldAccessor [
-                  Variable [ Name=paper ]
+                  Variable [ Name=$paper ]
                   Field=title
                 ]
               ]
               AS
-              Variable [ Name=token ]
+              Variable [ Name=$token ]
             ]
             Groupby
-              Variable [ Name=tokenGroupped ]
+              Variable [ Name=$tokenGroupped ]
               :=
-              Variable [ Name=token ]
-              With
-              Variable [ Name=paper ]
-              Variable [ Name=token ]
-              Variable [ Name=tokenUnranked ]
-              Variable [ Name=lenRight ]
-              Variable [ Name=tokensLeft ]
-              Variable [ Name=lenLeft ]
-              Variable [ Name=paperLeft ]
-              Variable [ Name=paperRight ]
-              Variable [ Name=prefixTokenRight ]
-              Variable [ Name=prefixTokenLeft ]
+              Variable [ Name=$token ]
+              GROUP AS
+              Variable [ Name=#3 ]
+              (
+              Variable [ Name=$token ]
+               AS token
+              Variable [ Name=$paper ]
+               AS paper
+              Variable [ Name=$tokenUnranked ]
+               AS tokenUnranked
+              Variable [ Name=$lenRight ]
+               AS lenRight
+              Variable [ Name=$tokensLeft ]
+               AS tokensLeft
+              Variable [ Name=$lenLeft ]
+               AS lenLeft
+              Variable [ Name=$prefixTokenRight ]
+               AS prefixTokenRight
+              Variable [ Name=$paperRight ]
+               AS paperRight
+              Variable [ Name=$prefixTokenLeft ]
+               AS prefixTokenLeft
+              Variable [ Name=$paperLeft ]
+               AS paperLeft
+              )
 
             Orderby
               FunctionCall fuzzyjoin.count@1[
-                Variable [ Name=paper ]
+                (
+                  SELECT ELEMENT [
+                  FieldAccessor [
+                    Variable [ Name=#4 ]
+                    Field=paper
+                  ]
+                  ]
+                  FROM [                    Variable [ Name=#3 ]
+                    AS
+                    Variable [ Name=#4 ]
+                  ]
+                )
               ]
               ASC
-              Variable [ Name=tokenGroupped ]
+              Variable [ Name=$tokenGroupped ]
               ASC
 
           )
           AS
-          Variable [ Name=tokenRanked ]
+          Variable [ Name=$tokenRanked ]
           AT
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
         ]
         Where
           OperatorExpr [
-            Variable [ Name=tokenUnranked ]
+            Variable [ Name=$tokenUnranked ]
             =
-            Variable [ Name=tokenRanked ]
+            Variable [ Name=$tokenRanked ]
           ]
         Orderby
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           ASC
 
       )
-    LetVariable [ Name=sim ]
+    Let Variable [ Name=$sim ]
       :=
       FunctionCall fuzzyjoin.similarity-jaccard-prefix@6[
-        Variable [ Name=lenLeft ]
-        Variable [ Name=tokensLeft ]
-        Variable [ Name=lenRight ]
-        Variable [ Name=tokensRight ]
-        Variable [ Name=prefixTokenLeft ]
+        Variable [ Name=$lenLeft ]
+        Variable [ Name=$tokensLeft ]
+        Variable [ Name=$lenRight ]
+        Variable [ Name=$tokensRight ]
+        Variable [ Name=$prefixTokenLeft ]
         LiteralExpr [FLOAT] [0.5]
       ]
     Where
       OperatorExpr [
         OperatorExpr [
-          Variable [ Name=prefixTokenLeft ]
+          Variable [ Name=$prefixTokenLeft ]
           =
-          Variable [ Name=prefixTokenRight ]
+          Variable [ Name=$prefixTokenRight ]
         ]
         and
         OperatorExpr [
           OperatorExpr [
-            Variable [ Name=sim ]
+            Variable [ Name=$sim ]
             >=
             LiteralExpr [FLOAT] [0.5]
           ]
           and
           OperatorExpr [
             FieldAccessor [
-              Variable [ Name=paperLeft ]
+              Variable [ Name=$paperLeft ]
               Field=id
             ]
             <
             FieldAccessor [
-              Variable [ Name=paperRight ]
+              Variable [ Name=$paperRight ]
               Field=id
             ]
           ]
         ]
       ]
     Groupby
-      Variable [ Name=idLeft ]
+      Variable [ Name=$idLeft ]
       :=
       FieldAccessor [
-        Variable [ Name=paperLeft ]
+        Variable [ Name=$paperLeft ]
         Field=id
       ]
-      Variable [ Name=idRight ]
+      Variable [ Name=$idRight ]
       :=
       FieldAccessor [
-        Variable [ Name=paperRight ]
+        Variable [ Name=$paperRight ]
         Field=id
       ]
-      With
-      Variable [ Name=sim ]
-      Variable [ Name=tokensRight ]
-      Variable [ Name=lenRight ]
-      Variable [ Name=tokensLeft ]
-      Variable [ Name=lenLeft ]
-      Variable [ Name=paperLeft ]
-      Variable [ Name=paperRight ]
-      Variable [ Name=prefixTokenRight ]
-      Variable [ Name=prefixTokenLeft ]
+      GROUP AS
+      Variable [ Name=#5 ]
+      (
+      Variable [ Name=$sim ]
+       AS sim
+      Variable [ Name=$tokensRight ]
+       AS tokensRight
+      Variable [ Name=$lenRight ]
+       AS lenRight
+      Variable [ Name=$tokensLeft ]
+       AS tokensLeft
+      Variable [ Name=$lenLeft ]
+       AS lenLeft
+      Variable [ Name=$prefixTokenRight ]
+       AS prefixTokenRight
+      Variable [ Name=$paperRight ]
+       AS paperRight
+      Variable [ Name=$prefixTokenLeft ]
+       AS prefixTokenLeft
+      Variable [ Name=$paperLeft ]
+       AS paperLeft
+      )
 
   )
   AS
-  Variable [ Name=ridpair ]
+  Variable [ Name=$ridpair ]
 ]
 Where
   OperatorExpr [
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=ridpair ]
+        Variable [ Name=$ridpair ]
         Field=idLeft
       ]
       =
       FieldAccessor [
-        Variable [ Name=paperLeft ]
+        Variable [ Name=$paperLeft ]
         Field=id
       ]
     ]
     and
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=ridpair ]
+        Variable [ Name=$ridpair ]
         Field=idRight
       ]
       =
       FieldAccessor [
-        Variable [ Name=paperRight ]
+        Variable [ Name=$paperRight ]
         Field=id
       ]
     ]
   ]
 Orderby
   FieldAccessor [
-    Variable [ Name=paperLeft ]
+    Variable [ Name=$paperLeft ]
     Field=id
   ]
   ASC
   FieldAccessor [
-    Variable [ Name=paperRight ]
+    Variable [ Name=$paperRight ]
     Field=id
   ]
   ASC

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization.ast
index c5360e2..1704a22 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/split-materialization.ast
@@ -20,23 +20,23 @@ TypeDecl FacebookUserType [
 ]
 DatasetDecl FacebookUsers(FacebookUserType) partitioned by [[id]]
 Query:
-LetVariable [ Name=lonelyusers ]
+Let Variable [ Name=$lonelyusers ]
   :=
   (
     SELECT ELEMENT [
-    Variable [ Name=d ]
+    Variable [ Name=$d ]
     ]
     FROM [      FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [FacebookUsers]
       ]
       AS
-      Variable [ Name=d ]
+      Variable [ Name=$d ]
     ]
     Where
       OperatorExpr [
         FunctionCall TinySocial.count@1[
           FieldAccessor [
-            Variable [ Name=d ]
+            Variable [ Name=$d ]
             Field=friend-ids
           ]
         ]
@@ -44,23 +44,23 @@ LetVariable [ Name=lonelyusers ]
         LiteralExpr [LONG] [2]
       ]
   )
-LetVariable [ Name=lonelyusers2 ]
+Let Variable [ Name=$lonelyusers2 ]
   :=
   (
     SELECT ELEMENT [
-    Variable [ Name=d ]
+    Variable [ Name=$d ]
     ]
     FROM [      FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [FacebookUsers]
       ]
       AS
-      Variable [ Name=d ]
+      Variable [ Name=$d ]
     ]
     Where
       OperatorExpr [
         FunctionCall TinySocial.count@1[
           FieldAccessor [
-            Variable [ Name=d ]
+            Variable [ Name=$d ]
             Field=friend-ids
           ]
         ]
@@ -78,7 +78,7 @@ RecordConstructor [
         LiteralExpr [STRING] [id]
         :
         FieldAccessor [
-          Variable [ Name=l1 ]
+          Variable [ Name=$l1 ]
           Field=id
         ]
       )
@@ -86,7 +86,7 @@ RecordConstructor [
         LiteralExpr [STRING] [name]
         :
         FieldAccessor [
-          Variable [ Name=l1 ]
+          Variable [ Name=$l1 ]
           Field=name
         ]
       )
@@ -100,7 +100,7 @@ RecordConstructor [
         LiteralExpr [STRING] [id]
         :
         FieldAccessor [
-          Variable [ Name=l2 ]
+          Variable [ Name=$l2 ]
           Field=id
         ]
       )
@@ -108,7 +108,7 @@ RecordConstructor [
         LiteralExpr [STRING] [name]
         :
         FieldAccessor [
-          Variable [ Name=l2 ]
+          Variable [ Name=$l2 ]
           Field=name
         ]
       )
@@ -116,34 +116,34 @@ RecordConstructor [
   )
 ]
 ]
-FROM [  Variable [ Name=lonelyusers ]
+FROM [  Variable [ Name=$lonelyusers ]
   AS
-  Variable [ Name=l1 ]
+  Variable [ Name=$l1 ]
 ,
-  Variable [ Name=lonelyusers2 ]
+  Variable [ Name=$lonelyusers2 ]
   AS
-  Variable [ Name=l2 ]
+  Variable [ Name=$l2 ]
 ]
 Where
   OperatorExpr [
     FieldAccessor [
-      Variable [ Name=l1 ]
+      Variable [ Name=$l1 ]
       Field=id
     ]
     <
     FieldAccessor [
-      Variable [ Name=l2 ]
+      Variable [ Name=$l2 ]
       Field=id
     ]
   ]
 Orderby
   FieldAccessor [
-    Variable [ Name=l1 ]
+    Variable [ Name=$l1 ]
     Field=id
   ]
   ASC
   FieldAccessor [
-    Variable [ Name=l2 ]
+    Variable [ Name=$l2 ]
     Field=id
   ]
   ASC

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_01.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_01.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_01.ast
index 6467025..adb3de6 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_01.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_01.ast
@@ -2,7 +2,7 @@ DataverseUse test
 WriteOutputTo asterix_nc1:rttest/unnest-to-join_01.adm
 Query:
 SELECT ELEMENT [
-Variable [ Name=y ]
+Variable [ Name=$y ]
 ]
 FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [1]
@@ -13,7 +13,7 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [6]
   ]
   AS
-  Variable [ Name=x ]
+  Variable [ Name=$x ]
 ,
   OrderedListConstructor [
     LiteralExpr [LONG] [4]
@@ -24,11 +24,11 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [9]
   ]
   AS
-  Variable [ Name=y ]
+  Variable [ Name=$y ]
 ]
 Where
   OperatorExpr [
-    Variable [ Name=x ]
+    Variable [ Name=$x ]
     =
-    Variable [ Name=y ]
+    Variable [ Name=$y ]
   ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_02.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_02.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_02.ast
index fa15409..aedd68f 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_02.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest-to-join_02.ast
@@ -3,7 +3,7 @@ WriteOutputTo asterix_nc1:rttest/unnest-to-join_02.adm
 Query:
 SELECT ELEMENT [
 QuantifiedExpression SOME [
-  [Variable [ Name=x ]
+  [Variable [ Name=$x ]
   In
     OrderedListConstructor [
       LiteralExpr [LONG] [1]
@@ -14,7 +14,7 @@ QuantifiedExpression SOME [
       LiteralExpr [LONG] [6]
     ]
   ]
-  [Variable [ Name=y ]
+  [Variable [ Name=$y ]
   In
     OrderedListConstructor [
       LiteralExpr [LONG] [4]
@@ -27,9 +27,9 @@ QuantifiedExpression SOME [
   ]
   Satifies [
     OperatorExpr [
-      Variable [ Name=x ]
+      Variable [ Name=$x ]
       =
-      Variable [ Name=y ]
+      Variable [ Name=$y ]
     ]
   ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest_list_in_subplan.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest_list_in_subplan.ast b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest_list_in_subplan.ast
index 57ba302..c037665 100644
--- a/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest_list_in_subplan.ast
+++ b/asterix-app/src/test/resources/optimizerts/results_parser_sqlpp/unnest_list_in_subplan.ast
@@ -23,12 +23,12 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [id]
     :
-    Variable [ Name=idDBLP ]
+    Variable [ Name=$idDBLP ]
   )
   (
     LiteralExpr [STRING] [tokens]
     :
-    Variable [ Name=tokensDBLP ]
+    Variable [ Name=$tokensDBLP ]
   )
 ]
 ]
@@ -36,53 +36,53 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [DBLP]
   ]
   AS
-  Variable [ Name=paperDBLP ]
+  Variable [ Name=$paperDBLP ]
 ]
-LetVariable [ Name=idDBLP ]
+Let Variable [ Name=$idDBLP ]
   :=
   FieldAccessor [
-    Variable [ Name=paperDBLP ]
+    Variable [ Name=$paperDBLP ]
     Field=id
   ]
-LetVariable [ Name=tokensUnrankedDBLP ]
+Let Variable [ Name=$tokensUnrankedDBLP ]
   :=
   FunctionCall fuzzyjoin.counthashed-word-tokens@1[
     FieldAccessor [
-      Variable [ Name=paperDBLP ]
+      Variable [ Name=$paperDBLP ]
       Field=title
     ]
   ]
-LetVariable [ Name=tokensDBLP ]
+Let Variable [ Name=$tokensDBLP ]
   :=
   (
     SELECT ELEMENT [
     FieldAccessor [
-      Variable [ Name=tokenRanked ]
+      Variable [ Name=$tokenRanked ]
       Field=rank
     ]
     ]
-    FROM [      Variable [ Name=tokensUnrankedDBLP ]
+    FROM [      Variable [ Name=$tokensUnrankedDBLP ]
       AS
-      Variable [ Name=tokenUnranked ]
+      Variable [ Name=$tokenUnranked ]
 ,
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [TOKENSRANKEDADM]
       ]
       AS
-      Variable [ Name=tokenRanked ]
+      Variable [ Name=$tokenRanked ]
     ]
     Where
       OperatorExpr [
-        Variable [ Name=tokenUnranked ]
+        Variable [ Name=$tokenUnranked ]
         =
         FieldAccessor [
-          Variable [ Name=tokenRanked ]
+          Variable [ Name=$tokenRanked ]
           Field=token
         ]
       ]
     Orderby
       FieldAccessor [
-        Variable [ Name=tokenRanked ]
+        Variable [ Name=$tokenRanked ]
         Field=rank
       ]
       ASC

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias.sqlpp
index 746660c..72eb1d9 100644
--- a/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias.sqlpp
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias.sqlpp
@@ -21,4 +21,4 @@ SELECT SQRT(t.a*t.b) AS root FROM tbl_name t
 GROUP BY root
 WITH u AS root
 HAVING root > 0
-ORDER BY u; 
\ No newline at end of file
+ORDER BY u;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/1.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/1.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/1.ast
index 5615495..4cd023d 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/1.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/1.ast
@@ -5,7 +5,7 @@ RecordConstructor [
     LiteralExpr [STRING] [name]
     :
     FieldAccessor [
-      Variable [ Name=user ]
+      Variable [ Name=$user ]
       Field=name
     ]
   )
@@ -15,20 +15,20 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [User]
   ]
   AS
-  Variable [ Name=user ]
+  Variable [ Name=$user ]
 ]
 Where
   QuantifiedExpression SOME [
-    [Variable [ Name=i ]
+    [Variable [ Name=$i ]
     In
       FieldAccessor [
-        Variable [ Name=user ]
+        Variable [ Name=$user ]
         Field=interests
       ]
     ]
     Satifies [
       OperatorExpr [
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
         =
         LiteralExpr [STRING] [movies]
       ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/2.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/2.ast
index 7de063f..fbf13fc 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/2.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/2.ast
@@ -4,17 +4,17 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [sig_name]
     :
-    Variable [ Name=sig_name ]
+    Variable [ Name=$sig_name ]
   )
   (
     LiteralExpr [STRING] [total_count]
     :
-    Variable [ Name=sig_sponsorship_count ]
+    Variable [ Name=$sig_sponsorship_count ]
   )
   (
     LiteralExpr [STRING] [chapter_breakdown]
     :
-    Variable [ Name=by_chapter ]
+    Variable [ Name=$by_chapter ]
   )
 ]
 ]
@@ -22,47 +22,64 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Event]
   ]
   AS
-  Variable [ Name=event ]
+  Variable [ Name=$event ]
 ,
   FieldAccessor [
-    Variable [ Name=event ]
+    Variable [ Name=$event ]
     Field=sponsoring_sigs
   ]
   AS
-  Variable [ Name=sponsor ]
+  Variable [ Name=$sponsor ]
 ]
-LetVariable [ Name=es ]
+Let Variable [ Name=$es ]
   :=
   RecordConstructor [
     (
       LiteralExpr [STRING] [event]
       :
-      Variable [ Name=event ]
+      Variable [ Name=$event ]
     )
     (
       LiteralExpr [STRING] [sponsor]
       :
-      Variable [ Name=sponsor ]
+      Variable [ Name=$sponsor ]
     )
   ]
 Groupby
-  Variable [ Name=sig_name ]
+  Variable [ Name=$sig_name ]
   :=
   FieldAccessor [
-    Variable [ Name=sponsor ]
+    Variable [ Name=$sponsor ]
     Field=sig_name
   ]
-  With
-  Variable [ Name=es ]
-  Variable [ Name=sponsor ]
-  Variable [ Name=event ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$es ]
+   AS es
+  Variable [ Name=$sponsor ]
+   AS sponsor
+  Variable [ Name=$event ]
+   AS event
+  )
 
-LetVariable [ Name=sig_sponsorship_count ]
+Let Variable [ Name=$sig_sponsorship_count ]
   :=
   FunctionCall null.count@1[
-    Variable [ Name=es ]
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=es
+      ]
+      ]
+      FROM [        Variable [ Name=#1 ]
+        AS
+        Variable [ Name=#2 ]
+      ]
+    )
   ]
-LetVariable [ Name=by_chapter ]
+Let Variable [ Name=$by_chapter ]
   :=
   (
     SELECT ELEMENT [
@@ -70,42 +87,64 @@ LetVariable [ Name=by_chapter ]
       (
         LiteralExpr [STRING] [chapter_name]
         :
-        Variable [ Name=chapter_name ]
+        Variable [ Name=$chapter_name ]
       )
       (
         LiteralExpr [STRING] [escount]
         :
         FunctionCall null.count@1[
-          Variable [ Name=es ]
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=#3 ]
+              Field=es
+            ]
+            ]
+            FROM [              Variable [ Name=#1 ]
+              AS
+              Variable [ Name=#3 ]
+            ]
+          )
         ]
       )
     ]
     ]
-    FROM [      Variable [ Name=es ]
+    FROM [      Variable [ Name=$es ]
       AS
-      Variable [ Name=e ]
+      Variable [ Name=$e ]
     ]
     Groupby
-      Variable [ Name=chapter_name ]
+      Variable [ Name=$chapter_name ]
       :=
       FieldAccessor [
         FieldAccessor [
-          Variable [ Name=e ]
+          Variable [ Name=$e ]
           Field=sponsor
         ]
         Field=chapter_name
       ]
-      With
-      Variable [ Name=e ]
-      Variable [ Name=sig_sponsorship_count ]
-      Variable [ Name=sponsor ]
-      Variable [ Name=event ]
-      Variable [ Name=es ]
-      Variable [ Name=sig_name ]
+      GROUP AS
+      Variable [ Name=#4 ]
+      (
+      Variable [ Name=$e ]
+       AS e
+      Variable [ Name=$sig_sponsorship_count ]
+       AS sig_sponsorship_count
+      Variable [ Name=$es ]
+       AS es
+      Variable [ Name=$event ]
+       AS event
+      Variable [ Name=$sponsor ]
+       AS sponsor
+      Variable [ Name=$sig_name ]
+       AS sig_name
+      Variable [ Name=#1 ]
+       AS #1
+      )
 
   )
 Orderby
-  Variable [ Name=sig_sponsorship_count ]
+  Variable [ Name=$sig_sponsorship_count ]
   DESC
 
 Limit

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/4.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/4.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/4.ast
index e739c37..1aad304 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/4.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/4.ast
@@ -4,7 +4,7 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [similar_sigs]
     :
-    Variable [ Name=similar_sigs ]
+    Variable [ Name=$similar_sigs ]
   )
 ]
 ]
@@ -12,9 +12,9 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [SIGroup]
   ]
   AS
-  Variable [ Name=sig ]
+  Variable [ Name=$sig ]
 ]
-LetVariable [ Name=similar_sigs ]
+Let Variable [ Name=$similar_sigs ]
   :=
   (
     SELECT ELEMENT [
@@ -23,7 +23,7 @@ LetVariable [ Name=similar_sigs ]
         LiteralExpr [STRING] [sig_name]
         :
         FieldAccessor [
-          Variable [ Name=similar_sig ]
+          Variable [ Name=$similar_sig ]
           Field=name
         ]
       )
@@ -33,24 +33,24 @@ LetVariable [ Name=similar_sigs ]
         LiteralExpr [STRING] [SIGroup]
       ]
       AS
-      Variable [ Name=similar_sig ]
+      Variable [ Name=$similar_sig ]
     ]
     Where
       OperatorExpr [
         OperatorExpr [
-          Variable [ Name=similar_sig ]
+          Variable [ Name=$similar_sig ]
           !=
-          Variable [ Name=sig ]
+          Variable [ Name=$sig ]
         ]
         and
         OperatorExpr [
           FieldAccessor [
-            Variable [ Name=similar_sig ]
+            Variable [ Name=$similar_sig ]
             Field=interests
           ]
           ~=
           FieldAccessor [
-            Variable [ Name=sig ]
+            Variable [ Name=$sig ]
             Field=interests
           ]
         ]
@@ -59,7 +59,7 @@ LetVariable [ Name=similar_sigs ]
 Where
   OperatorExpr [
     FieldAccessor [
-      Variable [ Name=sig ]
+      Variable [ Name=$sig ]
       Field=name
     ]
     =

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/5.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/5.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/5.ast
index 73f0cd6..dfb6f09 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/5.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/5.ast
@@ -4,7 +4,7 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [collocated_evnets]
     :
-    Variable [ Name=collocated_events ]
+    Variable [ Name=$collocated_events ]
   )
 ]
 ]
@@ -12,9 +12,9 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Event]
   ]
   AS
-  Variable [ Name=event ]
+  Variable [ Name=$event ]
 ]
-LetVariable [ Name=collocated_events ]
+Let Variable [ Name=$collocated_events ]
   :=
   (
     SELECT ELEMENT [
@@ -23,7 +23,7 @@ LetVariable [ Name=collocated_events ]
         LiteralExpr [STRING] [event_name]
         :
         FieldAccessor [
-          Variable [ Name=collocated_event ]
+          Variable [ Name=$collocated_event ]
           Field=name
         ]
       )
@@ -33,14 +33,14 @@ LetVariable [ Name=collocated_events ]
         LiteralExpr [STRING] [Events]
       ]
       AS
-      Variable [ Name=collocated_event ]
+      Variable [ Name=$collocated_event ]
     ]
     Where
       OperatorExpr [
         OperatorExpr [
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=collocated_event ]
+              Variable [ Name=$collocated_event ]
               Field=location
             ]
             Field=street
@@ -48,7 +48,7 @@ LetVariable [ Name=collocated_events ]
           ~=
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=event ]
+              Variable [ Name=$event ]
               Field=location
             ]
             Field=street
@@ -58,7 +58,7 @@ LetVariable [ Name=collocated_events ]
         OperatorExpr [
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=collocated_event ]
+              Variable [ Name=$collocated_event ]
               Field=location
             ]
             Field=city
@@ -66,7 +66,7 @@ LetVariable [ Name=collocated_events ]
           =
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=event ]
+              Variable [ Name=$event ]
               Field=location
             ]
             Field=city
@@ -76,7 +76,7 @@ LetVariable [ Name=collocated_events ]
         OperatorExpr [
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=collocated_event ]
+              Variable [ Name=$collocated_event ]
               Field=location
             ]
             Field=state
@@ -84,7 +84,7 @@ LetVariable [ Name=collocated_events ]
           =
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=event ]
+              Variable [ Name=$event ]
               Field=location
             ]
             Field=state
@@ -94,7 +94,7 @@ LetVariable [ Name=collocated_events ]
         OperatorExpr [
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=collocated_event ]
+              Variable [ Name=$collocated_event ]
               Field=location
             ]
             Field=zip
@@ -102,7 +102,7 @@ LetVariable [ Name=collocated_events ]
           =
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=event ]
+              Variable [ Name=$event ]
               Field=location
             ]
             Field=zip
@@ -113,7 +113,7 @@ LetVariable [ Name=collocated_events ]
 Where
   OperatorExpr [
     FieldAccessor [
-      Variable [ Name=event ]
+      Variable [ Name=$event ]
       Field=name
     ]
     =

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/6.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/6.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/6.ast
index dcbd485..effebf2 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/6.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/6.ast
@@ -5,14 +5,14 @@ RecordConstructor [
     LiteralExpr [STRING] [user_name]
     :
     FieldAccessor [
-      Variable [ Name=user ]
+      Variable [ Name=$user ]
       Field=name
     ]
   )
   (
     LiteralExpr [STRING] [similar_users]
     :
-    Variable [ Name=similar_users ]
+    Variable [ Name=$similar_users ]
   )
 ]
 ]
@@ -20,9 +20,9 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Users]
   ]
   AS
-  Variable [ Name=user ]
+  Variable [ Name=$user ]
 ]
-LetVariable [ Name=similar_users ]
+Let Variable [ Name=$similar_users ]
   :=
   (
     SELECT ELEMENT [
@@ -31,14 +31,14 @@ LetVariable [ Name=similar_users ]
         LiteralExpr [STRING] [user_name]
         :
         FieldAccessor [
-          Variable [ Name=similar_user ]
+          Variable [ Name=$similar_user ]
           Field=name
         ]
       )
       (
         LiteralExpr [STRING] [similarity]
         :
-        Variable [ Name=similarity ]
+        Variable [ Name=$similarity ]
       )
     ]
     ]
@@ -46,36 +46,36 @@ LetVariable [ Name=similar_users ]
         LiteralExpr [STRING] [Users]
       ]
       AS
-      Variable [ Name=similar_user ]
+      Variable [ Name=$similar_user ]
     ]
-    LetVariable [ Name=similarity ]
+    Let Variable [ Name=$similarity ]
       :=
       FunctionCall null.jaccard_similarity@2[
         FieldAccessor [
-          Variable [ Name=user ]
+          Variable [ Name=$user ]
           Field=interests
         ]
         FieldAccessor [
-          Variable [ Name=similar_user ]
+          Variable [ Name=$similar_user ]
           Field=interests
         ]
       ]
     Where
       OperatorExpr [
         OperatorExpr [
-          Variable [ Name=user ]
+          Variable [ Name=$user ]
           !=
-          Variable [ Name=similar_user ]
+          Variable [ Name=$similar_user ]
         ]
         and
         OperatorExpr [
-          Variable [ Name=similarity ]
+          Variable [ Name=$similarity ]
           >=
           LiteralExpr [DOUBLE] [0.75]
         ]
       ]
     Orderby
-      Variable [ Name=similarity ]
+      Variable [ Name=$similarity ]
       DESC
 
     Limit

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ANYInFieldAccessor.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ANYInFieldAccessor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ANYInFieldAccessor.ast
index 2f60cbc..619350b 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ANYInFieldAccessor.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ANYInFieldAccessor.ast
@@ -5,7 +5,7 @@ RecordConstructor [
     LiteralExpr [STRING] [name]
     :
     FieldAccessor [
-      Variable [ Name=user ]
+      Variable [ Name=$user ]
       Field=name
     ]
   )
@@ -13,7 +13,7 @@ RecordConstructor [
     LiteralExpr [STRING] [movie]
     :
     FieldAccessor [
-      Variable [ Name=mv ]
+      Variable [ Name=$mv ]
       Field=movie
     ]
   )
@@ -23,33 +23,33 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [User]
   ]
   AS
-  Variable [ Name=user ]
+  Variable [ Name=$user ]
 ,
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Movie]
   ]
   AS
-  Variable [ Name=mv ]
+  Variable [ Name=$mv ]
 ]
 Where
   QuantifiedExpression SOME [
-    [Variable [ Name=i ]
+    [Variable [ Name=$i ]
     In
       FieldAccessor [
-        Variable [ Name=user ]
+        Variable [ Name=$user ]
         Field=interests
       ]
     ]
     Satifies [
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=movie
         ]
         =
         IndexAccessor [
           FieldAccessor [
-            Variable [ Name=mv ]
+            Variable [ Name=$mv ]
             Field=movie
           ]
           Index: ANY

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfInFLOWGR.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfInFLOWGR.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfInFLOWGR.ast
index 4b9e932..a8b54c1 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfInFLOWGR.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/IfInFLOWGR.ast
@@ -3,14 +3,14 @@ SELECT ELEMENT [
 IfExpr [
   Condition:
     OperatorExpr [
-      Variable [ Name=i ]
+      Variable [ Name=$i ]
       >
-      Variable [ Name=j ]
+      Variable [ Name=$j ]
     ]
   Then:
-    Variable [ Name=i ]
+    Variable [ Name=$i ]
   Else:
-    Variable [ Name=j ]
+    Variable [ Name=$j ]
 ]
 ]
 FROM [  OrderedListConstructor [
@@ -20,7 +20,7 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [40]
   ]
   AS
-  Variable [ Name=i ]
+  Variable [ Name=$i ]
 ,
   UnorderedListConstructor [
     LiteralExpr [LONG] [4]
@@ -28,5 +28,5 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [6]
   ]
   AS
-  Variable [ Name=j ]
+  Variable [ Name=$j ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/LetFor.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/LetFor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/LetFor.ast
index b9bf49a..a46d1c9 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/LetFor.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/LetFor.ast
@@ -1,5 +1,5 @@
 Query:
-LetVariable [ Name=users ]
+Let Variable [ Name=$users ]
   :=
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [User]
@@ -10,28 +10,28 @@ RecordConstructor [
     LiteralExpr [STRING] [name]
     :
     FieldAccessor [
-      Variable [ Name=user ]
+      Variable [ Name=$user ]
       Field=name
     ]
   )
 ]
 ]
-FROM [  Variable [ Name=users ]
+FROM [  Variable [ Name=$users ]
   AS
-  Variable [ Name=user ]
+  Variable [ Name=$user ]
 ]
 Where
   QuantifiedExpression SOME [
-    [Variable [ Name=i ]
+    [Variable [ Name=$i ]
     In
       FieldAccessor [
-        Variable [ Name=user ]
+        Variable [ Name=$user ]
         Field=interests
       ]
     ]
     Satifies [
       OperatorExpr [
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
         =
         LiteralExpr [STRING] [movies]
       ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ListConstructor.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ListConstructor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ListConstructor.ast
index 3d3a387..f769a0d 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ListConstructor.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/ListConstructor.ast
@@ -1,9 +1,9 @@
 Query:
 SELECT ELEMENT [
 OperatorExpr [
-  Variable [ Name=i ]
+  Variable [ Name=$i ]
   +
-  Variable [ Name=j ]
+  Variable [ Name=$j ]
 ]
 ]
 FROM [  OrderedListConstructor [
@@ -12,7 +12,7 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [3]
   ]
   AS
-  Variable [ Name=i ]
+  Variable [ Name=$i ]
 ,
   UnorderedListConstructor [
     LiteralExpr [LONG] [4]
@@ -20,5 +20,5 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [6]
   ]
   AS
-  Variable [ Name=j ]
+  Variable [ Name=$j ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
index 26addaa..cb03fe8 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias.ast
@@ -1,77 +1,47 @@
 Query:
 SELECT [
-FunctionCall null.SQRT@1[
-  OperatorExpr [
-    FieldAccessor [
-      Variable [ Name=t ]
-      Field=a
-    ]
-    *
-    FieldAccessor [
-      Variable [ Name=t ]
-      Field=b
-    ]
-  ]
-]
+Variable [ Name=#1 ]
 root
 ]
 FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [tbl_name]
   ]
   AS
-  Variable [ Name=t ]
+  Variable [ Name=$t ]
 ]
 Groupby
+  Variable [ Name=#1 ]
+  :=
   FunctionCall null.SQRT@1[
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=t ]
+        Variable [ Name=$t ]
         Field=a
       ]
       *
       FieldAccessor [
-        Variable [ Name=t ]
+        Variable [ Name=$t ]
         Field=b
       ]
     ]
   ]
-  With
-  Variable [ Name=t ]
+  GROUP AS
+  Variable [ Name=#2 ]
+  (
+  Variable [ Name=$t ]
+   AS t
+  )
 
-LetVariable [ Name=u ]
+Let Variable [ Name=$u ]
   :=
-  FunctionCall null.SQRT@1[
-    OperatorExpr [
-      FieldAccessor [
-        Variable [ Name=t ]
-        Field=a
-      ]
-      *
-      FieldAccessor [
-        Variable [ Name=t ]
-        Field=b
-      ]
-    ]
-  ]
+  Variable [ Name=#1 ]
  HAVING
   OperatorExpr [
-    FunctionCall null.SQRT@1[
-      OperatorExpr [
-        FieldAccessor [
-          Variable [ Name=t ]
-          Field=a
-        ]
-        *
-        FieldAccessor [
-          Variable [ Name=t ]
-          Field=b
-        ]
-      ]
-    ]
+    Variable [ Name=#1 ]
     >
     LiteralExpr [LONG] [0]
   ]
 Orderby
-  Variable [ Name=u ]
+  Variable [ Name=$u ]
   ASC
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
index 90d32cc..6142478 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias2.ast
@@ -23,32 +23,38 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [tbl_name]
   ]
   AS
-  Variable [ Name=root ]
+  Variable [ Name=$root ]
 ]
 Groupby
+  Variable [ Name=#1 ]
+  :=
   FieldAccessor [
-    Variable [ Name=root ]
+    Variable [ Name=$root ]
     Field=id
   ]
-  With
-  Variable [ Name=root ]
+  GROUP AS
+  Variable [ Name=#2 ]
+  (
+  Variable [ Name=$root ]
+   AS root
+  )
 
-LetVariable [ Name=u ]
+Let Variable [ Name=$u ]
   :=
   FieldAccessor [
-    Variable [ Name=root ]
+    Variable [ Name=$root ]
     Field=time
   ]
  HAVING
   OperatorExpr [
     FieldAccessor [
-      Variable [ Name=root ]
+      Variable [ Name=$root ]
       Field=orders
     ]
     >
     LiteralExpr [LONG] [0]
   ]
 Orderby
-  Variable [ Name=u ]
+  Variable [ Name=$u ]
   ASC
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
index 6b5693b..a7ae7ca 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/columnalias3.ast
@@ -4,19 +4,7 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [root]
     :
-    FunctionCall null.SQRT@1[
-      OperatorExpr [
-        FieldAccessor [
-          Variable [ Name=t ]
-          Field=a
-        ]
-        *
-        FieldAccessor [
-          Variable [ Name=t ]
-          Field=b
-        ]
-      ]
-    ]
+    Variable [ Name=#1 ]
   )
 ]
 ]
@@ -24,59 +12,41 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [tbl_name]
   ]
   AS
-  Variable [ Name=t ]
+  Variable [ Name=$t ]
 ]
 Groupby
+  Variable [ Name=#1 ]
+  :=
   FunctionCall null.SQRT@1[
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=t ]
+        Variable [ Name=$t ]
         Field=a
       ]
       *
       FieldAccessor [
-        Variable [ Name=t ]
+        Variable [ Name=$t ]
         Field=b
       ]
     ]
   ]
-  With
-  Variable [ Name=t ]
+  GROUP AS
+  Variable [ Name=#2 ]
+  (
+  Variable [ Name=$t ]
+   AS t
+  )
 
-LetVariable [ Name=u ]
+Let Variable [ Name=$u ]
   :=
-  FunctionCall null.SQRT@1[
-    OperatorExpr [
-      FieldAccessor [
-        Variable [ Name=t ]
-        Field=a
-      ]
-      *
-      FieldAccessor [
-        Variable [ Name=t ]
-        Field=b
-      ]
-    ]
-  ]
+  Variable [ Name=#1 ]
  HAVING
   OperatorExpr [
-    FunctionCall null.SQRT@1[
-      OperatorExpr [
-        FieldAccessor [
-          Variable [ Name=t ]
-          Field=a
-        ]
-        *
-        FieldAccessor [
-          Variable [ Name=t ]
-          Field=b
-        ]
-      ]
-    ]
+    Variable [ Name=#1 ]
     >
     LiteralExpr [LONG] [0]
   ]
 Orderby
-  Variable [ Name=u ]
+  Variable [ Name=$u ]
   ASC
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/fieldAccessor.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/fieldAccessor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/fieldAccessor.ast
index 40bc769..0db2e76 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/fieldAccessor.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/fieldAccessor.ast
@@ -1,5 +1,5 @@
 Query:
-LetVariable [ Name=bla ]
+Let Variable [ Name=$bla ]
   :=
   RecordConstructor [
     (
@@ -11,12 +11,12 @@ LetVariable [ Name=bla ]
 SELECT ELEMENT [
 OperatorExpr [
   FieldAccessor [
-    Variable [ Name=bla ]
+    Variable [ Name=$bla ]
     Field=name
   ]
   =
   FieldAccessor [
-    Variable [ Name=bla ]
+    Variable [ Name=$bla ]
     Field=name
   ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_array.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_array.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_array.ast
index 192bf6e..43c56e7 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_array.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_array.ast
@@ -1,6 +1,6 @@
 Query:
 SELECT ELEMENT [
-Variable [ Name=x ]
+Variable [ Name=$x ]
 ]
 FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [10]
@@ -8,5 +8,5 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [30]
   ]
   AS
-  Variable [ Name=x ]
+  Variable [ Name=$x ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_bag.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_bag.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_bag.ast
index e768f7e..79cb01d 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_bag.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_collection_bag.ast
@@ -1,6 +1,6 @@
 Query:
 SELECT ELEMENT [
-Variable [ Name=x ]
+Variable [ Name=$x ]
 ]
 FROM [  UnorderedListConstructor [
     LiteralExpr [LONG] [10]
@@ -8,5 +8,5 @@ FROM [  UnorderedListConstructor [
     LiteralExpr [LONG] [30]
   ]
   AS
-  Variable [ Name=x ]
+  Variable [ Name=$x ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_correlate.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_correlate.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_correlate.ast
index b354122..701d997 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_correlate.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_correlate.ast
@@ -1,18 +1,18 @@
 DataverseUse test
 Query:
 SELECT ELEMENT [
-Variable [ Name=r ]
+Variable [ Name=$r ]
 ]
 FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [sensors]
   ]
   AS
-  Variable [ Name=s ]
+  Variable [ Name=$s ]
   INNER UNNEST
     FieldAccessor [
-      Variable [ Name=s ]
+      Variable [ Name=$s ]
       Field=readings
     ]
      AS
-    Variable [ Name=r ]
+    Variable [ Name=$r ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_flatten.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_flatten.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_flatten.ast
index 7668550..f3c8a42 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_flatten.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_flatten.ast
@@ -2,23 +2,23 @@ DataverseUse test
 Query:
 SELECT [
 FieldAccessor [
-  Variable [ Name=s ]
+  Variable [ Name=$s ]
   Field=sensor
 ]
 sensor
-Variable [ Name=r ]
+Variable [ Name=$r ]
 reading
 ]
 FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [sensors]
   ]
   AS
-  Variable [ Name=s ]
+  Variable [ Name=$s ]
 ,
   FieldAccessor [
-    Variable [ Name=s ]
+    Variable [ Name=$s ]
     Field=readings
   ]
   AS
-  Variable [ Name=r ]
+  Variable [ Name=$r ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_join.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_join.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_join.ast
index 0992966..d82b43d 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_join.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_inner_join.ast
@@ -2,17 +2,17 @@ DataverseUse test
 Query:
 SELECT [
 FieldAccessor [
-  Variable [ Name=m ]
+  Variable [ Name=$m ]
   Field=sensor
 ]
 sensor
 FieldAccessor [
-  Variable [ Name=s ]
+  Variable [ Name=$s ]
   Field=readings
 ]
 readings
 FieldAccessor [
-  Variable [ Name=m ]
+  Variable [ Name=$m ]
   Field=location
 ]
 location
@@ -21,22 +21,22 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [sensors]
   ]
   AS
-  Variable [ Name=s ]
+  Variable [ Name=$s ]
   INNER JOIN
     FunctionCall Metadata.dataset@1[
       LiteralExpr [STRING] [sensorMeta]
     ]
     AS
-    Variable [ Name=m ]
+    Variable [ Name=$m ]
     ON
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=s ]
+        Variable [ Name=$s ]
         Field=sensor
       ]
       =
       FieldAccessor [
-        Variable [ Name=m ]
+        Variable [ Name=$m ]
         Field=sensor
       ]
     ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate.ast
index 9fd948a..f11ecaf 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate.ast
@@ -2,17 +2,17 @@ DataverseUse test_022
 Query:
 SELECT [
 FieldAccessor [
-  Variable [ Name=sl ]
+  Variable [ Name=$sl ]
   Field=location
 ]
 location
 FieldAccessor [
-  Variable [ Name=sr ]
+  Variable [ Name=$sr ]
   Field=gas
 ]
 gas
 FieldAccessor [
-  Variable [ Name=sr ]
+  Variable [ Name=$sr ]
   Field=readings
 ]
 readings
@@ -62,7 +62,7 @@ FROM [  UnorderedListConstructor [
     ]
   ]
   AS
-  Variable [ Name=sl ]
+  Variable [ Name=$sl ]
   LEFTOUTER UNNEST
     UnorderedListConstructor [
       RecordConstructor [
@@ -141,17 +141,17 @@ FROM [  UnorderedListConstructor [
       ]
     ]
      AS
-    Variable [ Name=sr ]
+    Variable [ Name=$sr ]
 ]
 Where
   OperatorExpr [
     FieldAccessor [
-      Variable [ Name=sl ]
+      Variable [ Name=$sl ]
       Field=sensor
     ]
     =
     FieldAccessor [
-      Variable [ Name=sr ]
+      Variable [ Name=$sr ]
       Field=sensor
     ]
   ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate2.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate2.ast
index 9ace3b5..6036b55 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate2.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_correlate2.ast
@@ -1,6 +1,6 @@
 Query:
 SELECT ELEMENT [
-Variable [ Name=r ]
+Variable [ Name=$r ]
 ]
 FROM [  UnorderedListConstructor [
     RecordConstructor [
@@ -48,12 +48,12 @@ FROM [  UnorderedListConstructor [
     ]
   ]
   AS
-  Variable [ Name=s ]
+  Variable [ Name=$s ]
   LEFTOUTER UNNEST
     FieldAccessor [
-      Variable [ Name=s ]
+      Variable [ Name=$s ]
       Field=readings
     ]
      AS
-    Variable [ Name=r ]
+    Variable [ Name=$r ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_outer_join.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_outer_join.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_outer_join.ast
index 0f82980..998fc6f 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_outer_join.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_left_outer_join.ast
@@ -2,17 +2,17 @@ DataverseUse test_021
 Query:
 SELECT [
 FieldAccessor [
-  Variable [ Name=sl ]
+  Variable [ Name=$sl ]
   Field=location
 ]
 location
 FieldAccessor [
-  Variable [ Name=sr ]
+  Variable [ Name=$sr ]
   Field=gas
 ]
 gas
 FieldAccessor [
-  Variable [ Name=sr ]
+  Variable [ Name=$sr ]
   Field=readings
 ]
 readings
@@ -62,7 +62,7 @@ FROM [  UnorderedListConstructor [
     ]
   ]
   AS
-  Variable [ Name=sl ]
+  Variable [ Name=$sl ]
   LEFTOUTER JOIN
     UnorderedListConstructor [
       RecordConstructor [
@@ -141,16 +141,16 @@ FROM [  UnorderedListConstructor [
       ]
     ]
     AS
-    Variable [ Name=sr ]
+    Variable [ Name=$sr ]
     ON
     OperatorExpr [
       FieldAccessor [
-        Variable [ Name=sl ]
+        Variable [ Name=$sl ]
         Field=sensor
       ]
       =
       FieldAccessor [
-        Variable [ Name=sr ]
+        Variable [ Name=$sr ]
         Field=sensor
       ]
     ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_where_select_clause.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_where_select_clause.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_where_select_clause.ast
index bb0c8b5..b978b56 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_where_select_clause.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/from_where_select_clause.ast
@@ -1,6 +1,6 @@
 Query:
 SELECT ELEMENT [
-Variable [ Name=x ]
+Variable [ Name=$x ]
 ]
 FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [10]
@@ -10,11 +10,11 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [10]
   ]
   AS
-  Variable [ Name=x ]
+  Variable [ Name=$x ]
 ]
 Where
   OperatorExpr [
-    Variable [ Name=x ]
+    Variable [ Name=$x ]
     =
     LiteralExpr [LONG] [10]
   ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl.ast
index e025413..90fa1e7 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl.ast
@@ -1,16 +1,16 @@
-FunctionDecl add([a, b]) {
+FunctionDecl add([$a, $b]) {
   OperatorExpr [
-    Variable [ Name=a ]
+    Variable [ Name=$a ]
     +
-    Variable [ Name=b ]
+    Variable [ Name=$b ]
   ]
 }
 
-FunctionDecl minus([a, b]) {
+FunctionDecl minus([$a, $b]) {
   OperatorExpr [
-    Variable [ Name=a ]
+    Variable [ Name=$a ]
     -
-    Variable [ Name=b ]
+    Variable [ Name=$b ]
   ]
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl1.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl1.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl1.ast
index 36f35dd..5983067 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl1.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl1.ast
@@ -1,63 +1,63 @@
-FunctionDecl calculate([events]) {
+FunctionDecl calculate([$events]) {
   (
     SELECT ELEMENT [
     RecordConstructor [
       (
         LiteralExpr [STRING] [sig_name]
         :
-        Variable [ Name=sig_name ]
+        Variable [ Name=$sig_name ]
       )
       (
         LiteralExpr [STRING] [total_count]
         :
-        Variable [ Name=sig_sponsorship_count ]
+        Variable [ Name=$sig_sponsorship_count ]
       )
       (
         LiteralExpr [STRING] [chapter_breakdown]
         :
-        Variable [ Name=by_chapter ]
+        Variable [ Name=$by_chapter ]
       )
     ]
     ]
-    FROM [      Variable [ Name=events ]
+    FROM [      Variable [ Name=$events ]
       AS
-      Variable [ Name=event ]
+      Variable [ Name=$event ]
 ,
       FieldAccessor [
-        Variable [ Name=event ]
+        Variable [ Name=$event ]
         Field=sponsoring_sigs
       ]
       AS
-      Variable [ Name=sponsor ]
+      Variable [ Name=$sponsor ]
     ]
-    LetVariable [ Name=es ]
+    Let Variable [ Name=$es ]
       :=
       RecordConstructor [
         (
           LiteralExpr [STRING] [event]
           :
-          Variable [ Name=event ]
+          Variable [ Name=$event ]
         )
         (
           LiteralExpr [STRING] [sponsor]
           :
-          Variable [ Name=sponsor ]
+          Variable [ Name=$sponsor ]
         )
       ]
     Groupby
-      Variable [ Name=sig_name ]
+      Variable [ Name=$sig_name ]
       :=
       FieldAccessor [
-        Variable [ Name=sponsor ]
+        Variable [ Name=$sponsor ]
         Field=sig_name
       ]
 
-    LetVariable [ Name=sig_sponsorship_count ]
+    Let Variable [ Name=$sig_sponsorship_count ]
       :=
       FunctionCall null.count@1[
-        Variable [ Name=es ]
+        Variable [ Name=$es ]
       ]
-    LetVariable [ Name=by_chapter ]
+    Let Variable [ Name=$by_chapter ]
       :=
       (
         SELECT ELEMENT [
@@ -65,27 +65,27 @@ FunctionDecl calculate([events]) {
           (
             LiteralExpr [STRING] [chapter_name]
             :
-            Variable [ Name=chapter_name ]
+            Variable [ Name=$chapter_name ]
           )
           (
             LiteralExpr [STRING] [escount]
             :
             FunctionCall null.count@1[
-              Variable [ Name=es ]
+              Variable [ Name=$es ]
             ]
           )
         ]
         ]
-        FROM [          Variable [ Name=es ]
+        FROM [          Variable [ Name=$es ]
           AS
-          Variable [ Name=e ]
+          Variable [ Name=$e ]
         ]
         Groupby
-          Variable [ Name=chapter_name ]
+          Variable [ Name=$chapter_name ]
           :=
           FieldAccessor [
             FieldAccessor [
-              Variable [ Name=e ]
+              Variable [ Name=$e ]
               Field=sponsor
             ]
             Field=chapter_name
@@ -93,7 +93,7 @@ FunctionDecl calculate([events]) {
 
       )
     Orderby
-      Variable [ Name=sig_sponsorship_count ]
+      Variable [ Name=$sig_sponsorship_count ]
       DESC
 
     Limit
@@ -102,7 +102,7 @@ FunctionDecl calculate([events]) {
 }
 
 Query:
-LetVariable [ Name=result ]
+Let Variable [ Name=$result ]
   :=
   FunctionCall null.calculate@1[
     FunctionCall Metadata.dataset@1[
@@ -110,5 +110,5 @@ LetVariable [ Name=result ]
     ]
   ]
 SELECT ELEMENT [
-Variable [ Name=result ]
+Variable [ Name=$result ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl2.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl2.ast
index 407d545..de37697 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl2.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl2.ast
@@ -1,10 +1,10 @@
-FunctionDecl GT([a, b]) {
+FunctionDecl GT([$a, $b]) {
   IfExpr [
     Condition:
       OperatorExpr [
-        Variable [ Name=a ]
+        Variable [ Name=$a ]
         >
-        Variable [ Name=b ]
+        Variable [ Name=$b ]
       ]
     Then:
       LiteralExpr [TRUE]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl3.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl3.ast
index 487c466..54032ff 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl3.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/functionDecl3.ast
@@ -1,4 +1,4 @@
-FunctionDecl function with spaces([a, b]) {
+FunctionDecl function with spaces([$a, $b]) {
   LiteralExpr [STRING] [string with spaces]
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/groupby_clause_count.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/groupby_clause_count.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/groupby_clause_count.ast
index b413291..feeed6e 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/groupby_clause_count.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/groupby_clause_count.ast
@@ -1,7 +1,18 @@
 Query:
 SELECT ELEMENT [
 FunctionCall null.count@1[
-  Variable [ Name=r ]
+  (
+    SELECT ELEMENT [
+    FieldAccessor [
+      Variable [ Name=#2 ]
+      Field=r
+    ]
+    ]
+    FROM [      Variable [ Name=#1 ]
+      AS
+      Variable [ Name=#2 ]
+    ]
+  )
 ]
 ]
 FROM [  UnorderedListConstructor [
@@ -79,15 +90,19 @@ FROM [  UnorderedListConstructor [
     ]
   ]
   AS
-  Variable [ Name=r ]
+  Variable [ Name=$r ]
 ]
 Groupby
-  Variable [ Name=g ]
+  Variable [ Name=$g ]
   :=
   FieldAccessor [
-    Variable [ Name=r ]
+    Variable [ Name=$r ]
     Field=gas
   ]
-  With
-  Variable [ Name=r ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$r ]
+   AS r
+  )
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR.ast
index 6e7af3a..da4a74f 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR.ast
@@ -5,37 +5,37 @@ RecordConstructor [
     LiteralExpr [STRING] [name]
     :
     FieldAccessor [
-      Variable [ Name=user ]
+      Variable [ Name=$user ]
       Field=name
     ]
   )
 ]
 ]
 FROM [  (
-    LetVariable [ Name=data ]
+    Let Variable [ Name=$data ]
       :=
       FunctionCall Metadata.dataset@1[
         LiteralExpr [STRING] [User]
       ]
     SELECT ELEMENT [
-    Variable [ Name=data ]
+    Variable [ Name=$data ]
     ]
   )
   AS
-  Variable [ Name=user ]
+  Variable [ Name=$user ]
 ]
 Where
   QuantifiedExpression SOME [
-    [Variable [ Name=i ]
+    [Variable [ Name=$i ]
     In
       FieldAccessor [
-        Variable [ Name=user ]
+        Variable [ Name=$user ]
         Field=interests
       ]
     ]
     Satifies [
       OperatorExpr [
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
         =
         LiteralExpr [STRING] [movies]
       ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR1.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR1.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR1.ast
index 46d3fb8..ea08249 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR1.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR1.ast
@@ -2,26 +2,26 @@ Query:
 SELECT ELEMENT [
 (
   SELECT ELEMENT [
-  Variable [ Name=k ]
+  Variable [ Name=$k ]
   ]
   FROM [    IfExpr [
       Condition:
         OperatorExpr [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           >
-          Variable [ Name=j ]
+          Variable [ Name=$j ]
         ]
       Then:
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
       Else:
-        Variable [ Name=j ]
+        Variable [ Name=$j ]
     ]
     AS
-    Variable [ Name=k ]
+    Variable [ Name=$k ]
   ]
   Where
     OperatorExpr [
-      Variable [ Name=k ]
+      Variable [ Name=$k ]
       <
       LiteralExpr [LONG] [10]
     ]
@@ -34,7 +34,7 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [40]
   ]
   AS
-  Variable [ Name=i ]
+  Variable [ Name=$i ]
 ,
   UnorderedListConstructor [
     LiteralExpr [LONG] [4]
@@ -42,5 +42,5 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [6]
   ]
   AS
-  Variable [ Name=j ]
+  Variable [ Name=$j ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR2.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR2.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR2.ast
index 9673c91..84e2550 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR2.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR2.ast
@@ -2,26 +2,26 @@ Query:
 SELECT ELEMENT [
 (
   SELECT ELEMENT [
-  Variable [ Name=k ]
+  Variable [ Name=$k ]
   ]
   FROM [    IfExpr [
       Condition:
         OperatorExpr [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           >
-          Variable [ Name=j ]
+          Variable [ Name=$j ]
         ]
       Then:
-        Variable [ Name=i ]
+        Variable [ Name=$i ]
       Else:
-        Variable [ Name=j ]
+        Variable [ Name=$j ]
     ]
     AS
-    Variable [ Name=k ]
+    Variable [ Name=$k ]
   ]
   Where
     OperatorExpr [
-      Variable [ Name=k ]
+      Variable [ Name=$k ]
       <
       LiteralExpr [LONG] [10]
     ]
@@ -33,18 +33,18 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [30]
     (
       SELECT ELEMENT [
-      Variable [ Name=tmp ]
+      Variable [ Name=$tmp ]
       ]
       FROM [        FunctionCall Metadata.dataset@1[
           LiteralExpr [STRING] [number]
         ]
         AS
-        Variable [ Name=tmp ]
+        Variable [ Name=$tmp ]
       ]
     )
   ]
   AS
-  Variable [ Name=i ]
+  Variable [ Name=$i ]
 ,
   UnorderedListConstructor [
     LiteralExpr [LONG] [4]
@@ -52,5 +52,5 @@ FROM [  OrderedListConstructor [
     LiteralExpr [LONG] [6]
   ]
   AS
-  Variable [ Name=j ]
+  Variable [ Name=$j ]
 ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR3.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR3.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR3.ast
index 4232303..a636e0d 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR3.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFLWOGR3.ast
@@ -4,17 +4,17 @@ RecordConstructor [
   (
     LiteralExpr [STRING] [sig_name]
     :
-    Variable [ Name=sig_name ]
+    Variable [ Name=$sig_name ]
   )
   (
     LiteralExpr [STRING] [total_count]
     :
-    Variable [ Name=sig_sponsorship_count ]
+    Variable [ Name=$sig_sponsorship_count ]
   )
   (
     LiteralExpr [STRING] [chapter_breakdown]
     :
-    Variable [ Name=by_chapter ]
+    Variable [ Name=$by_chapter ]
   )
 ]
 ]
@@ -22,47 +22,64 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Event]
   ]
   AS
-  Variable [ Name=event ]
+  Variable [ Name=$event ]
 ,
   FieldAccessor [
-    Variable [ Name=event ]
+    Variable [ Name=$event ]
     Field=sponsoring_sigs
   ]
   AS
-  Variable [ Name=sponsor ]
+  Variable [ Name=$sponsor ]
 ]
-LetVariable [ Name=es ]
+Let Variable [ Name=$es ]
   :=
   RecordConstructor [
     (
       LiteralExpr [STRING] [event]
       :
-      Variable [ Name=event ]
+      Variable [ Name=$event ]
     )
     (
       LiteralExpr [STRING] [sponsor]
       :
-      Variable [ Name=sponsor ]
+      Variable [ Name=$sponsor ]
     )
   ]
 Groupby
-  Variable [ Name=sig_name ]
+  Variable [ Name=$sig_name ]
   :=
   FieldAccessor [
-    Variable [ Name=sponsor ]
+    Variable [ Name=$sponsor ]
     Field=sig_name
   ]
-  With
-  Variable [ Name=es ]
-  Variable [ Name=sponsor ]
-  Variable [ Name=event ]
+  GROUP AS
+  Variable [ Name=#1 ]
+  (
+  Variable [ Name=$es ]
+   AS es
+  Variable [ Name=$sponsor ]
+   AS sponsor
+  Variable [ Name=$event ]
+   AS event
+  )
 
-LetVariable [ Name=sig_sponsorship_count ]
+Let Variable [ Name=$sig_sponsorship_count ]
   :=
   FunctionCall null.count@1[
-    Variable [ Name=es ]
+    (
+      SELECT ELEMENT [
+      FieldAccessor [
+        Variable [ Name=#2 ]
+        Field=es
+      ]
+      ]
+      FROM [        Variable [ Name=#1 ]
+        AS
+        Variable [ Name=#2 ]
+      ]
+    )
   ]
-LetVariable [ Name=by_chapter ]
+Let Variable [ Name=$by_chapter ]
   :=
   (
     SELECT ELEMENT [
@@ -70,42 +87,64 @@ LetVariable [ Name=by_chapter ]
       (
         LiteralExpr [STRING] [chapter_name]
         :
-        Variable [ Name=chapter_name ]
+        Variable [ Name=$chapter_name ]
       )
       (
         LiteralExpr [STRING] [escount]
         :
         FunctionCall null.count@1[
-          Variable [ Name=es ]
+          (
+            SELECT ELEMENT [
+            FieldAccessor [
+              Variable [ Name=#3 ]
+              Field=es
+            ]
+            ]
+            FROM [              Variable [ Name=#1 ]
+              AS
+              Variable [ Name=#3 ]
+            ]
+          )
         ]
       )
     ]
     ]
-    FROM [      Variable [ Name=es ]
+    FROM [      Variable [ Name=$es ]
       AS
-      Variable [ Name=e ]
+      Variable [ Name=$e ]
     ]
     Groupby
-      Variable [ Name=chapter_name ]
+      Variable [ Name=$chapter_name ]
       :=
       FieldAccessor [
         FieldAccessor [
-          Variable [ Name=e ]
+          Variable [ Name=$e ]
           Field=sponsor
         ]
         Field=chapter_name
       ]
-      With
-      Variable [ Name=e ]
-      Variable [ Name=sig_sponsorship_count ]
-      Variable [ Name=sponsor ]
-      Variable [ Name=event ]
-      Variable [ Name=es ]
-      Variable [ Name=sig_name ]
+      GROUP AS
+      Variable [ Name=#4 ]
+      (
+      Variable [ Name=$e ]
+       AS e
+      Variable [ Name=$sig_sponsorship_count ]
+       AS sig_sponsorship_count
+      Variable [ Name=$es ]
+       AS es
+      Variable [ Name=$event ]
+       AS event
+      Variable [ Name=$sponsor ]
+       AS sponsor
+      Variable [ Name=$sig_name ]
+       AS sig_name
+      Variable [ Name=#1 ]
+       AS #1
+      )
 
   )
 Orderby
-  Variable [ Name=sig_sponsorship_count ]
+  Variable [ Name=$sig_sponsorship_count ]
   DESC
 
 Limit

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFor.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFor.ast
index 518d51b..d94617e 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFor.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/nestedFor.ast
@@ -5,7 +5,7 @@ RecordConstructor [
     LiteralExpr [STRING] [name]
     :
     FieldAccessor [
-      Variable [ Name=user ]
+      Variable [ Name=$user ]
       Field=name
     ]
   )
@@ -13,7 +13,7 @@ RecordConstructor [
     LiteralExpr [STRING] [movie]
     :
     FieldAccessor [
-      Variable [ Name=mv ]
+      Variable [ Name=$mv ]
       Field=movie
     ]
   )
@@ -23,32 +23,32 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [User]
   ]
   AS
-  Variable [ Name=user ]
+  Variable [ Name=$user ]
 ,
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Movie]
   ]
   AS
-  Variable [ Name=mv ]
+  Variable [ Name=$mv ]
 ]
 Where
   QuantifiedExpression SOME [
-    [Variable [ Name=i ]
+    [Variable [ Name=$i ]
     In
       FieldAccessor [
-        Variable [ Name=user ]
+        Variable [ Name=$user ]
         Field=interests
       ]
     ]
     Satifies [
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=movie
         ]
         =
         FieldAccessor [
-          Variable [ Name=mv ]
+          Variable [ Name=$mv ]
           Field=movie
         ]
       ]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/acc12a9b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/numberInFieldAccessor.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/numberInFieldAccessor.ast b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/numberInFieldAccessor.ast
index 6a681a0..c9ad9d6 100644
--- a/asterix-app/src/test/resources/parserts/results_parser_sqlpp/numberInFieldAccessor.ast
+++ b/asterix-app/src/test/resources/parserts/results_parser_sqlpp/numberInFieldAccessor.ast
@@ -5,7 +5,7 @@ RecordConstructor [
     LiteralExpr [STRING] [name]
     :
     FieldAccessor [
-      Variable [ Name=user ]
+      Variable [ Name=$user ]
       Field=name
     ]
   )
@@ -13,7 +13,7 @@ RecordConstructor [
     LiteralExpr [STRING] [movie]
     :
     FieldAccessor [
-      Variable [ Name=mv ]
+      Variable [ Name=$mv ]
       Field=movie
     ]
   )
@@ -23,33 +23,33 @@ FROM [  FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [User]
   ]
   AS
-  Variable [ Name=user ]
+  Variable [ Name=$user ]
 ,
   FunctionCall Metadata.dataset@1[
     LiteralExpr [STRING] [Movie]
   ]
   AS
-  Variable [ Name=mv ]
+  Variable [ Name=$mv ]
 ]
 Where
   QuantifiedExpression SOME [
-    [Variable [ Name=i ]
+    [Variable [ Name=$i ]
     In
       FieldAccessor [
-        Variable [ Name=user ]
+        Variable [ Name=$user ]
         Field=interests
       ]
     ]
     Satifies [
       OperatorExpr [
         FieldAccessor [
-          Variable [ Name=i ]
+          Variable [ Name=$i ]
           Field=movie
         ]
         =
         IndexAccessor [
           FieldAccessor [
-            Variable [ Name=mv ]
+            Variable [ Name=$mv ]
             Field=movie
           ]
           Index:           LiteralExpr [LONG] [2]



Mime
View raw message