blob: 3a1ef047e97e1fb6987f0c63630d1f8c6a46326a [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)
60 partitioned by key l_orderkey, l_linenumber on group1;
61create dataset Orders(OrderType)
62 partitioned by key o_orderkey on group1;
63create dataset Customers(CustomerType)
64 partitioned by key c_custkey on group1;
65create dataset PartSupp(PartSuppType)
66 partitioned by key ps_partkey, ps_suppkey on group1;
67
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}