alexander.behm | 3caae9e | 2012-11-08 04:50:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Description : Equi joins two datasets, Customers and Orders, based on the customer id. |
| 3 | * Given the 'indexnl' hint we expect the join to be transformed |
| 4 | * into an indexed nested-loop join using Customers' primary index. |
| 5 | * We expect the additional predicates to be put into a select above the |
| 6 | * primary index search. |
| 7 | * Success : Yes |
| 8 | */ |
| 9 | |
| 10 | drop dataverse test if exists; |
| 11 | create dataverse test; |
| 12 | use dataverse test; |
| 13 | |
| 14 | create type AddressType as closed { |
| 15 | number: int32, |
| 16 | street: string, |
| 17 | city: string |
| 18 | } |
| 19 | |
| 20 | create type CustomerType as closed { |
| 21 | cid: int32, |
| 22 | name: string, |
| 23 | age: int32?, |
| 24 | address: AddressType?, |
| 25 | lastorder: { |
| 26 | oid: int32, |
| 27 | total: float |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | create type OrderType as closed { |
| 32 | oid: int32, |
| 33 | cid: int32, |
| 34 | orderstatus: string, |
| 35 | orderpriority: string, |
| 36 | clerk: string, |
| 37 | total: float |
| 38 | } |
| 39 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 40 | create dataset Customers(CustomerType) primary key cid; |
| 41 | create dataset Orders(OrderType) primary key oid; |
alexander.behm | 3caae9e | 2012-11-08 04:50:20 +0000 | [diff] [blame] | 42 | |
| 43 | write output to nc1:"rttest/btree-index-join_primary-equi-join-multipred.adm"; |
| 44 | |
| 45 | for $c in dataset('Customers') |
| 46 | for $o in dataset('Orders') |
| 47 | where $c.cid /*+ indexnl */ = $o.cid and $c.name < $o.orderstatus and $c.age < $o.cid |
| 48 | return {"customer":$c, "order": $o} |