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 | * Success : Yes |
| 6 | */ |
| 7 | |
| 8 | drop dataverse test if exists; |
| 9 | create dataverse test; |
| 10 | use dataverse test; |
| 11 | |
| 12 | create type AddressType as open { |
| 13 | number: int32, |
| 14 | street: string, |
| 15 | city: string |
| 16 | } |
| 17 | |
| 18 | create type CustomerType as closed { |
| 19 | cid: int32, |
| 20 | name: string, |
| 21 | cashBack: int32, |
| 22 | age: int32?, |
| 23 | address: AddressType?, |
| 24 | lastorder: { |
| 25 | oid: int32, |
| 26 | total: float |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | create type OrderType as open { |
| 31 | oid: int32, |
| 32 | cid: int32, |
| 33 | orderstatus: string, |
| 34 | orderpriority: string, |
| 35 | clerk: string, |
| 36 | total: float, |
| 37 | items: [int32] |
| 38 | } |
| 39 | |
| 40 | create dataset Customers(CustomerType) partitioned by key cid; |
| 41 | create dataset Orders(OrderType) partitioned by key oid; |
| 42 | |
| 43 | load dataset Customers |
| 44 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 45 | (("path"="nc1://data/nontagged/customerData.json"),("format"="adm")); |
| 46 | |
| 47 | load dataset Orders |
| 48 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 49 | (("path"="nc1://data/nontagged/orderData.json"),("format"="adm")); |
| 50 | |
| 51 | write output to nc1:"rttest/index-join_btree-primary-equi-join.adm"; |
| 52 | |
| 53 | for $c in dataset('Customers') |
| 54 | for $o in dataset('Orders') |
| 55 | where $c.cid /*+ indexnl */ = $o.cid |
| 56 | order by $c.cid, $o.oid |
| 57 | return {"cid":$c.cid, "oid": $o.oid} |