khfaraaz82@gmail.com | c26a698 | 2012-06-01 02:35:40 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 10 | drop dataverse testdv2 if exists; |
| 11 | create dataverse testdv2; |
| 12 | use dataverse testdv2; |
| 13 | |
| 14 | create type testtype01 as open { |
| 15 | id: string |
| 16 | } |
| 17 | |
| 18 | create type testtype02 as closed { |
| 19 | id : string, |
| 20 | name : string, |
| 21 | sex : string, |
| 22 | dept : string, |
| 23 | salary : int32, |
| 24 | interests : {{string}}? |
| 25 | } |
| 26 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame^] | 27 | create dataset testds01(testtype01) primary key id; |
khfaraaz82@gmail.com | c26a698 | 2012-06-01 02:35:40 +0000 | [diff] [blame] | 28 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame^] | 29 | create dataset testds02(testtype02) primary key id; |
khfaraaz82@gmail.com | c26a698 | 2012-06-01 02:35:40 +0000 | [diff] [blame] | 30 | |
| 31 | insert into dataset testds02 ( |
| 32 | { "id": "011", "name": "John Doe", "sex":"Male", "dept":"HR", "salary":80000,"interests":{{"hiking","scuba","painting","biking"}}}); |
| 33 | |
| 34 | insert into dataset testds02 ( |
| 35 | { "id": "921", "name": "John Smith", "sex":"Male", "dept":"Sales", "salary":65000,"interests":{{"gardening","biking","reading","hiking","fishing"}}}); |
| 36 | |
| 37 | insert 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 | |
| 40 | insert 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 | |
| 45 | insert into dataset testds01( |
| 46 | for $d in dataset("testds02") |
| 47 | return $d |
| 48 | ); |
| 49 | |
buyingyi | bc282ae | 2012-06-05 21:41:14 +0000 | [diff] [blame] | 50 | write output to nc1:"rttest/open-closed_open-closed-33.adm"; |
khfaraaz82@gmail.com | c26a698 | 2012-06-01 02:35:40 +0000 | [diff] [blame] | 51 | for $d in dataset('testds01') |
| 52 | where some $h in $d.interests satisfies $h='biking' |
buyingyi | bc282ae | 2012-06-05 21:41:14 +0000 | [diff] [blame] | 53 | order by $d.id |
khfaraaz82@gmail.com | c26a698 | 2012-06-01 02:35:40 +0000 | [diff] [blame] | 54 | return $d.interests |
| 55 | |