blob: e951abcb8c5887b2081ab0233c129a61e68c6684 [file] [log] [blame]
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 Customers1(CustomerType)
partitioned by key cid on group1;
create dataset Orders1(OrderType)
partitioned by key oid on group1;
create dataset CustomerOrders1(CustomerOrdersType)
partitioned by key cid on group1;
load dataset Customers1
using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
(("path"="nc1://data/custord-tiny/customer-tiny.adm"),("format"="adm")) pre-sorted;
load dataset Orders1
using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
(("path"="nc1://data/custord-tiny/order-tiny.adm"),("format"="adm")) pre-sorted;
// write output to nc1:"rttest/denorm-cust-order_01.adm";
write into dataset CustomerOrders1 (
for $c in dataset('Customers1')
for $o in dataset('Orders1')
where $c.cid = $o.cid and $c.age < 21 and $c.total > 50.0
group by $cid := $c.cid decor $cust := $c with $o
return {"cid":$cid, "cust": $cust, "orders": $o}
);