buyingyi | 179e62f | 2014-12-03 18:40:53 -0800 | [diff] [blame] | 1 | /* |
Ian Maxon | 857dc13 | 2015-09-25 17:13:19 -0700 | [diff] [blame] | 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 | */ |
| 19 | /* |
buyingyi | 179e62f | 2014-12-03 18:40:53 -0800 | [diff] [blame] | 20 | * Description : This test case is to verify the fix for issue827 |
| 21 | * https://code.google.com/p/asterixdb/issues/detail?id=827 |
| 22 | * Expected Res : SUCCESS |
| 23 | * Date : 3rd Dec. 2014 |
| 24 | */ |
| 25 | |
| 26 | drop dataverse tpch if exists; |
| 27 | create dataverse tpch; |
| 28 | |
| 29 | use dataverse tpch; |
| 30 | |
| 31 | create type LineItemType as closed { |
| 32 | l_orderkey: int32, |
| 33 | l_partkey: int32, |
| 34 | l_suppkey: int32, |
| 35 | l_linenumber: int32, |
| 36 | l_quantity: double, |
| 37 | l_extendedprice: double, |
| 38 | l_discount: double, |
| 39 | l_tax: double, |
| 40 | l_returnflag: string, |
| 41 | l_linestatus: string, |
| 42 | l_shipdate: string, |
| 43 | l_commitdate: string, |
| 44 | l_receiptdate: string, |
| 45 | l_shipinstruct: string, |
| 46 | l_shipmode: string, |
| 47 | l_comment: string |
| 48 | } |
| 49 | |
| 50 | create dataset LineItem(LineItemType) |
| 51 | primary key l_orderkey, l_linenumber; |
| 52 | |
| 53 | let $qty := for $i in dataset('LineItem') where $i.l_shipdate <= '1998-09-02' return $i.l_quantity |
| 54 | let $base_price := for $i in dataset('LineItem') return $i.l_extendedprice |
| 55 | let $disc_price := for $i in dataset('LineItem') return $i.l_extendedprice * (1 - $i.l_discount) |
| 56 | let $charge := for $i in dataset('LineItem') return $i.l_extendedprice * (1 - $i.l_discount) * (1 + $i.l_tax) |
| 57 | let $price := for $i in dataset('LineItem') return $i.l_extendedprice |
| 58 | let $disc := for $i in dataset('LineItem') return $i.l_discount |
| 59 | let $order := for $l in dataset('LineItem') return $l |
| 60 | return { |
| 61 | "sum_qty_partial": sum($qty), |
| 62 | "sum_base_price": sum($base_price), |
| 63 | "sum_disc_price": sum($disc_price), |
| 64 | "sum_charge": sum($charge), |
| 65 | "ave_qty": avg($qty), |
| 66 | "ave_price": avg($price), |
| 67 | "ave_disc": avg($disc), |
| 68 | "count_order": count($order) |
| 69 | } |
| 70 | |