Ian Maxon | 857dc13 | 2015-09-25 17:13:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 19 | drop dataverse join-super-key_01 if exists; |
| 20 | |
| 21 | create dataverse join-super-key_01; |
| 22 | |
| 23 | use dataverse join-super-key_01; |
| 24 | |
| 25 | create type SupplierType as closed { |
| 26 | s_suppkey: int32, |
| 27 | s_name: string, |
| 28 | s_address: string, |
| 29 | s_nationkey: int32, |
| 30 | s_phone: string, |
| 31 | s_acctbal: double, |
| 32 | s_comment: string |
| 33 | } |
| 34 | |
| 35 | create type NationType as closed { |
| 36 | n_nationkey: int32, |
| 37 | n_name: string, |
| 38 | n_regionkey: int32, |
| 39 | n_comment: string |
| 40 | } |
| 41 | |
| 42 | create type LineItemType as closed { |
| 43 | l_orderkey: int32, |
| 44 | l_partkey: int32, |
| 45 | l_suppkey: int32, |
| 46 | l_linenumber: int32, |
| 47 | l_quantity: double, |
| 48 | l_extendedprice: double, |
| 49 | l_discount: double, |
| 50 | l_tax: double, |
| 51 | l_returnflag: string, |
| 52 | l_linestatus: string, |
| 53 | l_shipdate: string, |
| 54 | l_commitdate: string, |
| 55 | l_receiptdate: string, |
| 56 | l_shipinstruct: string, |
| 57 | l_shipmode: string, |
| 58 | l_comment: string |
| 59 | } |
| 60 | |
| 61 | create type PartType as closed { |
| 62 | p_partkey: int32, |
| 63 | p_name: string, |
| 64 | p_mfgr: string, |
| 65 | p_brand: string, |
| 66 | p_type: string, |
| 67 | p_size: int32, |
| 68 | p_container: string, |
| 69 | p_retailprice: double, |
| 70 | p_comment: string |
| 71 | } |
| 72 | |
| 73 | create type PartSuppType as closed { |
| 74 | ps_partkey: int32, |
| 75 | ps_suppkey: int32, |
| 76 | ps_availqty: int32, |
| 77 | ps_supplycost: double, |
| 78 | ps_comment: string |
| 79 | } |
| 80 | |
| 81 | |
Ian Maxon | f7b6453 | 2015-12-09 17:28:18 -0800 | [diff] [blame^] | 82 | create nodegroup group1 if not exists on asterix_nc1, asterix_nc2; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 83 | |
Ian Maxon | f7b6453 | 2015-12-09 17:28:18 -0800 | [diff] [blame^] | 84 | write output to asterix_nc1:"/tmp/join-super-key_01.adm"; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 85 | |
| 86 | create dataset LineItems(LineItemType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 87 | primary key l_partkey, l_linenumber on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 88 | create dataset PartSupp(PartSuppType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 89 | primary key ps_partkey, ps_suppkey on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 90 | |
| 91 | |
| 92 | for $ps in dataset('PartSupp') |
| 93 | for $li in dataset('LineItems') |
| 94 | where $li.l_partkey = $ps.ps_partkey and $li.l_suppkey = $ps.ps_suppkey and |
| 95 | $li.l_extendedprice = $ps.ps_supplycost |
| 96 | return { |
| 97 | "l_partkey": $li.l_partkey |
| 98 | } |