blob: d304b3b3a568da25e59f4a8f1f2029b6451ee4cb [file] [log] [blame]
alexander.behm8a3e3c02012-11-21 07:27:47 +00001/*
Ian Maxon857dc132015-09-25 17:13:19 -07002 * 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 */
19/*
alexander.behm8a3e3c02012-11-21 07:27:47 +000020 * Description : Equi joins two datasets, FacebookUsers and FacebookMessages, based on their user's id.
21 * We first expect FacebookUsers' primary index to be used
22 * to satisfy the range condition on it's primary key.
23 * FacebookMessages has a secondary btree index on author-id-copy, and given the 'indexnl' hint
24 * we expect the join to be transformed into an indexed nested-loop join.
25 * Success : Yes
26 */
27
28drop dataverse test if exists;
29create dataverse test;
30use dataverse test;
31
32create type EmploymentType as closed {
33 organization-name: string,
34 start-date: date,
35 end-date: date?
36}
37
38create type FacebookUserType as closed {
39 id: int32,
40 id-copy: int32,
41 alias: string,
42 name: string,
43 user-since: datetime,
44 user-since-copy: datetime,
45 friend-ids: {{ int32 }},
46 employment: [EmploymentType]
47}
48
49create type FacebookMessageType as closed {
50 message-id: int32,
51 message-id-copy: int32,
52 author-id: int32,
53 author-id-copy: int32,
54 in-response-to: int32?,
55 sender-location: point?,
56 message: string
57}
58
59create dataset FacebookUsers(FacebookUserType)
ramangrover29669d8f62013-02-11 06:03:32 +000060primary key id;
alexander.behm8a3e3c02012-11-21 07:27:47 +000061
62create dataset FacebookMessages(FacebookMessageType)
ramangrover29669d8f62013-02-11 06:03:32 +000063primary key message-id;
alexander.behm8a3e3c02012-11-21 07:27:47 +000064
65create index fbmIdxAutId if not exists on FacebookMessages(author-id-copy);
66
67write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multiindex.adm";
68
69for $user in dataset('FacebookUsers')
70for $message in dataset('FacebookMessages')
71where $user.id /*+ indexnl */ = $message.author-id-copy
72and $user.id >= 11000 and $user.id <= 12000
73return {
74 "fbu-ID": $user.id,
75 "fbm-auth-ID": $message.author-id,
76 "uname": $user.name,
77 "message": $message.message
78}