Yingyi Bu | 6084e3b | 2016-02-09 11:45:53 -0800 | [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 | */ |
| 19 | |
| 20 | /** |
| 21 | * This query is to verify the fix for ASTERIXDB-1291. |
| 22 | */ |
| 23 | |
| 24 | drop dataverse tpch if exists; |
| 25 | create dataverse tpch; |
| 26 | use dataverse tpch; |
| 27 | |
| 28 | create type LineItemType as closed { |
| 29 | l_orderkey: int32, |
| 30 | l_partkey: int32, |
| 31 | l_suppkey: int32, |
| 32 | l_linenumber: int32, |
| 33 | l_quantity: double, |
| 34 | l_extendedprice: double, |
| 35 | l_discount: double, |
| 36 | l_tax: double, |
| 37 | l_returnflag: string, |
| 38 | l_linestatus: string, |
| 39 | l_shipdate: string, |
| 40 | l_commitdate: string, |
| 41 | l_receiptdate: string, |
| 42 | l_shipinstruct: string, |
| 43 | l_shipmode: string, |
| 44 | l_comment: string |
| 45 | } |
| 46 | |
| 47 | create type OrderType as closed { |
| 48 | o_orderkey: int32, |
| 49 | o_custkey: int32, |
| 50 | o_orderstatus: string, |
| 51 | o_totalprice: double, |
| 52 | o_orderdate: string, |
| 53 | o_orderpriority: string, |
| 54 | o_clerk: string, |
| 55 | o_shippriority: int32, |
| 56 | o_comment: string |
| 57 | } |
| 58 | |
| 59 | create type CustomerType as closed { |
| 60 | c_custkey: int32, |
| 61 | c_name: string, |
| 62 | c_address: string, |
| 63 | c_nationkey: int32, |
| 64 | c_phone: string, |
| 65 | c_acctbal: double, |
| 66 | c_mktsegment: string, |
| 67 | c_comment: string |
| 68 | } |
| 69 | |
| 70 | create dataset Orders(OrderType) |
| 71 | primary key o_orderkey; |
| 72 | create dataset Customers(CustomerType) |
| 73 | primary key c_custkey; |
| 74 | |
| 75 | for $c in dataset('Customers') |
| 76 | group by $ccustkey := $c.c_custkey, $cnationkey := $c.c_nationkey with $c |
| 77 | let $orders := |
| 78 | for $o in dataset('Orders') |
| 79 | where $cnationkey = 5 and $o.o_$o.o_custkey = $ccustkey |
| 80 | return $o |
| 81 | return { |
| 82 | "cust": $c, |
| 83 | "orders": $orders |
| 84 | } |