khfaraaz82@gmail.com | 1fbcdaa | 2012-10-23 20:47:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Description : Insert open data into internal dataset and query the open data |
| 3 | * Expected Result : Success |
| 4 | * Date : 23rd October 2012 |
| 5 | * Notes : This test was written to cover the scenario which is used in the proposal. |
| 6 | * : this is another variant of the test in query-proposal.aql |
| 7 | */ |
| 8 | |
| 9 | drop dataverse test if exists; |
| 10 | create dataverse test; |
| 11 | |
| 12 | use dataverse test; |
| 13 | |
| 14 | create type TweetMessageType as open { |
| 15 | tweetid : string, |
| 16 | user : { |
| 17 | screen-name: string, |
| 18 | lang: string, |
| 19 | friends_count: int32, |
| 20 | statuses_count: int32, |
| 21 | name: string, |
| 22 | followers_count: int32 |
| 23 | }, sender-location: point?, |
| 24 | send-time: datetime, |
| 25 | referred-topics: {{ string }}, |
| 26 | message-text: string |
| 27 | }; |
| 28 | |
| 29 | create dataset TweetMessages(TweetMessageType) |
| 30 | partitioned by key tweetid; |
| 31 | |
| 32 | insert into dataset TweetMessages( |
| 33 | { |
| 34 | "tweetid": "1023", |
| 35 | "user": { |
| 36 | "screen-name": "dflynn24", |
| 37 | "lang": "en", |
| 38 | "friends_count": 46, |
| 39 | "statuses_count": 987, |
| 40 | "name": "danielle flynn", |
| 41 | "followers_count": 47 |
| 42 | }, |
| 43 | "sender-location": create-point(40.904177,-72.958996), |
| 44 | "send-time": datetime("2010-02-21T11:56:02-05:00"), |
| 45 | "referred-topics": {{ "verizon" }}, |
| 46 | "message-text": "i need a #verizon phone like nowwwww! : (" |
| 47 | }); |
| 48 | |
| 49 | insert into dataset TweetMessages( |
| 50 | { |
| 51 | "tweetid": "1024", |
| 52 | "user": { |
| 53 | "screen-name": "miriamorous", |
| 54 | "lang": "en", |
| 55 | "friends_count": 69, |
| 56 | "statuses_count": 1068, |
| 57 | "name": "Miriam Songco", |
| 58 | "followers_count": 78 |
| 59 | }, |
| 60 | "send-time": datetime("2010-02-21T11:11:43-08:00"), |
| 61 | "referred-topics": {{ "commercials", "verizon", "att" }}, |
| 62 | "message-text": "#verizon & #att #commercials, so competitive" |
| 63 | }); |
| 64 | |
| 65 | insert into dataset TweetMessages( |
| 66 | { |
| 67 | "tweetid": "1025", |
| 68 | "user": { |
| 69 | "screen-name": "dj33", |
| 70 | "lang": "en", |
| 71 | "friends_count": 96, |
| 72 | "send-time": "2010-02-21T11:56:02-05:00", |
| 73 | "statuses_count": 1696, |
| 74 | "name": "Don Jango", |
| 75 | "followers_count": 22 |
| 76 | }, |
| 77 | "send-time": datetime("2010-02-21T12:38:44-05:00"), |
| 78 | "referred-topics": {{ "charlotte" }}, |
| 79 | "message-text": "Chillin at dca waiting for 900am flight to #charlotte and from there to providenciales" |
| 80 | }); |
| 81 | |
| 82 | insert into dataset TweetMessages( |
| 83 | { "tweetid": "1026", |
| 84 | "user": { |
| 85 | "screen-name": "reallyleila", |
| 86 | "lang": "en", |
| 87 | "friends_count": 106, |
| 88 | "statuses_count": 107, |
| 89 | "name": "Leila Samii", |
| 90 | "followers_count": 52 |
| 91 | }, |
| 92 | "send-time": datetime("2010-02-21T21:31:57-06:00"), |
| 93 | "referred-topics": {{ "verizon", "at&t", "iphone" }}, |
| 94 | "message-text": "I think a switch from #verizon to #at&t may be in my near future... my smartphone is like a land line compared to the #iphone!" |
| 95 | }); |
| 96 | |
| 97 | write output to nc1:"rttest/open-closed_query-proposal02.adm"; |
| 98 | |
| 99 | for $tweet in dataset('TweetMessages') |
| 100 | where some $reftopic in $tweet.referred-topics |
| 101 | satisfies contains($reftopic, 'verizon') |
| 102 | for $reftopic in $tweet.referred-topics |
| 103 | group by $topic := $reftopic with $tweet |
| 104 | order by $topic |
| 105 | return |
| 106 | { |
| 107 | "topic": $topic, |
| 108 | "count": count($tweet) |
| 109 | } |
| 110 | |