blob: 809c93ea3859772a6e7cb0fac41d9991b9e4fbf0 [file] [log] [blame]
/*
* Test case Name : open-closed-33.aql
* Description : INSERT into target (closed type) internal dataset by doing SELECT on (closed type) source internal dataset
* : then query the target internal dataset for data enclosed within {{ }} braces, in this case interests field.
* : Here the interests field is optional.
* Success : Yes
* Date : 31st May 2012
*/
drop dataverse testdv2 if exists;
create dataverse testdv2;
use dataverse testdv2;
create type testtype01 as open {
id: string
}
create type testtype02 as closed {
id : string,
name : string,
sex : string,
dept : string,
salary : int32,
interests : {{string}}?
}
create dataset testds01(testtype01) primary key id;
create dataset testds02(testtype02) primary key id;
insert into dataset testds02 (
{ "id": "011", "name": "John Doe", "sex":"Male", "dept":"HR", "salary":80000,"interests":{{"hiking","scuba","painting","biking"}}});
insert into dataset testds02 (
{ "id": "921", "name": "John Smith", "sex":"Male", "dept":"Sales", "salary":65000,"interests":{{"gardening","biking","reading","hiking","fishing"}}});
insert into dataset testds02 (
{ "id": "959", "name": "Susan Malaika", "sex":"Female", "dept":"XML Dev", "salary":200000,"interests":{{"XML","Web Services","Cloud","X-Forms","art","travelling"}}});
insert into dataset testds02 (
{ "id": "371", "name": "Tom Sawyer", "sex":"Male", "dept":"Well Being", "salary":90000,"interests":{{"tennis","scuba","running","biking"}}});
// insert into open type target dataset by doing a select on the closed type (source) internal dataset
insert into dataset testds01(
for $d in dataset("testds02")
return $d
);
write output to nc1:"rttest/open-closed_open-closed-33.adm";
for $d in dataset('testds01')
where some $h in $d.interests satisfies $h='biking'
order by $d.id
return $d.interests