blob: 0b77f5599217e9de1f9df35e8e1595010b51e599 [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
47create nodegroup group1 if not exists on nc1, nc2;
48
49create dataset LineItems(LineItemType)
50 partitioned by key l_orderkey, l_linenumber on group1;
51create dataset Orders(OrderType)
52 partitioned by key o_orderkey on group1;
53create dataset Customers(CustomerType)
54 partitioned by key c_custkey on group1;
55
56write output to nc1:"/tmp/nested_loj.adm";
57
58for $c in dataset('Customers')
59let $orders :=
60 for $o in dataset('Orders')
61 where $o.o_custkey = $c.c_custkey
62 let $items :=
63 for $l in dataset('LineItems')
64 where $l.l_orderkey = $o.o_orderkey
65 return $l
66 return {
67 "order": $o,
68 "items": $items
69 }
70return {
71 "cust": $c,
72 "orders": $orders
73}