blob: d2527685009c6394ca4f8483c23980bb28444780 [file] [log] [blame]
Yingyi Bud5f0fc52014-06-09 13:49:23 -07001/*
Ian Maxon857dc132015-09-25 17:13:19 -07002 * 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/*
Yingyi Bud5f0fc52014-06-09 13:49:23 -070020 * Description : This test case is to verify the fix for issue782
21 * https://code.google.com/p/asterixdb/issues/detail?id=782
22 * Expected Res : SUCCESS
23 * Date : 2nd Jun 2014
24 */
25
26drop dataverse tpch if exists;
27create dataverse tpch;
28
29use dataverse tpch;
30
31create type OrderType as closed {
32 o_orderkey: int32,
33 o_custkey: int32,
34 o_orderstatus: string,
35 o_totalprice: double,
36 o_orderdate: string,
37 o_orderpriority: string,
38 o_clerk: string,
39 o_shippriority: int32,
40 o_comment: string
41}
42
43create type CustomerType as closed {
44 c_custkey: int32,
45 c_name: string,
46 c_address: string,
47 c_nationkey: int32,
48 c_phone: string,
49 c_acctbal: double,
50 c_mktsegment: string,
51 c_comment: string
52}
53
54create type SupplierType as closed {
55 s_suppkey: int32,
56 s_name: string,
57 s_address: string,
58 s_nationkey: int32,
59 s_phone: string,
60 s_acctbal: double,
61 s_comment: string
62}
63
64create type NationType as closed {
65 n_nationkey: int32,
66 n_name: string,
67 n_regionkey: int32,
68 n_comment: string
69}
70
71create type RegionType as closed {
72 r_regionkey: int32,
73 r_name: string,
74 r_comment: string
75}
76
77create type PartType as closed {
78 p_partkey: int32,
79 p_name: string,
80 p_mfgr: string,
81 p_brand: string,
82 p_type: string,
83 p_size: int32,
84 p_container: string,
85 p_retailprice: double,
86 p_comment: string
87}
88
89create type PartSuppType as closed {
90 ps_partkey: int32,
91 ps_suppkey: int32,
92 ps_availqty: int32,
93 ps_supplycost: double,
94 ps_comment: string
95}
96
97create dataset Orders(OrderType)
98 primary key o_orderkey;
99create dataset Supplier(SupplierType)
100 primary key s_suppkey;
101create dataset Region(RegionType)
102 primary key r_regionkey;
103create dataset Nation(NationType)
104 primary key n_nationkey;
105create dataset Part(PartType)
106 primary key p_partkey;
107create dataset Partsupp(PartSuppType)
108 primary key ps_partkey, ps_suppkey;
109create dataset Customer(CustomerType)
110 primary key c_custkey;
111create dataset SelectedNation(NationType)
112 primary key n_nationkey;
113
114
115
116for $nation in dataset Nation
117for $sn in dataset SelectedNation
118where $nation.n_nationkey = $sn.n_nationkey /*+ indexnl */
119return {
120 "nation_key": $nation.n_nationkey,
121 "name": $nation.n_name,
122 "aggregates": for $order in dataset Orders
123 for $customer in dataset Customer
124 where $order.o_custkey = $customer.c_custkey
125 and $customer.c_nationkey = $nation.n_nationkey
126 group by $orderdate := $order.o_orderdate with $order
127 let $sum := sum(for $o in $order return $o.o_totalprice)
128 order by $sum
129 limit 3
130 return {
131 "order_date": $orderdate,
132 "sum_price": $sum
133 }
Ian Maxon857dc132015-09-25 17:13:19 -0700134}