blob: f7c8ddf41c30b3b1fc39f808b7a8131fecc4eb57 [file] [log] [blame]
Yingyi Bu391f09e2015-10-29 13:49:39 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19/*
20 * Description : This test case is to verify the fix for issue827
21 * https://code.google.com/p/asterixdb/issues/detail?id=827
22 * Expected Res : SUCCESS
23 * Date : 3rd Dec. 2014
24 */
25
26drop database tpch if exists;
27create database tpch;
28
29use tpch;
30
31
32create type tpch.LineItemType as
33 closed {
34 l_orderkey : int32,
35 l_partkey : int32,
36 l_suppkey : int32,
37 l_linenumber : int32,
38 l_quantity : double,
39 l_extendedprice : double,
40 l_discount : double,
41 l_tax : double,
42 l_returnflag : string,
43 l_linestatus : string,
44 l_shipdate : string,
45 l_commitdate : string,
46 l_receiptdate : string,
47 l_shipinstruct : string,
48 l_shipmode : string,
49 l_comment : string
50}
51
52create table LineItem(LineItemType) primary key l_orderkey,l_linenumber;
53
Yingyi Bu3dd80ec2016-04-01 10:31:53 -070054{'sum_qty_partial':tpch.coll_sum((
Yingyi Bu391f09e2015-10-29 13:49:39 -070055 select element i.l_quantity
56 from LineItem as i
57 where (i.l_shipdate <= '1998-09-02')
Yingyi Bu3dd80ec2016-04-01 10:31:53 -070058)),'sum_base_price':tpch.coll_sum((
Yingyi Bu391f09e2015-10-29 13:49:39 -070059 select element i.l_extendedprice
60 from LineItem as i
Yingyi Bu3dd80ec2016-04-01 10:31:53 -070061)),'sum_disc_price':tpch.coll_sum((
Yingyi Bu391f09e2015-10-29 13:49:39 -070062 select element (i.l_extendedprice * (1 - i.l_discount))
63 from LineItem as i
Yingyi Bu3dd80ec2016-04-01 10:31:53 -070064)),'sum_charge':tpch.coll_sum((
Yingyi Bu391f09e2015-10-29 13:49:39 -070065 select element (i.l_extendedprice * (1 - i.l_discount) * (1 + i.l_tax))
66 from LineItem as i
Yingyi Bu3dd80ec2016-04-01 10:31:53 -070067)),'ave_qty':tpch.coll_avg((
Yingyi Bu391f09e2015-10-29 13:49:39 -070068 select element i.l_quantity
69 from LineItem as i
70 where (i.l_shipdate <= '1998-09-02')
Yingyi Bu3dd80ec2016-04-01 10:31:53 -070071)),'ave_price':tpch.coll_avg((
Yingyi Bu391f09e2015-10-29 13:49:39 -070072 select element i.l_extendedprice
73 from LineItem as i
Yingyi Bu3dd80ec2016-04-01 10:31:53 -070074)),'ave_disc':tpch.coll_avg((
Yingyi Bu391f09e2015-10-29 13:49:39 -070075 select element i.l_discount
76 from LineItem as i
Yingyi Bu3dd80ec2016-04-01 10:31:53 -070077)),'count_order':tpch.coll_count((
Yingyi Bu391f09e2015-10-29 13:49:39 -070078 select element l
79 from LineItem as l
80))};