blob: 809c93ea3859772a6e7cb0fac41d9991b9e4fbf0 [file] [log] [blame]
khfaraaz82@gmail.comc26a6982012-06-01 02:35:40 +00001/*
2 * Test case Name : open-closed-33.aql
3 * Description : INSERT into target (closed type) internal dataset by doing SELECT on (closed type) source internal dataset
4 * : then query the target internal dataset for data enclosed within {{ }} braces, in this case interests field.
5 * : Here the interests field is optional.
6 * Success : Yes
7 * Date : 31st May 2012
8 */
9
10drop dataverse testdv2 if exists;
11create dataverse testdv2;
12use dataverse testdv2;
13
14create type testtype01 as open {
15id: string
16}
17
18create type testtype02 as closed {
19id : string,
20name : string,
21sex : string,
22dept : string,
23salary : int32,
24interests : {{string}}?
25}
26
ramangrover29669d8f62013-02-11 06:03:32 +000027create dataset testds01(testtype01) primary key id;
khfaraaz82@gmail.comc26a6982012-06-01 02:35:40 +000028
ramangrover29669d8f62013-02-11 06:03:32 +000029create dataset testds02(testtype02) primary key id;
khfaraaz82@gmail.comc26a6982012-06-01 02:35:40 +000030
31insert into dataset testds02 (
32{ "id": "011", "name": "John Doe", "sex":"Male", "dept":"HR", "salary":80000,"interests":{{"hiking","scuba","painting","biking"}}});
33
34insert into dataset testds02 (
35{ "id": "921", "name": "John Smith", "sex":"Male", "dept":"Sales", "salary":65000,"interests":{{"gardening","biking","reading","hiking","fishing"}}});
36
37insert into dataset testds02 (
38{ "id": "959", "name": "Susan Malaika", "sex":"Female", "dept":"XML Dev", "salary":200000,"interests":{{"XML","Web Services","Cloud","X-Forms","art","travelling"}}});
39
40insert into dataset testds02 (
41{ "id": "371", "name": "Tom Sawyer", "sex":"Male", "dept":"Well Being", "salary":90000,"interests":{{"tennis","scuba","running","biking"}}});
42
43// insert into open type target dataset by doing a select on the closed type (source) internal dataset
44
45insert into dataset testds01(
46for $d in dataset("testds02")
47return $d
48);
49
buyingyibc282ae2012-06-05 21:41:14 +000050write output to nc1:"rttest/open-closed_open-closed-33.adm";
khfaraaz82@gmail.comc26a6982012-06-01 02:35:40 +000051for $d in dataset('testds01')
52where some $h in $d.interests satisfies $h='biking'
buyingyibc282ae2012-06-05 21:41:14 +000053order by $d.id
khfaraaz82@gmail.comc26a6982012-06-01 02:35:40 +000054return $d.interests
55