Ian Maxon | 857dc13 | 2015-09-25 17:13:19 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
icetindil | e8fd4cc | 2014-08-05 20:25:16 -0700 | [diff] [blame] | 19 | drop dataverse TinySocial if exists; |
| 20 | create dataverse TinySocial; |
| 21 | use dataverse TinySocial; |
| 22 | |
| 23 | |
| 24 | create type EmploymentType as open { |
| 25 | organization-name: string, |
| 26 | start-date: date, |
| 27 | end-date: date? |
| 28 | } |
| 29 | |
| 30 | create type FacebookUserType as closed { |
| 31 | id: int32, |
| 32 | alias: string, |
| 33 | name: string, |
| 34 | user-since: datetime, |
| 35 | friend-ids: {{ int32 }}, |
| 36 | employment: [EmploymentType] |
| 37 | } |
| 38 | |
| 39 | create dataset FacebookUsers(FacebookUserType) |
| 40 | primary key id; |
| 41 | |
| 42 | |
| 43 | let $lonelyusers := for $d in dataset FacebookUsers where count($d.friend-ids) < 2 return $d |
| 44 | let $lonelyusers2 := for $d in dataset FacebookUsers where count($d.friend-ids) < 2 return $d |
| 45 | for $l1 in $lonelyusers |
| 46 | for $l2 in $lonelyusers2 |
| 47 | where $l1.id < $l2.id |
| 48 | order by $l1.id, $l2.id |
Ian Maxon | 857dc13 | 2015-09-25 17:13:19 -0700 | [diff] [blame^] | 49 | return { "user1": { "id": $l1.id, "name": $l1.name }, "user2": { "id": $l2.id, "name": $l2.name } }; |