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