blob: 831976fddb05eb523069fb78ac4aae77c233f771 [file] [log] [blame]
Ian Maxon857dc132015-09-25 17:13:19 -07001/*
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 */
vinayakb38b7ca42012-03-05 05:44:15 +000019drop dataverse join-super-key_01 if exists;
20
21create dataverse join-super-key_01;
22
23use dataverse join-super-key_01;
24
25create 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
35create type NationType as closed {
36 n_nationkey: int32,
37 n_name: string,
38 n_regionkey: int32,
39 n_comment: string
40}
41
42create 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
61create 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
73create 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 Maxonf7b64532015-12-09 17:28:18 -080082create nodegroup group1 if not exists on asterix_nc1, asterix_nc2;
vinayakb38b7ca42012-03-05 05:44:15 +000083
Ian Maxonf7b64532015-12-09 17:28:18 -080084write output to asterix_nc1:"/tmp/join-super-key_01.adm";
vinayakb38b7ca42012-03-05 05:44:15 +000085
86create dataset LineItems(LineItemType)
ramangrover29669d8f62013-02-11 06:03:32 +000087 primary key l_partkey, l_linenumber on group1;
vinayakb38b7ca42012-03-05 05:44:15 +000088create dataset PartSupp(PartSuppType)
ramangrover29669d8f62013-02-11 06:03:32 +000089 primary key ps_partkey, ps_suppkey on group1;
vinayakb38b7ca42012-03-05 05:44:15 +000090
91
92for $ps in dataset('PartSupp')
93for $li in dataset('LineItems')
94where $li.l_partkey = $ps.ps_partkey and $li.l_suppkey = $ps.ps_suppkey and
95 $li.l_extendedprice = $ps.ps_supplycost
96return {
97 "l_partkey": $li.l_partkey
98}