blob: a3bb0fc4a3671a77e7f8634a9f7bc580a23a8450 [file] [log] [blame]
Ian Maxon857dc132015-09-25 17:13:19 -07001/*
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 */
icetindile8fd4cc2014-08-05 20:25:16 -070019drop dataverse TinySocial if exists;
20create dataverse TinySocial;
21use dataverse TinySocial;
22
23
24create type EmploymentType as open {
25 organization-name: string,
26 start-date: date,
27 end-date: date?
28}
29
30create 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
39create dataset FacebookUsers(FacebookUserType)
40primary key id;
41
42
43let $lonelyusers := for $d in dataset FacebookUsers where count($d.friend-ids) < 2 return $d
44let $lonelyusers2 := for $d in dataset FacebookUsers where count($d.friend-ids) < 2 return $d
45for $l1 in $lonelyusers
46for $l2 in $lonelyusers2
47where $l1.id < $l2.id
48order by $l1.id, $l2.id
Ian Maxon857dc132015-09-25 17:13:19 -070049return { "user1": { "id": $l1.id, "name": $l1.name }, "user2": { "id": $l2.id, "name": $l2.name } };