blob: 270383de0ae122c4e629438815abbb53735b72ae [file] [log] [blame]
buyingyi179e62f2014-12-03 18:40:53 -08001/*
2 * Description : This test case is to verify the fix for issue827
3 * https://code.google.com/p/asterixdb/issues/detail?id=827
4 * Expected Res : SUCCESS
5 * Date : 3rd Dec. 2014
6 */
7
8drop dataverse tpch if exists;
9create dataverse tpch;
10
11use dataverse tpch;
12
13create 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
32create dataset LineItem(LineItemType)
33 primary key l_orderkey, l_linenumber;
34
35let $qty := for $i in dataset('LineItem') where $i.l_shipdate <= '1998-09-02' return $i.l_quantity
36let $base_price := for $i in dataset('LineItem') return $i.l_extendedprice
37let $disc_price := for $i in dataset('LineItem') return $i.l_extendedprice * (1 - $i.l_discount)
38let $charge := for $i in dataset('LineItem') return $i.l_extendedprice * (1 - $i.l_discount) * (1 + $i.l_tax)
39let $price := for $i in dataset('LineItem') return $i.l_extendedprice
40let $disc := for $i in dataset('LineItem') return $i.l_discount
41let $order := for $l in dataset('LineItem') return $l
42return {
43 "sum_qty_partial": sum($qty),
44 "sum_base_price": sum($base_price),
45 "sum_disc_price": sum($disc_price),
46 "sum_charge": sum($charge),
47 "ave_qty": avg($qty),
48 "ave_price": avg($price),
49 "ave_disc": avg($disc),
50 "count_order": count($order)
51}
52