buyingyi | b1dd834 | 2014-11-26 14:37:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Description : This test case is to verify the fix for issue810 |
| 3 | * https://code.google.com/p/asterixdb/issues/detail?id=810 |
| 4 | * Expected Res : SUCCESS |
| 5 | * Date : 24th Nov. 2014 |
| 6 | */ |
| 7 | |
| 8 | drop dataverse tpch if exists; |
| 9 | create dataverse tpch; |
| 10 | |
| 11 | use dataverse tpch; |
| 12 | |
| 13 | create type LineItemType as closed { |
| 14 | l_orderkey: int32, |
| 15 | l_partkey: int32, |
| 16 | l_suppkey: int32, |
| 17 | l_linenumber: int32, |
| 18 | l_quantity: double, |
| 19 | l_extendedprice: double, |
| 20 | l_discount: double, |
| 21 | l_tax: double, |
| 22 | l_returnflag: string, |
| 23 | l_linestatus: string, |
| 24 | l_shipdate: string, |
| 25 | l_commitdate: string, |
| 26 | l_receiptdate: string, |
| 27 | l_shipinstruct: string, |
| 28 | l_shipmode: string, |
| 29 | l_comment: string |
| 30 | } |
| 31 | |
| 32 | create dataset LineItem(LineItemType) |
| 33 | primary key l_orderkey, l_linenumber; |
| 34 | |
| 35 | |
| 36 | for $l in dataset('LineItem') |
| 37 | where $l.l_shipdate <= '1998-09-02' |
| 38 | /*+ hash*/ |
| 39 | group by $l_returnflag := $l.l_returnflag, |
| 40 | $l_linestatus := $l.l_linestatus |
| 41 | with $l |
| 42 | let $expensives := for $i in $l where ($i.l_discount<=0.05) return $i.l_discount |
| 43 | let $cheaps := for $i in $l where ($i.l_discount>0.05) return $i |
| 44 | let $charges := for $i in $l return $i.l_extendedprice * (1 - $i.l_discount) * (1 + $i.l_tax) |
| 45 | let $disc_prices := for $i in $l return $i.l_extendedprice * (1 - $i.l_discount) |
| 46 | order by $l_returnflag, $l_linestatus |
| 47 | return { |
| 48 | "l_returnflag": $l_returnflag, |
| 49 | "l_linestatus": $l_linestatus, |
| 50 | "count_cheaps": count($cheaps), |
| 51 | "avg_expensive_discounts": avg($expensives), |
| 52 | "sum_disc_prices": sum($disc_prices), |
| 53 | "total_charges": sum($charges) |
| 54 | } |