vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse tpch if exists; |
| 2 | create dataverse tpch; |
| 3 | use dataverse tpch; |
| 4 | |
| 5 | create 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 | |
| 24 | create 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 | |
| 36 | create 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 | create nodegroup group1 if not exists on nc1, nc2; |
| 48 | |
| 49 | create dataset LineItems(LineItemType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 50 | primary key l_orderkey, l_linenumber on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 51 | create dataset Orders(OrderType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 52 | primary key o_orderkey on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 53 | create dataset Customers(CustomerType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 54 | primary key c_custkey on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 55 | |
| 56 | write output to nc1:"/tmp/nested_loj.adm"; |
| 57 | |
| 58 | for $c in dataset('Customers') |
| 59 | let $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 | } |
| 70 | return { |
| 71 | "cust": $c, |
| 72 | "orders": $orders |
| 73 | } |