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 tpch if exists; |
| 20 | create dataverse tpch; |
| 21 | use dataverse tpch; |
| 22 | |
| 23 | create type LineItemType as closed { |
| 24 | l_orderkey: int32, |
| 25 | l_partkey: int32, |
| 26 | l_suppkey: int32, |
| 27 | l_linenumber: int32, |
| 28 | l_quantity: double, |
| 29 | l_extendedprice: double, |
| 30 | l_discount: double, |
| 31 | l_tax: double, |
| 32 | l_returnflag: string, |
| 33 | l_linestatus: string, |
| 34 | l_shipdate: string, |
| 35 | l_commitdate: string, |
| 36 | l_receiptdate: string, |
| 37 | l_shipinstruct: string, |
| 38 | l_shipmode: string, |
| 39 | l_comment: string |
| 40 | } |
| 41 | |
Ian Maxon | f7b6453 | 2015-12-09 17:28:18 -0800 | [diff] [blame] | 42 | create nodegroup group1 if not exists on asterix_nc1, asterix_nc2; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 43 | |
| 44 | create dataset LineItems_q1(LineItemType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 45 | primary key l_orderkey, l_linenumber on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 46 | |
Ian Maxon | f7b6453 | 2015-12-09 17:28:18 -0800 | [diff] [blame] | 47 | write output to asterix_nc1:"rttest/tpch_q1_pricing_summary_report_nt.adm"; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 48 | |
| 49 | for $g in |
| 50 | ( |
| 51 | for $l in dataset('LineItems_q1') |
| 52 | where $l.l_shipdate <= '1998-09-02' |
| 53 | group by $l_returnflag := $l.l_returnflag, $l_linestatus := $l.l_linestatus, |
| 54 | $l_suppkey := $l.l_suppkey with $l |
| 55 | return { |
| 56 | "l_returnflag": $l_returnflag, |
| 57 | "l_linestatus": $l_linestatus, |
| 58 | "l_suppkey": $l_suppkey |
| 59 | } |
| 60 | ) |
| 61 | group by $l_returnflag := $g.l_returnflag, $l_linestatus := $g.l_linestatus |
| 62 | with $g |
| 63 | order by $l_returnflag, $l_linestatus |
| 64 | return { |
| 65 | "l_returnflag": $l_returnflag, |
| 66 | "l_linestatus": $l_linestatus, |
| 67 | "count_suppkey": count($g) |
| 68 | } |