khfaraaz82@gmail.com | 1a300b2 | 2012-04-30 19:18:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Test case name : open-closed-22.aql |
khfaraaz82@gmail.com | 923f12b | 2012-05-02 20:11:28 +0000 | [diff] [blame] | 3 | * Description : Insert into a closed type dataset which has nullable(optional) and non-nullable fields |
khfaraaz82@gmail.com | 1a300b2 | 2012-04-30 19:18:14 +0000 | [diff] [blame] | 4 | * Success : Yes |
| 5 | * Date : 30 April 2012 |
| 6 | */ |
| 7 | |
| 8 | drop dataverse test if exists; |
| 9 | create dataverse test; |
| 10 | use dataverse test; |
| 11 | |
| 12 | write output to nc1:"rttest/open-closed-22.adm"; |
| 13 | |
| 14 | create type Emp as closed { |
| 15 | id:int32, |
| 16 | name:string, |
| 17 | age:int8?, |
| 18 | dept:string?, |
| 19 | sex:string, |
| 20 | dob:date? |
| 21 | } |
| 22 | |
| 23 | create dataset employee(Emp) partitioned by key id; |
| 24 | |
| 25 | //date("YYYY-MM-DD") |
| 26 | insert into dataset employee({"id":201,"name":"John Doe","age":37,"dept":"HR","sex":"M","dob":date("1975-11-02")}); |
| 27 | |
| 28 | insert into dataset employee({"id":202,"name":"John Smith","age":30,"dept":"Sales","sex":"M","dob":date("1982-12-12")}); |
| 29 | |
| 30 | // all optional fields missing |
| 31 | insert into dataset employee({"id":201,"name":"John Wayne","age":62,"sex":"M"}); |
| 32 | |
| 33 | // missing age field |
| 34 | insert into dataset employee({"id":203,"name":"Roger Sanders","dept":"Technology","sex":"M","dob":date("1970-03-12")}); |
| 35 | |
| 36 | // all optional fields missing! |
| 37 | insert into dataset employee({"id":204,"name":"Raj Singh","sex":"M"}); |
| 38 | |
| 39 | // missing dept field |
| 40 | insert into dataset employee({"id":205,"name":"Mike Tyson","age":44,"sex":"M","dob":date("1970-12-22")}); |
| 41 | |
| 42 | for $l in dataset('employee') |
| 43 | return $l |