blob: c596984dd68619fe0eefe409578d4ab9a0380a36 [file] [log] [blame]
alexander.behm8a3e3c02012-11-21 07:27:47 +00001/*
2 * Description : Equi joins two datasets, FacebookUsers and FacebookMessages, based on their user's id.
3 * We first expect FacebookUsers' primary index to be used
4 * to satisfy the range condition on it's primary key.
5 * FacebookMessages has a secondary btree index on author-id-copy, and given the 'indexnl' hint
6 * we expect the join to be transformed into an indexed nested-loop join.
7 * Success : Yes
8 */
9
10drop dataverse test if exists;
11create dataverse test;
12use dataverse test;
13
14create type EmploymentType as closed {
15 organization-name: string,
16 start-date: date,
17 end-date: date?
18}
19
20create type FacebookUserType as closed {
21 id: int32,
22 id-copy: int32,
23 alias: string,
24 name: string,
25 user-since: datetime,
26 user-since-copy: datetime,
27 friend-ids: {{ int32 }},
28 employment: [EmploymentType]
29}
30
31create type FacebookMessageType as closed {
32 message-id: int32,
33 message-id-copy: int32,
34 author-id: int32,
35 author-id-copy: int32,
36 in-response-to: int32?,
37 sender-location: point?,
38 message: string
39}
40
41create dataset FacebookUsers(FacebookUserType)
ramangrover29669d8f62013-02-11 06:03:32 +000042primary key id;
alexander.behm8a3e3c02012-11-21 07:27:47 +000043
44create dataset FacebookMessages(FacebookMessageType)
ramangrover29669d8f62013-02-11 06:03:32 +000045primary key message-id;
alexander.behm8a3e3c02012-11-21 07:27:47 +000046
47create index fbmIdxAutId if not exists on FacebookMessages(author-id-copy);
48
49write output to nc1:"rttest/btree-index-join_title-secondary-equi-join-multiindex.adm";
50
51for $user in dataset('FacebookUsers')
52for $message in dataset('FacebookMessages')
53where $user.id /*+ indexnl */ = $message.author-id-copy
54and $user.id >= 11000 and $user.id <= 12000
55return {
56 "fbu-ID": $user.id,
57 "fbm-auth-ID": $message.author-id,
58 "uname": $user.name,
59 "message": $message.message
60}