Added asterix project
git-svn-id: https://asterixdb.googlecode.com/svn/trunk/asterix@12 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/AQLTS/queries/1.aql b/asterix-app/src/test/resources/AQLTS/queries/1.aql
new file mode 100644
index 0000000..7561215
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/1.aql
@@ -0,0 +1,3 @@
+for $user in dataset('User')
+where some $i in $user.interests satisfies $i = "movies"
+return { "name": $user.name }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/2.aql b/asterix-app/src/test/resources/AQLTS/queries/2.aql
new file mode 100644
index 0000000..0757d9d
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/2.aql
@@ -0,0 +1,12 @@
+for $event in dataset('Event')
+for $sponsor in $event.sponsoring_sigs
+let $es := { "event": $event, "sponsor": $sponsor }
+group by $sig_name := $sponsor.sig_name with $es
+let $sig_sponsorship_count := count($es)
+let $by_chapter :=
+ for $e in $es
+ group by $chapter_name := $e.sponsor.chapter_name with $es
+ return { "chapter_name": $chapter_name, "escount" : count($es) }
+order by $sig_sponsorship_count desc
+limit 5
+return { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/3.aql b/asterix-app/src/test/resources/AQLTS/queries/3.aql
new file mode 100644
index 0000000..3d71b27
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/3.aql
@@ -0,0 +1,5 @@
+for $current_sig in dataset('SIGroup')
+where
+ every $old_sig in dataset('SIGroup', getCurrentDateTime() - dtduration(0, 24, 0, 0))
+ satisfies $old_sig.name != $current_sig.name
+return $current_sig
diff --git a/asterix-app/src/test/resources/AQLTS/queries/4.aql b/asterix-app/src/test/resources/AQLTS/queries/4.aql
new file mode 100644
index 0000000..f77ca02
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/4.aql
@@ -0,0 +1,8 @@
+for $sig in dataset('SIGroup')
+where $sig.name = "Movie-Watchers"
+let $similar_sigs :=
+ for $similar_sig in dataset('SIGroup')
+ where $similar_sig != $sig
+ and $similar_sig.interests ~= $sig.interests
+ return { "sig_name" : $similar_sig.name }
+return { "similar_sigs" : $similar_sigs }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/5.aql b/asterix-app/src/test/resources/AQLTS/queries/5.aql
new file mode 100644
index 0000000..2dfb537
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/5.aql
@@ -0,0 +1,10 @@
+for $event in dataset('Event')
+where $event.name = "The Night of the Ad Eaters, 29th edition"
+let $collocated_events :=
+ for $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
+ return { "event_name" : $collocated_event.name }
+return { "collocated_evnets" : $collocated_events }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/6.aql b/asterix-app/src/test/resources/AQLTS/queries/6.aql
new file mode 100644
index 0000000..d5e71e6
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/6.aql
@@ -0,0 +1,10 @@
+for $user in dataset('Users')
+let $similar_users :=
+ for $similar_user in dataset('Users')
+ let $similarity := jaccard_similarity($user.interests, $similar_user.interests)
+ where $user != $similar_user
+ and $similarity >= .75
+ order by $similarity desc
+ limit 10
+ return { "user_name" : $similar_user.name, "similarity" : $similarity }
+return { "user_name" : $user.name, "similar_users" : $similar_users }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/ANYInFieldAccessor.aql b/asterix-app/src/test/resources/AQLTS/queries/ANYInFieldAccessor.aql
new file mode 100644
index 0000000..c72e4a0
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/ANYInFieldAccessor.aql
@@ -0,0 +1,4 @@
+for $user in dataset('User')
+for $mv in dataset('Movie')
+where some $i in $user.interests satisfies $i.movie = $mv.movie[?]
+return { "name": $user.name, "movie": $mv.movie }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/IfInFLOWGR.aql b/asterix-app/src/test/resources/AQLTS/queries/IfInFLOWGR.aql
new file mode 100644
index 0000000..9e70c7a
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/IfInFLOWGR.aql
@@ -0,0 +1,3 @@
+for $i in [1,2,30,40]
+for $j in {{4,5,6}}
+return if ($i>$j) then $i else $j
diff --git a/asterix-app/src/test/resources/AQLTS/queries/IfThenElse.aql b/asterix-app/src/test/resources/AQLTS/queries/IfThenElse.aql
new file mode 100644
index 0000000..18d19f9
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/IfThenElse.aql
@@ -0,0 +1,4 @@
+if (2>1) then
+ 20
+else
+ 10
diff --git a/asterix-app/src/test/resources/AQLTS/queries/LetFor.aql b/asterix-app/src/test/resources/AQLTS/queries/LetFor.aql
new file mode 100644
index 0000000..26f5f82
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/LetFor.aql
@@ -0,0 +1,4 @@
+let $users := dataset('User')
+for $user in $users
+where some $i in $user.interests satisfies $i = "movies"
+return { "name": $user.name }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/ListConstructor.aql b/asterix-app/src/test/resources/AQLTS/queries/ListConstructor.aql
new file mode 100644
index 0000000..924d3df
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/ListConstructor.aql
@@ -0,0 +1,3 @@
+for $i in [1,2,3]
+for $j in {{4,5,6}}
+return $i+$j
diff --git a/asterix-app/src/test/resources/AQLTS/queries/addOperator.aql b/asterix-app/src/test/resources/AQLTS/queries/addOperator.aql
new file mode 100644
index 0000000..e621f17
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/addOperator.aql
@@ -0,0 +1 @@
+1+1-2
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries/constant.aql b/asterix-app/src/test/resources/AQLTS/queries/constant.aql
new file mode 100644
index 0000000..71181c0
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/constant.aql
@@ -0,0 +1 @@
+-1 +1
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql b/asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql
new file mode 100644
index 0000000..51e4344
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/del-dataset.aql
@@ -0,0 +1,29 @@
+drop dataverse demo0927 if exists;
+
+create dataverse demo0927;
+
+use dataverse demo0927;
+
+create type CustomerType as closed {
+ cid: int32,
+ name: string,
+ age: int32?,
+ address: AddressType?,
+ lastorder: {
+ oid: int32,
+ total: float
+ }
+}
+
+create type AddressType as closed {
+ number: int32,
+ street: string,
+ city: string
+}
+
+create nodegroup group1 if not exists on nc1, nc2;
+
+create dataset Customers(CustomerType)
+ partitioned by key cid on group1;
+
+drop dataset Customers;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries/functionDecl.aql b/asterix-app/src/test/resources/AQLTS/queries/functionDecl.aql
new file mode 100644
index 0000000..25455cc
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/functionDecl.aql
@@ -0,0 +1,7 @@
+declare function add($a, $b){
+ $a + $b
+}
+
+declare function minus($a, $b){
+ $a - $b
+}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries/functionDecl1.aql b/asterix-app/src/test/resources/AQLTS/queries/functionDecl1.aql
new file mode 100644
index 0000000..2b24cc0
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/functionDecl1.aql
@@ -0,0 +1,17 @@
+declare function calculate($events){
+for $event in $events
+for $sponsor in $event.sponsoring_sigs
+let $es := { "event": $event, "sponsor": $sponsor }
+group by $sig_name := $sponsor.sig_name with $es
+let $sig_sponsorship_count := count($es)
+let $by_chapter :=
+ for $e in $es
+ group by $chapter_name := $e.sponsor.chapter_name with $es
+ return { "chapter_name": $chapter_name, "escount" : count($es) }
+order by $sig_sponsorship_count desc
+limit 5
+return { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
+}
+
+let $result := calculate(dataset('Events'))
+return $result
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries/functionDecl2.aql b/asterix-app/src/test/resources/AQLTS/queries/functionDecl2.aql
new file mode 100644
index 0000000..abb8f9d
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/functionDecl2.aql
@@ -0,0 +1,6 @@
+declare function GT($a, $b){
+if ($a > $b) then
+ true
+else
+ false
+}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql b/asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql
new file mode 100644
index 0000000..f70de14
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/load-del-dataset.aql
@@ -0,0 +1,32 @@
+drop dataverse demo0927 if exists;
+
+create dataverse demo0927;
+
+use dataverse demo0927;
+
+create type CustomerType as closed {
+ cid: int32,
+ name: string,
+ age: int32?,
+ address: AddressType?,
+ lastorder: {
+ oid: int32,
+ total: float
+ }
+}
+
+create type AddressType as closed {
+ number: int32,
+ street: string,
+ city: string
+}
+
+create nodegroup group1 if not exists on nc1, nc2;
+
+create dataset Customers(CustomerType)
+ partitioned by key cid on group1;
+
+load dataset Customers
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1:///tmp/customerData.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/AQLTS/queries/mulOperator.aql b/asterix-app/src/test/resources/AQLTS/queries/mulOperator.aql
new file mode 100644
index 0000000..d604a5c
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/mulOperator.aql
@@ -0,0 +1 @@
+1+2*3-4
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR.aql b/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR.aql
new file mode 100644
index 0000000..88e9b05
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR.aql
@@ -0,0 +1,5 @@
+for $user in
+ let $data := dataset('User')
+ return $data
+where some $i in $user.interests satisfies $i = "movies"
+return { "name": $user.name }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR1.aql b/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR1.aql
new file mode 100644
index 0000000..5b3bb1c
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR1.aql
@@ -0,0 +1,6 @@
+for $i in [1,2,30,40]
+for $j in {{4,5,6}}
+return
+ for $k in if ($i>$j) then $i else $j
+ where $k <10
+ return $k
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR2.aql b/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR2.aql
new file mode 100644
index 0000000..9dbc965
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR2.aql
@@ -0,0 +1,6 @@
+for $i in [1,2,30,for $tmp in dataset('number') return $tmp]
+for $j in {{4,5,6}}
+return
+ for $k in if ($i>$j) then $i else $j
+ where $k <10
+ return $k
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR3.aql b/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR3.aql
new file mode 100644
index 0000000..23fb4b2
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/nestedFLWOGR3.aql
@@ -0,0 +1,12 @@
+for $event in dataset('Event')
+for $sponsor in $event.sponsoring_sigs
+let $es := { "event": $event, "sponsor": $sponsor }
+group by $sig_name := $sponsor.sig_name with $es
+let $sig_sponsorship_count := count($es)
+let $by_chapter :=
+ for $e in $es
+ group by $chapter_name := $e.sponsor.chapter_name with $es
+ return { "chapter_name": $chapter_name, "escount" : count($es) }
+order by $sig_sponsorship_count desc
+limit 5 offset 2
+return { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/nestedFor.aql b/asterix-app/src/test/resources/AQLTS/queries/nestedFor.aql
new file mode 100644
index 0000000..46bd8b0
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/nestedFor.aql
@@ -0,0 +1,4 @@
+for $user in dataset('User')
+for $mv in dataset('Movie')
+where some $i in $user.interests satisfies $i.movie = $mv.movie
+return { "name": $user.name, "movie": $mv.movie }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/numberInFieldAccessor.aql b/asterix-app/src/test/resources/AQLTS/queries/numberInFieldAccessor.aql
new file mode 100644
index 0000000..ab7d964
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/numberInFieldAccessor.aql
@@ -0,0 +1,4 @@
+for $user in dataset('User')
+for $mv in dataset('Movie')
+where some $i in $user.interests satisfies $i.movie = $mv.movie[2]
+return { "name": $user.name, "movie": $mv.movie }
diff --git a/asterix-app/src/test/resources/AQLTS/queries/union.aql b/asterix-app/src/test/resources/AQLTS/queries/union.aql
new file mode 100644
index 0000000..90c6c0d
--- /dev/null
+++ b/asterix-app/src/test/resources/AQLTS/queries/union.aql
@@ -0,0 +1,8 @@
+(for $l in foo1()
+return $l)
+union
+(for $l in foo2()
+return $l)
+union
+(for $l in foo3()
+return $l)