blob: 2ac6910cc4c4d75153ff59579165da3f70f27b42 [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 dataset Customers2(CustomerType)
partitioned by key cid;
create dataset Orders2(OrderType)
partitioned by key oid;
create dataset CustomerOrders2(CustomerOrdersType)
partitioned by key cid;
load dataset Customers2
using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
(("path"="nc1://data/custord-tiny/customer-tiny.adm"),("format"="adm")) pre-sorted;
load dataset Orders2
using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
(("path"="nc1://data/custord-tiny/order-tiny.adm"),("format"="adm")) pre-sorted;
write into dataset CustomerOrders2 (
for $c in dataset('Customers2')
let $orders :=
for $o in dataset('Orders2')
where $o.cid = $c.cid
order by $o.oid asc
return $o
return { "cid": $c.cid, "cust": $c, "orders": $orders }
);
write output to nc1:"rttest/custord_denorm-cust-order_02.adm";
for $co in dataset('CustomerOrders2')
order by $co.cid
return $co