alexander.behm | af5c4e9 | 2012-10-05 06:34:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Description : Test that multiple subtrees in the same query |
| 3 | * can be rewritten with secondary BTree indexes. |
| 4 | * Guards against regression to issue 204. |
| 5 | * Expected Result : Success |
| 6 | * Issue : Issue 204 |
| 7 | */ |
| 8 | |
| 9 | drop dataverse tpch if exists; |
| 10 | create dataverse tpch; |
| 11 | use dataverse tpch; |
| 12 | |
| 13 | create type OrderType as open { |
| 14 | o_orderkey: int32, |
| 15 | o_custkey: int32, |
| 16 | o_orderstatus: string, |
| 17 | o_totalprice: double, |
| 18 | o_orderdate: string, |
| 19 | o_orderpriority: string, |
| 20 | o_clerk: string, |
| 21 | o_shippriority: int32, |
| 22 | o_comment: string |
| 23 | } |
| 24 | |
| 25 | create dataset Orders(OrderType) partitioned by key o_orderkey; |
| 26 | |
| 27 | load dataset Orders |
| 28 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 29 | (("path"="nc1://data/tpch0.001/orders.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted; |
| 30 | |
| 31 | create index idx_Orders_Custkey on Orders(o_custkey); |
| 32 | |
| 33 | write output to nc1:"rttest/index-selection_btree-index-rewrite-multiple.adm"; |
| 34 | |
| 35 | for $o in dataset('Orders') |
| 36 | for $o2 in dataset('Orders') |
| 37 | where $o.o_custkey = 20 and $o2.o_custkey = 10 |
| 38 | and $o.o_orderstatus < $o2.o_orderstatus |
| 39 | order by $o.o_orderkey, $o2.o_orderkey |
| 40 | return { |
| 41 | "o_orderkey": $o.o_orderkey, |
| 42 | "o_custkey": $o.o_custkey, |
| 43 | "o_orderstatus": $o.o_orderstatus, |
| 44 | "o_orderkey2": $o2.o_orderkey, |
| 45 | "o_custkey2": $o2.o_custkey, |
| 46 | "o_orderstatus2": $o2.o_orderstatus |
| 47 | } |
| 48 | |