vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse join-super-key_01 if exists; |
| 2 | |
| 3 | create dataverse join-super-key_01; |
| 4 | |
| 5 | use dataverse join-super-key_01; |
| 6 | |
| 7 | create type SupplierType as closed { |
| 8 | s_suppkey: int32, |
| 9 | s_name: string, |
| 10 | s_address: string, |
| 11 | s_nationkey: int32, |
| 12 | s_phone: string, |
| 13 | s_acctbal: double, |
| 14 | s_comment: string |
| 15 | } |
| 16 | |
| 17 | create type NationType as closed { |
| 18 | n_nationkey: int32, |
| 19 | n_name: string, |
| 20 | n_regionkey: int32, |
| 21 | n_comment: string |
| 22 | } |
| 23 | |
| 24 | create type LineItemType as closed { |
| 25 | l_orderkey: int32, |
| 26 | l_partkey: int32, |
| 27 | l_suppkey: int32, |
| 28 | l_linenumber: int32, |
| 29 | l_quantity: double, |
| 30 | l_extendedprice: double, |
| 31 | l_discount: double, |
| 32 | l_tax: double, |
| 33 | l_returnflag: string, |
| 34 | l_linestatus: string, |
| 35 | l_shipdate: string, |
| 36 | l_commitdate: string, |
| 37 | l_receiptdate: string, |
| 38 | l_shipinstruct: string, |
| 39 | l_shipmode: string, |
| 40 | l_comment: string |
| 41 | } |
| 42 | |
| 43 | create type PartType as closed { |
| 44 | p_partkey: int32, |
| 45 | p_name: string, |
| 46 | p_mfgr: string, |
| 47 | p_brand: string, |
| 48 | p_type: string, |
| 49 | p_size: int32, |
| 50 | p_container: string, |
| 51 | p_retailprice: double, |
| 52 | p_comment: string |
| 53 | } |
| 54 | |
| 55 | create type PartSuppType as closed { |
| 56 | ps_partkey: int32, |
| 57 | ps_suppkey: int32, |
| 58 | ps_availqty: int32, |
| 59 | ps_supplycost: double, |
| 60 | ps_comment: string |
| 61 | } |
| 62 | |
| 63 | |
| 64 | create nodegroup group1 if not exists on nc1, nc2; |
| 65 | |
| 66 | write output to nc1:"/tmp/join-super-key_01.adm"; |
| 67 | |
| 68 | create dataset LineItems(LineItemType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame^] | 69 | primary key l_partkey, l_linenumber on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 70 | create dataset PartSupp(PartSuppType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame^] | 71 | primary key ps_partkey, ps_suppkey on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 72 | |
| 73 | |
| 74 | for $ps in dataset('PartSupp') |
| 75 | for $li in dataset('LineItems') |
| 76 | where $li.l_partkey = $ps.ps_partkey and $li.l_suppkey = $ps.ps_suppkey and |
| 77 | $li.l_extendedprice = $ps.ps_supplycost |
| 78 | return { |
| 79 | "l_partkey": $li.l_partkey |
| 80 | } |