blob: 1616a678d363bfabb1cbf94b6e31e8d5e9551caa [file] [log] [blame]
vinayakb38b7ca42012-03-05 05:44:15 +00001drop dataverse tpch if exists;
2create dataverse tpch;
3use dataverse tpch;
4
5create type LineItemType as closed {
6 l_orderkey: int32,
7 l_partkey: int32,
8 l_suppkey: int32,
9 l_linenumber: int32,
10 l_quantity: double,
11 l_extendedprice: double,
12 l_discount: double,
13 l_tax: double,
14 l_returnflag: string,
15 l_linestatus: string,
16 l_shipdate: string,
17 l_commitdate: string,
18 l_receiptdate: string,
19 l_shipinstruct: string,
20 l_shipmode: string,
21 l_comment: string
22}
23
24create type OrderType as closed {
25 o_orderkey: int32,
26 o_custkey: int32,
27 o_orderstatus: string,
28 o_totalprice: double,
29 o_orderdate: string,
30 o_orderpriority: string,
31 o_clerk: string,
32 o_shippriority: int32,
33 o_comment: string
34}
35
36create type CustomerType as closed {
37 c_custkey: int32,
38 c_name: string,
39 c_address: string,
40 c_nationkey: int32,
41 c_phone: string,
42 c_acctbal: double,
43 c_mktsegment: string,
44 c_comment: string
45}
46
47
48create type PartSuppType as closed {
49 ps_partkey: int32,
50 ps_suppkey: int32,
51 ps_availqty: int32,
52 ps_supplycost: double,
53 ps_comment: string
54}
55
56
57create nodegroup group1 if not exists on nc1, nc2;
58
59create dataset LineItems(LineItemType)
ramangrover29669d8f62013-02-11 06:03:32 +000060 primary key l_orderkey, l_linenumber on group1;
vinayakb38b7ca42012-03-05 05:44:15 +000061create dataset Orders(OrderType)
ramangrover29669d8f62013-02-11 06:03:32 +000062 primary key o_orderkey on group1;
vinayakb38b7ca42012-03-05 05:44:15 +000063create dataset Customers(CustomerType)
ramangrover29669d8f62013-02-11 06:03:32 +000064 primary key c_custkey on group1;
vinayakb38b7ca42012-03-05 05:44:15 +000065create dataset PartSupp(PartSuppType)
ramangrover29669d8f62013-02-11 06:03:32 +000066 primary key ps_partkey, ps_suppkey on group1;
vinayakb38b7ca42012-03-05 05:44:15 +000067
68write output to nc1:"/tmp/nested_loj.adm";
69
70for $c in dataset('Customers')
71let $orders :=
72 for $o in dataset('Orders')
73 where $o.o_custkey = $c.c_custkey
74 let $items :=
75 for $l in dataset('LineItems')
76 where $l.l_orderkey = $o.o_orderkey
77 let $partsupp :=
78 for $ps in dataset('PartSupp')
79 where $ps.ps_partkey = $l.l_partkey and $ps.ps_suppkey = $l.l_suppkey
80 return $ps
81 return {
82 "item": $l,
83 "part_supplier": $partsupp
84 }
85 return {
86 "order": $o,
87 "items": $items
88 }
89return {
90 "cust": $c,
91 "orders": $orders
92}