Add NoSQL grammar:
Please make FROM a synonym for FOR, SELECT a synonym for RETURN, and WITH a synonym for LET.  No semantic changes here - just some keyword synonyms.

Change-Id: Iffba1c25c611fc420b6e223bcdde75a9244035e4
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/181
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <westmann@gmail.com>
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/1.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/1.aql
new file mode 100644
index 0000000..37a2b3f
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/1.aql
@@ -0,0 +1,3 @@
+from $user in dataset('User')
+where some $i in $user.interests satisfies $i = "movies"
+select { "name": $user.name }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/2.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/2.aql
new file mode 100644
index 0000000..d094e7e
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/2.aql
@@ -0,0 +1,12 @@
+from $event in dataset('Event')
+from $sponsor in $event.sponsoring_sigs
+with $es := { "event": $event, "sponsor": $sponsor }
+group by $sig_name := $sponsor.sig_name with $es
+with $sig_sponsorship_count := count($es)
+with $by_chapter :=
+   from $e in $es
+   group by $chapter_name := $e.sponsor.chapter_name with $es
+   select { "chapter_name": $chapter_name, "escount" : count($es) }
+order by $sig_sponsorship_count desc
+limit 5
+select { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/4.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/4.aql
new file mode 100644
index 0000000..ca9e728
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/4.aql
@@ -0,0 +1,8 @@
+from $sig in dataset('SIGroup')
+where $sig.name = "Movie-Watchers"
+with $similar_sigs :=
+   from $similar_sig in dataset('SIGroup')
+   where $similar_sig != $sig
+   and $similar_sig.interests ~= $sig.interests
+   select { "sig_name" : $similar_sig.name }
+select { "similar_sigs" : $similar_sigs }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/5.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/5.aql
new file mode 100644
index 0000000..4fe6be0
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/5.aql
@@ -0,0 +1,10 @@
+from $event in dataset('Event')
+where $event.name = "The Night of the Ad Eaters, 29th edition"
+with $collocated_events :=
+   from $collocated_event in dataset('Events')
+   where $collocated_event.location.street ~= $event.location.street
+   and $collocated_event.location.city = $event.location.city
+   and $collocated_event.location.state = $event.location.state
+   and $collocated_event.location.zip = $event.location.zip
+   select { "event_name" : $collocated_event.name }
+select { "collocated_evnets" : $collocated_events }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/6.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/6.aql
new file mode 100644
index 0000000..f71a00c
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/6.aql
@@ -0,0 +1,10 @@
+from $user in dataset('Users')
+with $similar_users :=
+   from $similar_user in dataset('Users')
+   with $similarity := jaccard_similarity($user.interests, $similar_user.interests)
+   where $user != $similar_user
+   and $similarity >= .75
+   order by $similarity desc
+   limit 10
+   select { "user_name" : $similar_user.name, "similarity" : $similarity }
+select { "user_name" : $user.name, "similar_users" : $similar_users }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/ANYInFieldAccessor.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/ANYInFieldAccessor.aql
new file mode 100644
index 0000000..61ef75b
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/ANYInFieldAccessor.aql
@@ -0,0 +1,4 @@
+from $user in dataset('User')
+from $mv in dataset('Movie')
+where some $i in $user.interests satisfies $i.movie = $mv.movie[?]
+select { "name": $user.name, "movie": $mv.movie }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/IfInFLOWGR.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/IfInFLOWGR.aql
new file mode 100644
index 0000000..b3d7a72
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/IfInFLOWGR.aql
@@ -0,0 +1,3 @@
+from $i in [1,2,30,40]
+from $j in {{4,5,6}}
+select if ($i>$j) then $i else $j
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/ListConstructor.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/ListConstructor.aql
new file mode 100644
index 0000000..ca990fc
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/ListConstructor.aql
@@ -0,0 +1,3 @@
+from $i in [1,2,3]
+from $j in {{4,5,6}}
+select $i+$j
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/WithFrom.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/WithFrom.aql
new file mode 100644
index 0000000..1ec743a
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/WithFrom.aql
@@ -0,0 +1,4 @@
+with $users := dataset('User')
+from $user in $users
+where some $i in $user.interests satisfies $i = "movies"
+select { "name": $user.name }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/fieldAccessor.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/fieldAccessor.aql
new file mode 100644
index 0000000..3b1c725
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/fieldAccessor.aql
@@ -0,0 +1,3 @@
+with $bla := { "name" : "value" }
+return
+  $bla."name" = $bla.name
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/functionDecl1.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/functionDecl1.aql
new file mode 100644
index 0000000..9a77c84
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/functionDecl1.aql
@@ -0,0 +1,17 @@
+declare function calculate($events){
+from $event in $events
+from $sponsor in $event.sponsoring_sigs
+with $es := { "event": $event, "sponsor": $sponsor }
+group by $sig_name := $sponsor.sig_name with $es
+with $sig_sponsorship_count := count($es)
+with $by_chapter :=
+   from $e in $es
+   group by $chapter_name := $e.sponsor.chapter_name with $es
+   select { "chapter_name": $chapter_name, "escount" : count($es) }
+order by $sig_sponsorship_count desc
+limit 5
+select { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
+}
+
+with $result := calculate(dataset('Events'))
+select $result
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR.aql
new file mode 100644
index 0000000..98424dc
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR.aql
@@ -0,0 +1,5 @@
+from $user in
+    with $data := dataset('User')
+    select $data
+where some $i in $user.interests satisfies $i = "movies"
+select { "name": $user.name }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR1.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR1.aql
new file mode 100644
index 0000000..a9c59f2
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR1.aql
@@ -0,0 +1,6 @@
+from $i in [1,2,30,40]
+from $j in {{4,5,6}}
+select
+    from $k in if ($i>$j) then $i else $j
+    where $k <10
+    select $k
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR2.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR2.aql
new file mode 100644
index 0000000..3ceca7a
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR2.aql
@@ -0,0 +1,6 @@
+from $i in [1,2,30,from $tmp in dataset('number') select $tmp]
+from $j in {{4,5,6}}
+select
+    from $k in if ($i>$j) then $i else $j
+    where $k <10
+    select $k
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR3.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR3.aql
new file mode 100644
index 0000000..0f5fa5f
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFLWOGR3.aql
@@ -0,0 +1,12 @@
+from $event in dataset('Event')
+from $sponsor in $event.sponsoring_sigs
+with $es := { "event": $event, "sponsor": $sponsor }
+group by $sig_name := $sponsor.sig_name with $es
+with $sig_sponsorship_count := count($es)
+with $by_chapter :=
+   from $e in $es
+   group by $chapter_name := $e.sponsor.chapter_name with $es
+   select { "chapter_name": $chapter_name, "escount" : count($es) }
+order by $sig_sponsorship_count desc
+limit 5 offset 2
+select { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFor.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFor.aql
new file mode 100644
index 0000000..26c3564
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/nestedFor.aql
@@ -0,0 +1,4 @@
+from $user in dataset('User')
+from $mv in dataset('Movie')
+where some $i in $user.interests satisfies $i.movie = $mv.movie
+select { "name": $user.name, "movie": $mv.movie }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/numberInFieldAccessor.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/numberInFieldAccessor.aql
new file mode 100644
index 0000000..b52ff3a
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/numberInFieldAccessor.aql
@@ -0,0 +1,4 @@
+from $user in dataset('User')
+from $mv in dataset('Movie')
+where some $i in $user.interests satisfies $i.movie = $mv.movie[2]
+select { "name": $user.name, "movie": $mv.movie }
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/union.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/union.aql
new file mode 100644
index 0000000..fc4352d
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/union.aql
@@ -0,0 +1,8 @@
+(from $l in foo1()
+select $l)
+union
+(from $l in foo2()
+select $l)
+union
+(from $l in foo3()
+select $l)
diff --git a/asterix-app/src/test/resources/AQLTS/queries-sql-like/variables.aql b/asterix-app/src/test/resources/AQLTS/queries-sql-like/variables.aql
new file mode 100644
index 0000000..0cf91cd
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries-sql-like/variables.aql
@@ -0,0 +1,4 @@
+with $a:=1
+with $b:=1
+return
+  $b-$a