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