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