http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.1.ddl.aql
new file mode 100644
index 0000000..c08c61c
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.1.ddl.aql
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type DBLPType as closed {
+  id: int64, 
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPTypeOpen as open {
+  id: int64, 
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create dataset DBLPOpen(DBLPTypeOpen) primary key id;
+
+create index keyword_index on DBLPOpen(title:string?) type keyword enforced;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.2.update.aql
new file mode 100644
index 0000000..b174592
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.2.update.aql
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use dataverse test;
+
+load dataset DBLP using localfs
+(("path"="asterix_nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"))
 pre-sorted;
+
+insert into dataset test.DBLPOpen (
+    for $x in dataset test.DBLP
+        return $x
+);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.3.query.aql
new file mode 100644
index 0000000..b792fd6
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index-open/load-with-word-index-open.3.query.aql
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use dataverse test;
+
+for $o in dataset('DBLPOpen')
+let $jacc := similarity-jaccard-check(word-tokens($o.title), 
word-tokens("Transactions for Cooperative Environments"), 0.5f)
+where $jacc[0]
+return $o

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.1.ddl.aql
new file mode 100644
index 0000000..7ee89a3
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.1.ddl.aql
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type DBLPType as closed {
+  id: int64,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+create dataset DBLP1(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title) type keyword;
+create index keyword_index1 on DBLP1(title) type keyword;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.2.update.aql
new file mode 100644
index 0000000..483eab3
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.2.update.aql
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use dataverse test;
+
+load dataset DBLP using localfs
+(("path"="asterix_nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":"))
 pre-sorted;
+
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.3.query.aql
new file mode 100644
index 0000000..a25404f
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/load-with-word-index/load-with-word-index.3.query.aql
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use dataverse test;
+
+for $o in dataset('DBLP')
+let $jacc := similarity-jaccard-check(word-tokens($o.title), 
word-tokens("Transactions for Cooperative Environments"), 0.5f)
+where $jacc[0]
+return $o

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ddl.aql
new file mode 100644
index 0000000..ee91ec5
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.1.ddl.aql
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants
+ * Expected Result : Success
+ */
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+
+use dataverse testdv2;
+
+create type AddressType as open{
+  street: string,
+  city: string
+}
+create type Dept as open{
+    name: string,
+    id: int64
+}
+
+create type testtype as closed {
+  name: string,
+  id: string,
+  address: AddressType?,
+  department: {{Dept}}?
+}
+
+create type testtype2 as open {
+  name: string,
+  id: string
+}
+
+create dataset testds(testtype) primary key id;
+
+create dataset testds2(testtype2) primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.update.aql
new file mode 100644
index 0000000..25a4c74
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.2.update.aql
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+insert into dataset testds (
+{ "id": "001", "name": "Person One", "address": {"street": "3019 DBH",  
"city": "Irvine", "zip": 92697}, "department": {{ {"name":"CS", "id":299, 
"review":5}, {"name":"EE", "id":399} }} }
+);
+
+insert into dataset testds (
+{ "id": "002", "name": "Person Two" }
+);
+
+insert into dataset testds (
+{ "id": "003", "name": "Person Three", "address": {"street": "2019 DBH",  
"city": "Irvine"} }
+);
+
+insert into dataset testds (
+{ "id": "004", "name": "Person Four", "address": {"street": "1019 DBH",  
"city": "irvine", "property": {"zip": 92697, "review": "positive" }  } }
+);
+
+insert into dataset testds2 (
+ for $d in dataset("testds")
+    return $d
+);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.query.aql
new file mode 100644
index 0000000..94569dd
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o-recursive/opentype-c2o-recursive.3.query.aql
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+for $d in dataset("testds2") 
+order by $d.id
+return $d

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.1.ddl.aql
new file mode 100644
index 0000000..3736b23
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.1.ddl.aql
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-c2o.aql
+ * Description     : read data from a closed type dataset into a open type 
dataset and verify if
+ *                    records can be casted to the target open type
+ * Expected Result : Success
+ */
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+
+use dataverse testdv2;
+
+create type testtype as closed {
+  id: string,
+  name: string,
+  hobby: {{string}}?
+}
+
+/*
+* name and hobby from the closed dataset will
+* become open fields, and hobby can be null
+*/
+create type testtype2 as open {
+  id: string
+}
+
+create dataset testds(testtype) primary key id;
+
+create dataset testds2(testtype2) primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.2.update.aql
new file mode 100644
index 0000000..4f74e16
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.2.update.aql
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-c2o.aql
+ * Description     : read data from a closed type dataset into a open type 
dataset and verify if
+ *                    records can be casted to the target open type
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+insert into dataset testds (
+{ "hobby": {{"music", "coding"}}, "id": "001", "name": "Person Three"}
+);
+
+insert into dataset testds (
+{ "name": "Person One", "id": "002", "hobby": {{"sports"}} }
+);
+
+insert into dataset testds (
+{ "id": "003", "hobby": {{"movie", "sports"}}, "name": "Person Two"}
+);
+
+insert into dataset testds (
+{ "id": "004", "name": "Person Four", "hobby": {{"swimming"}} }
+);
+
+insert into dataset testds (
+{ "name": "Person Five", "id": "005"}
+);
+
+insert into dataset testds2 (
+ for $d in dataset("testds")
+    return $d
+);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.3.query.aql
new file mode 100644
index 0000000..6ef3159
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-c2o/opentype-c2o.3.query.aql
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-c2o.aql
+ * Description     : read data from a closed type dataset into a open type 
dataset and verify if
+ *                    records can be casted to the target open type
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+for $d in dataset("testds2")
+order by $d.id
+return $d

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.1.ddl.aql
new file mode 100644
index 0000000..199c275
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.1.ddl.aql
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-closed-optional.aql
+ * Description     : verify that closed type can have optional fields
+ * Expected Result : Success
+ */
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+
+use dataverse testdv2;
+
+create type testtype as closed {
+  name: string?,
+  id: string
+}
+
+create dataset testds(testtype) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.2.update.aql
new file mode 100644
index 0000000..f8a47df
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.2.update.aql
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-closed-optional.aql
+ * Description     : verify that closed type can have optional fields
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+insert into dataset testds (
+{ "id": "001", "name": "Person One"}
+);
+
+insert into dataset testds (
+{ "id": "002"}
+);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.3.query.aql
new file mode 100644
index 0000000..ef34b2b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-closed-optional/opentype-closed-optional.3.query.aql
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-closed-optional.aql
+ * Description     : verify that closed type can have optional fields
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+for $d in dataset("testds") 
+order by $d.id
+return $d

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.1.ddl.aql
new file mode 100644
index 0000000..f984ece
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.1.ddl.aql
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-insert.aql
+ * Description     : verify static type casting
+ * Expected Result : Success
+ */
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+
+use dataverse testdv2;
+
+create type testtype as open {
+  id: string,
+  name: string
+}
+
+create dataset testds(testtype) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.2.update.aql
new file mode 100644
index 0000000..edba28d
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.2.update.aql
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-insert.aql
+ * Description     : verify static type casting
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+ 
+ insert into dataset testds (
+ { "id": "001", "name": "Person Three", "hobbies": {{"scuba", "music"}}}
+ );
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.3.query.aql
new file mode 100644
index 0000000..81843ad
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert/opentype-insert.3.query.aql
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-insert.aql
+ * Description     : verify static type casting
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+for $d in dataset("testds") 
+return $d

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.1.ddl.aql
new file mode 100644
index 0000000..8a77067
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.1.ddl.aql
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-insert2.aql
+ * Description     : verify that the case where SetClosedRecordRule should not 
rewrite
+ *                    the plan to use closed-object-descriptor
+ * Expected Result : Success
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type TestType as open {
+    id: int64
+}
+
+create dataset testds(TestType) primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.2.update.aql
new file mode 100644
index 0000000..ba7fc30
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.2.update.aql
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-insert2.aql
+ * Description     : verify that the case where SetClosedRecordRule should not 
rewrite
+ *                    the plan to use closed-object-descriptor
+ * Expected Result : Success
+ */
+
+use dataverse test;
+
+insert into dataset testds( for $i in range(1, 10) return { 
"id":$i,"name":"John Doe" });
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.3.query.aql
new file mode 100644
index 0000000..e67a7f6
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-insert2/opentype-insert2.3.query.aql
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-insert2.aql
+ * Description     : verify that the case where SetClosedRecordRule should not 
rewrite
+ *                    the plan to use closed-object-descriptor
+ * Expected Result : Success
+ */
+
+use dataverse test;
+
+for $l in dataset('testds')
+order by $l.id
+return $l

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.1.ddl.aql
new file mode 100644
index 0000000..e2cdc3e
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.1.ddl.aql
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-noexpand.aql
+ * Description     : verify that open type dataset can have records without 
open fields
+ *                     verify the bag-based fields
+ * Expected Result : Success
+ */
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+
+use dataverse testdv2;
+
+create type testtype as open {
+  name: string?,
+  id: string
+}
+
+create dataset testds(testtype) primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.2.update.aql
new file mode 100644
index 0000000..4dfdfe4
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.2.update.aql
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-noexpand.aql
+ * Description     : verify that open type dataset can have records without 
open fields
+ *                     verify the bag-based fields
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+insert into dataset testds (
+{ "id": "001", "name": "Person One"}
+);
+
+insert into dataset testds (
+{ "id": "002"}
+);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.3.query.aql
new file mode 100644
index 0000000..6697435
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-noexpand/opentype-noexpand.3.query.aql
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-noexpand.aql
+ * Description     : verify that open type dataset can have records without 
open fields
+ *                     verify the bag-based fields
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+for $d in dataset("testds")
+order by $d.id
+return $d

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ddl.aql
new file mode 100644
index 0000000..29e2157
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.1.ddl.aql
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants
+ * Expected Result : Success
+ */
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+
+use dataverse testdv2;
+
+create type AddressType as open{
+  street: string,
+  city: string
+}
+
+create type Dept as closed{
+    name: string,
+    id: int64
+}
+
+create type testtype as open {
+  name: string,
+  id: string
+}
+
+create type testtype2 as closed {
+  name: string,
+  id: string,
+  address: AddressType?,
+  department: {{Dept}}?
+}
+
+create dataset testds(testtype) primary key id;
+
+create dataset testds2(testtype2) primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.update.aql
new file mode 100644
index 0000000..f940b46
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.2.update.aql
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+insert into dataset testds (
+{ "id": "001", "name": "Person One", "address": {"street": "3019 DBH",  
"city": "Irvine", "zip": 92697}, "department": {{ {"name":"CS", "id":299}, 
{"name":"EE", "id":399} }} }
+);
+
+insert into dataset testds (
+{ "id": "002", "name": "Person Two" }
+);
+
+insert into dataset testds (
+{ "id": "003", "name": "Person Three", "address": {"street": "2019 DBH",  
"city": "Irvine"} }
+);
+
+insert into dataset testds (
+{ "id": "004", "name": "Person Four", "address": {"street": "1019 DBH",  
"city": "irvine", "property": {"zip": 92697, "review": "positive" }  } }
+);
+
+insert into dataset testds2 (
+ for $d in dataset("testds")
+    return $d
+);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.query.aql
new file mode 100644
index 0000000..94569dd
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c-recursive/opentype-o2c-recursive.3.query.aql
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* 
+ * Test case Name  : opentype-o2c-recursive.aql
+ * Description     : verify the static casting of nest record constants 
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+for $d in dataset("testds2") 
+order by $d.id
+return $d

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.1.ddl.aql
new file mode 100644
index 0000000..2fbc5f2
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.1.ddl.aql
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2c.aql
+ * Description     : verify that open records can be inserted into a closed 
dataset
+ *                     verify missing optional fields in the closed part of 
the target closed dataset are allowed
+ * Expected Result : Success
+ */
+
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+
+use dataverse testdv2;
+
+create type testtype as open {
+  id: string,
+  name: string
+}
+
+create type testtype2 as closed {
+  hobby: {{string}}?,
+  id: string,
+  name: string
+}
+
+create dataset testds(testtype) primary key id;
+
+create dataset testds2(testtype2) primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.2.update.aql
new file mode 100644
index 0000000..af659af
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.2.update.aql
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2c.aql
+ * Description     : verify that open records can be inserted into a closed 
dataset
+ *                     verify missing optional fields in the closed part of 
the target closed dataset are allowed
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+insert into dataset testds (
+{ "id": "001",  "hobby": {{"music"}}, "name": "Person Three"}
+);
+
+insert into dataset testds (
+{ "id": "002", "name": "Person Three", "hobby": {{"football"}}}
+);
+
+insert into dataset testds (
+{ "id": "003", "name": "Person Three", "hobby": {{"movie", "coding", 
"debugging"}}}
+);
+
+insert into dataset testds (
+{ "name": "Person Three", "hobby": {{"swimming", "music"}}, "id": "004"}
+);
+
+insert into dataset testds (
+{ "id": "005", "name": "Person Five"}
+);
+
+insert into dataset testds2 (
+ for $d in dataset("testds")
+    return $d
+);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.3.query.aql
new file mode 100644
index 0000000..c512393
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2c/opentype-o2c.3.query.aql
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2c.aql
+ * Description     : verify that open records can be inserted into a closed 
dataset
+ *                     verify missing optional fields in the closed part of 
the target closed dataset are allowed
+ * Expected Result : Success
+ */
+
+use dataverse testdv2;
+
+for $d in dataset("testds2")
+order by $d.id
+return $d

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.1.ddl.aql
new file mode 100644
index 0000000..fbc5766
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.1.ddl.aql
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2o.aql
+ * Description     : verify that the dynamic type cast from one open type to 
another compatible open type
+ *                     verify the bag-based fields
+ * Expected Result : Success
+ */
+
+
+drop dataverse testdv2 if exists;
+create dataverse testdv2;
+
+use dataverse testdv2;
+
+create type testtype as open {
+  name: string,
+  id: string
+}
+
+create type testtype2 as open {
+  id: string,
+  name: string,
+  hobby: string
+}
+
+create dataset testds(testtype) primary key id;
+
+create dataset testds2(testtype2) primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.2.update.aql
new file mode 100644
index 0000000..db1c0f0
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.2.update.aql
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2o.aql
+ * Description     : verify that the dynamic type cast from one open type to 
another compatible open type
+ *                     verify the bag-based fields
+ * Expected Result : Success
+ */
+
+
+use dataverse testdv2;
+
+insert into dataset testds (
+{ "name": "Person One",  "id": "001", "hobby": "music"}
+);
+
+insert into dataset testds (
+{ "hobby": "football", "city":"irvine", "name": "Person Two", "id": "002"}
+);
+
+insert into dataset testds (
+{ "name": "Person Three",  "id": "003",  "hobby": "movie"}
+);
+
+insert into dataset testds (
+{ "hobby": "swimming", "name": "Person Four", "id": "004", 
"phone":"102-304-506"}
+);
+
+insert into dataset testds2 (
+ for $d in dataset("testds")
+    return $d
+);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.3.query.aql
new file mode 100644
index 0000000..51745f6
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/opentype-o2o/opentype-o2o.3.query.aql
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Test case Name  : opentype-o2o.aql
+ * Description     : verify that the dynamic type cast from one open type to 
another compatible open type
+ *                     verify the bag-based fields
+ * Expected Result : Success
+ */
+
+
+use dataverse testdv2;
+
+for $d in dataset("testds2")
+order by $d.id
+return $d

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.1.ddl.aql
new file mode 100644
index 0000000..6608439
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.1.ddl.aql
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue205
+                 : https://code.google.com/p/asterixdb/issues/detail?id=205
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type EmployeeStat as open {
+  age: int64,
+  salary: int64
+}
+
+create type EmployeeType as closed {
+  id: string,
+  stat: EmployeeStat,
+  deptCode: int64
+}
+
+create dataset Employees(EmployeeType)
+  primary key id;
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.2.update.aql
new file mode 100644
index 0000000..901af33
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.2.update.aql
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue205
+                 : https://code.google.com/p/asterixdb/issues/detail?id=205
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+use dataverse test;
+
+insert into dataset Employees({"id":"1234", "stat":{ "age":50, 
"salary":120000}, "deptCode":32 });
+insert into dataset Employees({"id":"5678", "stat":{ "age":40, 
"salary":100000}, "deptCode":16 });
+
+delete $l from dataset Employees where $l.id = "1234";
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.3.query.aql
new file mode 100644
index 0000000..634df86
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue205/query-issue205.3.query.aql
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue205
+                 : https://code.google.com/p/asterixdb/issues/detail?id=205
+ * Expected Res : Success
+ * Date         : 26th November 2012
+ */
+
+use dataverse test;
+
+for $l in dataset('Employees')
+return $l

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.1.ddl.aql
new file mode 100644
index 0000000..093e5eb
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.1.ddl.aql
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+                 : https://code.google.com/p/asterixdb/issues/detail?id=288
+ * Expected Res : Success
+ * Date         : 3th April 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type LineIDType as closed {
+  l_orderkey: int64,
+  l_linenumber: int64,
+  l_suppkey: int64
+}
+
+create dataset LineID(LineIDType)
+  primary key l_orderkey, l_linenumber;
+
+create dataset LineID2(LineIDType)
+  primary key l_orderkey, l_linenumber;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.2.update.aql
new file mode 100644
index 0000000..786e3e2
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.2.update.aql
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+                 : https://code.google.com/p/asterixdb/issues/detail?id=288
+ * Expected Res : Success
+ * Date         : 3th April 2013
+ */
+
+use dataverse test;
+
+load dataset LineID
+using localfs
+(("path"="asterix_nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|"))
 pre-sorted;
+
+
+insert into dataset LineID (
+let $x:=1
+let $y:=2
+let $z:=3
+return {
+    "l_orderkey": $x,
+    "l_linenumber": $y,
+    "l_suppkey": $z
+}
+);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.3.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.3.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.3.ddl.aql
new file mode 100644
index 0000000..7c54bfe
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.3.ddl.aql
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+                 : https://code.google.com/p/asterixdb/issues/detail?id=288
+ * Expected Res : Success
+ * Date         : 3th April 2013
+ */
+use dataverse test;
+
+create index idx_LineID_1 on LineID(l_linenumber);
+create index idx_LineID_2 on LineID2(l_linenumber);
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.4.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.4.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.4.update.aql
new file mode 100644
index 0000000..ea8287c
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.4.update.aql
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+                 : https://code.google.com/p/asterixdb/issues/detail?id=288
+ * Expected Res : Success
+ * Date         : 3th April 2013
+ */
+
+use dataverse test;
+
+insert into dataset LineID2
+(
+    for $r in dataset('LineID')
+    return $r
+);
+
+// If we replace the insert statement with this, it will work
+/* insert into dataset LineID2
+(
+    for $r in dataset('LineID')
+    return {
+"l_orderkey": $r.l_orderkey,
+"l_linenumber": $r.l_linenumber,
+"l_suppkey": $r.l_suppkey}
+);
+*/

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.5.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.5.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.5.query.aql
new file mode 100644
index 0000000..96bfd4e
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue288/query-issue288.5.query.aql
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue288
+                 : https://code.google.com/p/asterixdb/issues/detail?id=288
+ * Expected Res : Success
+ * Date         : 3th April 2013
+ */
+
+use dataverse test;
+
+for $c in dataset('LineID2')
+where $c.l_linenumber=2
+return $c

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.1.ddl.aql
new file mode 100644
index 0000000..4568a83
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.1.ddl.aql
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+drop dataverse SocialNetworkData if exists;
+create dataverse SocialNetworkData;
+
+use dataverse SocialNetworkData;
+
+create type EmploymentType as closed {
+organization-name: string,
+start-date: date,
+end-date: date?
+}
+
+create type FacebookUserType as closed {
+id: int64,
+id-copy: int64,
+alias: string,
+name: string,
+user-since: datetime,
+user-since-copy: datetime,
+friend-ids: {{ int64 }},
+employment: [EmploymentType]
+}
+
+create dataset FacebookUsers(FacebookUserType)
+primary key id;
+
+create dataset HandbookUsers(FacebookUserType)
+primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.2.update.aql
new file mode 100644
index 0000000..d901204
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.2.update.aql
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use dataverse SocialNetworkData;
+
+load dataset FacebookUsers using localfs
+(("path"="asterix_nc1://data/fbu-dml-insert-shuffled.adm"),("format"="adm"));
+
+insert into dataset HandbookUsers (
+for $x in dataset FacebookUsers
+where $x.id < 10307032
+return $x
+)

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.3.query.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.3.query.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.3.query.aql
new file mode 100644
index 0000000..34bcbae
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue382/query-issue382.3.query.aql
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use dataverse SocialNetworkData;
+
+count(for $h in dataset HandbookUsers return $h);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue433/query-issue433.1.ddl.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue433/query-issue433.1.ddl.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue433/query-issue433.1.ddl.aql
new file mode 100644
index 0000000..87970ef
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue433/query-issue433.1.ddl.aql
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue433
+                 : https://code.google.com/p/asterixdb/issues/detail?id=433
+ * Expected Res : Success
+ * Date         : 3th April 2013
+ */
+
+drop dataverse insertIssue if exists;
+create dataverse insertIssue;
+use dataverse insertIssue;
+
+create type subElem as closed {
+n: string,
+e: int64?
+}
+
+create type elem as closed {
+id: int64,
+name: string,
+sub: [subElem]
+}
+
+create dataset myDataset(elem)
+primary key id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4dbb614/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue433/query-issue433.2.update.aql
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue433/query-issue433.2.update.aql
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue433/query-issue433.2.update.aql
new file mode 100644
index 0000000..6761d0e
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/query-issue433/query-issue433.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : This test case is to verify the fix for issue433
+                 : https://code.google.com/p/asterixdb/issues/detail?id=433
+ * Expected Res : Success
+ * Date         : 3th April 2013
+ */
+
+use dataverse insertIssue;
+
+insert into dataset myDataset (
+for $t in [ {"id":1, "name":"u1","sub":[{"n":"se1","e":100}]}, {"id":2, 
"name":"u2","sub":[{"n":"se2","e":200}]} ]
+return $t
+);

Reply via email to