blob: 171fb022ad932adc9ddfff5097497a25b2d0a847 [file] [log] [blame]
vinayakb38b7ca42012-03-05 05:44:15 +00001drop dataverse test if exists;
2
3create dataverse test;
4use dataverse test;
5
6create type AddressType as closed {
7 street: string,
8 city: string,
9 zip: string,
10 latlong: point
11}
12
13create type EventType as closed {
14 event_id: int32,
15 name: string,
16 location: AddressType ?,
17 organizers: {{
18 {
19 name: string
20 }
21 }},
22 sponsoring_sigs: [
23 {
24 sig_id: int32,
25 chapter_name: string
26 }
27 ],
28 interest_keywords: {{string}},
29 price: double?,
30 start_time: datetime,
31 end_time: datetime
32}
33
34
35
36create nodegroup group1 if not exists on nc1, nc2;
37
38create external dataset Event(EventType)
39using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
40(("path"="nc1://data/events/tiny/event.adm"),("format"="adm"));
41
42write output to nc1:"rttest/dapd_q2.adm";
43
44for $event in dataset('Event')
45for $sponsor in $event.sponsoring_sigs
46let $es := { "event": $event, "sponsor": $sponsor }
47group by $sig_id := $sponsor.sig_id with $es
48let $sig_sponsorship_count := count($es)
49let $by_chapter :=
50 for $e in $es
51 group by $chapter_name := $e.sponsor.chapter_name with $e
52 return { "chapter_name": $chapter_name, "escount" : count($e) }
53order by $sig_sponsorship_count desc
54limit 5
55return { "sig_id": $sig_id, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
56