blob: f101e4778fbe31f95092607be35523a3f7b0a219 [file] [log] [blame]
khfaraaz82@gmail.comc26a6982012-06-01 02:35:40 +00001/*
2 * Test case Name : open-closed-32.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 * Success : Yes
6 * Date : 31st May 2012
7 */
8
9drop dataverse testdv2 if exists;
10create dataverse testdv2;
11use dataverse testdv2;
12
13create type testtype01 as open {
14id: string
15}
16
17create type testtype02 as closed {
18id : string,
19name : string,
20sex : string,
21dept : string,
22salary : int32,
23interests : {{string}}
24}
25
26create dataset testds01(testtype01) partitioned by key id;
27
28create dataset testds02(testtype02) partitioned by key id;
29
30insert into dataset testds02 (
31{ "id": "011", "name": "John Doe", "sex":"Male", "dept":"HR", "salary":80000,"interests":{{"hiking","scuba","painting","biking"}}});
32
33insert into dataset testds02 (
34{ "id": "921", "name": "John Smith", "sex":"Male", "dept":"Sales", "salary":65000,"interests":{{"gardening","biking","reading","hiking","fishing"}}});
35
36insert into dataset testds02 (
37{ "id": "959", "name": "Susan Malaika", "sex":"Female", "dept":"XML Dev", "salary":200000,"interests":{{"XML","Web Services","Cloud","X-Forms","art","travelling"}}});
38
39insert into dataset testds02 (
40{ "id": "371", "name": "Tom Sawyer", "sex":"Male", "dept":"Well Being", "salary":90000,"interests":{{"tennis","scuba","running","biking"}}});
41
42// insert into open type target dataset by doing a select on the closed type (source) internal dataset
43
44insert into dataset testds01(
45for $d in dataset("testds02")
46return $d
47);
48
buyingyibc282ae2012-06-05 21:41:14 +000049write output to nc1:"rttest/open-closed_open-closed-32.adm";
khfaraaz82@gmail.comc26a6982012-06-01 02:35:40 +000050for $d in dataset('testds01')
51where some $h in $d.interests satisfies $h='biking'
buyingyibc282ae2012-06-05 21:41:14 +000052order by $d.id
khfaraaz82@gmail.comc26a6982012-06-01 02:35:40 +000053return $d.interests
54