blob: 545e31f015cf37bd5357de932a810be50cc20704 [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
vinayakb38b7ca42012-03-05 05:44:15 +000034create external dataset Event(EventType)
35using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
36(("path"="nc1://data/events/tiny/event.adm"),("format"="adm"));
37
38write output to nc1:"rttest/dapd_q2.adm";
39
40for $event in dataset('Event')
41for $sponsor in $event.sponsoring_sigs
42let $es := { "event": $event, "sponsor": $sponsor }
43group by $sig_id := $sponsor.sig_id with $es
44let $sig_sponsorship_count := count($es)
45let $by_chapter :=
46 for $e in $es
47 group by $chapter_name := $e.sponsor.chapter_name with $e
48 return { "chapter_name": $chapter_name, "escount" : count($e) }
49order by $sig_sponsorship_count desc
50limit 5
51return { "sig_id": $sig_id, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
52