| drop dataverse test if exists; |
| |
| create dataverse test; |
| |
| use dataverse test; |
| |
| |
| |
| create type AddressType as open { |
| number: int32, |
| street: string, |
| city: string |
| } |
| |
| create type CustomerType as open { |
| cid: int32, |
| name: string, |
| age: int32?, |
| address: AddressType?, |
| lastorder: { |
| oid: int32, |
| total: float |
| } |
| } |
| |
| create type OrderType as open { |
| oid: int32, |
| cid: int32, |
| orderstatus: string, |
| orderpriority: string, |
| clerk: string, |
| total: float |
| } |
| |
| create type CustomerOrdersType as open { |
| cid: int32, |
| cust: CustomerType, |
| orders: [OrderType] |
| } |
| |
| create nodegroup group1 if not exists on nc1, nc2; |
| |
| create dataset Customers3(CustomerType) |
| partitioned by key cid on group1; |
| create dataset Orders3(OrderType) |
| partitioned by key oid on group1; |
| create dataset CustomerOrders3(CustomerOrdersType) |
| partitioned by key cid on group1; |
| |
| load dataset Customers3 |
| using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| (("path"="nc1://data/custord-tiny/customer-tiny.adm"),("format"="adm")) pre-sorted; |
| |
| load dataset Orders3 |
| using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| (("path"="nc1://data/custord-tiny/order-tiny.adm"),("format"="adm")) pre-sorted; |
| |
| |
| write into dataset CustomerOrders3 ( |
| |
| for $c in dataset('Customers3') |
| let $orders := |
| for $o in dataset('Orders3') |
| where $o.cid = $c.cid |
| order by $o.orderpriority desc |
| return $o |
| return { "cid": $c.cid, "cust": $c, "orders": $orders } |
| |
| ); |
| |
| write output to nc1:"rttest/custord_denorm-cust-order_03.adm"; |
| |
| for $co1 in dataset('CustomerOrders3') |
| for $o1 in $co1.orders |
| return { |
| "order": $o1, |
| "ordcust": |
| for $co2 in dataset('CustomerOrders3') |
| where some $o2 in $co2.orders |
| satisfies $o2.oid = $o1.oid |
| return $co2.cust |
| } |