vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse test if exists; |
| 2 | |
| 3 | create dataverse test; |
| 4 | use dataverse test; |
| 5 | |
| 6 | create type AddressType as closed { |
| 7 | street: string, |
| 8 | city: string, |
| 9 | zip: string, |
| 10 | latlong: point |
| 11 | } |
| 12 | |
| 13 | create 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 | |
| 36 | create nodegroup group1 if not exists on nc1, nc2; |
| 37 | |
| 38 | create external dataset Event(EventType) |
| 39 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 40 | (("path"="nc1://data/events/tiny/event.adm"),("format"="adm")); |
| 41 | |
| 42 | write output to nc1:"rttest/dapd_q2.adm"; |
| 43 | |
| 44 | for $event in dataset('Event') |
| 45 | for $sponsor in $event.sponsoring_sigs |
| 46 | let $es := { "event": $event, "sponsor": $sponsor } |
| 47 | group by $sig_id := $sponsor.sig_id with $es |
| 48 | let $sig_sponsorship_count := count($es) |
| 49 | let $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) } |
| 53 | order by $sig_sponsorship_count desc |
| 54 | limit 5 |
| 55 | return { "sig_id": $sig_id, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter } |
| 56 | |