blob: e4c140cc59e46cb0409edb264d10f8ed82b7d488 [file] [log] [blame]
alexander.behm3caae9e2012-11-08 04:50:20 +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.behm3caae9e2012-11-08 04:50:20 +000020 * Description : Equi joins two datasets, Customers and Orders, based on the customer id.
21 * Given the 'indexnl' hint we expect the join to be transformed
22 * into an indexed nested-loop join using Customers' primary index.
23 * We expect the additional predicates to be put into a select above the
24 * primary index search.
25 * Success : Yes
26 */
27
28drop dataverse test if exists;
29create dataverse test;
30use dataverse test;
31
32create type AddressType as closed {
33 number: int32,
34 street: string,
35 city: string
36}
37
38create type CustomerType as closed {
39 cid: int32,
40 name: string,
41 age: int32?,
42 address: AddressType?,
43 lastorder: {
44 oid: int32,
45 total: float
46 }
47}
48
49create type OrderType as closed {
50 oid: int32,
51 cid: int32,
52 orderstatus: string,
53 orderpriority: string,
54 clerk: string,
55 total: float
56}
57
ramangrover29669d8f62013-02-11 06:03:32 +000058create dataset Customers(CustomerType) primary key cid;
59create dataset Orders(OrderType) primary key oid;
alexander.behm3caae9e2012-11-08 04:50:20 +000060
61write output to nc1:"rttest/btree-index-join_primary-equi-join-multipred.adm";
62
63for $c in dataset('Customers')
64for $o in dataset('Orders')
65where $c.cid /*+ indexnl */ = $o.cid and $c.name < $o.orderstatus and $c.age < $o.cid
66return {"customer":$c, "order": $o}