alexander.behm | 3caae9e | 2012-11-08 04:50:20 +0000 | [diff] [blame] | 1 | /* |
Ian Maxon | 857dc13 | 2015-09-25 17:13:19 -0700 | [diff] [blame^] | 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 | */ |
| 19 | /* |
alexander.behm | 3caae9e | 2012-11-08 04:50:20 +0000 | [diff] [blame] | 20 | * 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 | |
| 28 | drop dataverse test if exists; |
| 29 | create dataverse test; |
| 30 | use dataverse test; |
| 31 | |
| 32 | create type AddressType as closed { |
| 33 | number: int32, |
| 34 | street: string, |
| 35 | city: string |
| 36 | } |
| 37 | |
| 38 | create 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 | |
| 49 | create type OrderType as closed { |
| 50 | oid: int32, |
| 51 | cid: int32, |
| 52 | orderstatus: string, |
| 53 | orderpriority: string, |
| 54 | clerk: string, |
| 55 | total: float |
| 56 | } |
| 57 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 58 | create dataset Customers(CustomerType) primary key cid; |
| 59 | create dataset Orders(OrderType) primary key oid; |
alexander.behm | 3caae9e | 2012-11-08 04:50:20 +0000 | [diff] [blame] | 60 | |
| 61 | write output to nc1:"rttest/btree-index-join_primary-equi-join-multipred.adm"; |
| 62 | |
| 63 | for $c in dataset('Customers') |
| 64 | for $o in dataset('Orders') |
| 65 | where $c.cid /*+ indexnl */ = $o.cid and $c.name < $o.orderstatus and $c.age < $o.cid |
| 66 | return {"customer":$c, "order": $o} |