[FUN] fix array functions when args have ANY type

- user model changes: no
- storage format changes: no
- interface changes: no

details:
This is to fix the array functions that use type inferer
in order to infer the types of the arguments at compile time.
In some cases, the args could have ANY type at compile time
but they return the correct required type at runtime. This
patch handles such scenarios.

Change-Id: I4d6cf358f0850e3cdd45f8de9939173b9797c6e8
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2809
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.3.query.sqlpp
index 20ea6fc..c8673f5 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_append/array_append.3.query.sqlpp
@@ -28,5 +28,6 @@
   "t6": (array_append("non_array", 5, missing)),  // missing
   "t7": (array_append([], 5, 10, 12.0, "sth")),   // OK
   "t8": (array_append(missing, 3, 9)),            // missing
-  "t9": (array_append([3], 3, [9], null, "sth"))  // OK to add nulls
+  "t9": (array_append([3], 3, [9], null, "sth")), // OK to add nulls
+  "t10": (select array_append(d.followers, "sth1", "sth2") from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_concat/array_concat.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_concat/array_concat.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_concat/array_concat.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_concat/array_concat.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_concat/array_concat.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_concat/array_concat.3.query.sqlpp
index c36b56f..35d959c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_concat/array_concat.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_concat/array_concat.3.query.sqlpp
@@ -28,5 +28,6 @@
   "t6": (array_concat("non_array", [5], missing)),// missing
   "t7": (array_concat([], [5, 10], [12.0], [])),  // OK
   "t8": (array_concat(missing, 3, 9)),            // missing
-  "t9": (array_concat([3, missing], [3, [9], null, missing, null]))  // OK with nulls
+  "t9": (array_concat([3, missing], [3, [9], null, missing, null])),  // OK with nulls
+  "t10": (select array_concat(d.followers, ["sth", 5], [3,2]) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.1.ddl.sqlpp
index 257c4dd..1c55a9a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.1.ddl.sqlpp
@@ -43,4 +43,14 @@
   `message-text` : string
 };
 
-create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
\ No newline at end of file
+create type t1 AS {
+
+};
+
+create type t2 AS {
+id: int,
+compType: t1
+};
+
+create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
+create dataset d1(t2) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.2.update.sqlpp
index 4a0e7ed..d666e41 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.2.update.sqlpp
@@ -20,3 +20,8 @@
 use TinySocial;
 
 load  dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`));
+
+insert into d1([
+{"id":1, "compType":{"sth":33}},
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones", "John Green", "Emily Jones", "sth"]}
+]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.3.query.sqlpp
index ee5070a..dd01484 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.3.query.sqlpp
@@ -29,5 +29,6 @@
   "t7": (array_distinct("non_array")),
   "t8": (array_distinct([])),
   "t9": (array_distinct(missing)),
-  "t10": (array_distinct(null))
+  "t10": (array_distinct(null)),
+  "t11": (select array_distinct(d.followers) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.1.ddl.sqlpp
index 8c406c9..ad018d3 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.1.ddl.sqlpp
@@ -21,3 +21,14 @@
 create  dataverse TinySocial;
 
 use TinySocial;
+
+create type t1 AS {
+
+};
+
+create type t2 AS {
+id: int,
+compType: t1
+};
+
+create dataset d1(t2) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.2.update.sqlpp
index 042f3ce..f63c82d 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.2.update.sqlpp
@@ -16,3 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
+use TinySocial;
+
+insert into d1([
+{"id":1, "compType":{"sth":33}},
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones", ["sth"]]}
+]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.3.query.sqlpp
index 685c96a..323d018 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_flatten/array_flatten.3.query.sqlpp
@@ -35,5 +35,6 @@
   "t13": (array_flatten(null, 2)),
   "t14": (array_flatten(null, missing)),
   "t15": (array_flatten("non_array", 2)),
-  "t16": (array_flatten([1,2,3, [5,6,7]], "non-numeric"))
+  "t16": (array_flatten([1,2,3, [5,6,7]], "non-numeric")),
+  "t17": (select array_flatten(d.followers, 1) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.1.ddl.sqlpp
index 257c4dd..1c55a9a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.1.ddl.sqlpp
@@ -43,4 +43,14 @@
   `message-text` : string
 };
 
-create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
\ No newline at end of file
+create type t1 AS {
+
+};
+
+create type t2 AS {
+id: int,
+compType: t1
+};
+
+create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
+create dataset d1(t2) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.2.update.sqlpp
index 4a0e7ed..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.2.update.sqlpp
@@ -20,3 +20,8 @@
 use TinySocial;
 
 load  dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`));
+
+insert into d1([
+{"id":1, "compType":{"sth":33}},
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp
index 137c9fa..fdc35cc 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp
@@ -39,5 +39,6 @@
   "t17": (array_insert([6], 1, null, 9, null)),   // OK to insert nulls
   "t18": (array_insert([6], null, 5, 9, null)),   // null
   "t19": (array_insert([6], 3, null, missing, 9, null)),  // missing
-  "t20": (select array_insert(t.`referred-topics`, 0, 5) from TweetMessages t order by t.tweetid)
+  "t20": (select array_insert(t.`referred-topics`, 0, 5) from TweetMessages t order by t.tweetid),
+  "t21": (select array_insert(d.followers, 0, 5, 3) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.3.query.sqlpp
index 283af63..3de0126 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.3.query.sqlpp
@@ -35,5 +35,6 @@
   "t13": (array_intersect([3,5,1], "non_array", [2,5,1])),
   "t14": (array_intersect(missing, "non_array", [2,5,1])),
   "t15": (array_intersect([], [], [])),
-  "t16": (array_intersect([], [3,2], []))
+  "t16": (array_intersect([], [3,2], [])),
+  "t17": (select array_intersect(d.followers, ["John Green", "sth"], ["sth", "John Green"]) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_prepend/array_prepend.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_prepend/array_prepend.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_prepend/array_prepend.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_prepend/array_prepend.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_prepend/array_prepend.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_prepend/array_prepend.3.query.sqlpp
index e912a75..1603570e 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_prepend/array_prepend.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_prepend/array_prepend.3.query.sqlpp
@@ -28,5 +28,6 @@
   "t6": (array_prepend(5, missing, "non_array")),   // missing
   "t7": (array_prepend(5, 10, 12.0, "sth",[77, "val"])),   // OK
   "t8": (array_prepend(5, 10, null, "sth",[77, "val"])),   // OK to insert nulls
-  "t9": (array_prepend(3, 9, missing))              // missing
+  "t9": (array_prepend(3, 9, missing)),              // missing
+  "t10": (select array_prepend("sth1", "sth2", d.followers) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.3.query.sqlpp
index 2e37af2..44ff8f2 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.3.query.sqlpp
@@ -29,5 +29,6 @@
   "t7": (array_put(null, 3, 9)),               // null
   "t8": (array_put([3,2,"sth"], 3, 9, 9, 3, "sth")), // OK
   "t9": (array_put([3,2,"sth"], 1, 5)),     // OK
-  "t10": (array_put([3,2,"sth"], null, 5))   // null
+  "t10": (array_put([3,2,"sth"], null, 5)),   // null
+  "t11": (select array_put(d.followers, "sth1", "John Green", "sth2") from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.3.query.sqlpp
index f726e7c..ca1d2af 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.3.query.sqlpp
@@ -28,5 +28,6 @@
   "t6": (array_remove(missing, 3, 9)),            // missing
   "t7": (array_remove(null, 3, 9)),               // null
   "t8": (array_remove([3,2,"sth"], 3, 9, 9, 3, "sth")), // OK
-  "t9": (array_remove([3,2,"sth"], 1, null))      // null
+  "t9": (array_remove([3,2,"sth"], 1, null)),      // null
+  "t10": (select array_remove(d.followers, "sth1", "John Green") from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.1.ddl.sqlpp
index 257c4dd..1c55a9a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.1.ddl.sqlpp
@@ -43,4 +43,14 @@
   `message-text` : string
 };
 
-create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
\ No newline at end of file
+create type t1 AS {
+
+};
+
+create type t2 AS {
+id: int,
+compType: t1
+};
+
+create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
+create dataset d1(t2) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.2.update.sqlpp
index 4a0e7ed..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.2.update.sqlpp
@@ -20,3 +20,8 @@
 use TinySocial;
 
 load  dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`));
+
+insert into d1([
+{"id":1, "compType":{"sth":33}},
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.3.query.sqlpp
index 1bea679..217d8a7 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.3.query.sqlpp
@@ -43,5 +43,6 @@
   "t21": (array_replace([3,2,3], 3, null, 8)),
   "t22": (array_replace([3,2], null, 3, 3)),
   "t23": (array_replace([3,null,2], null, 3, 3)),
-  "t24": (array_replace(missing, null, 3, 3))
+  "t24": (array_replace(missing, null, 3, 3)),
+  "t25": (select array_replace(d.followers, "Emily Jones", "sth") from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.1.ddl.sqlpp
index 257c4dd..1c55a9a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.1.ddl.sqlpp
@@ -43,4 +43,14 @@
   `message-text` : string
 };
 
-create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
\ No newline at end of file
+create type t1 AS {
+
+};
+
+create type t2 AS {
+id: int,
+compType: t1
+};
+
+create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
+create dataset d1(t2) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.2.update.sqlpp
index 4a0e7ed..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.2.update.sqlpp
@@ -20,3 +20,8 @@
 use TinySocial;
 
 load  dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`));
+
+insert into d1([
+{"id":1, "compType":{"sth":33}},
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.3.query.sqlpp
index 70e09a6..6f65b77 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_reverse/array_reverse.3.query.sqlpp
@@ -28,5 +28,6 @@
   "t6": (select array_reverse("non_array")),
   "t7": (select array_reverse([])),
   "t8": (select array_reverse(missing)),
-  "t9": (select array_reverse(null))
+  "t9": (select array_reverse(null)),
+  "t10": (select array_reverse(d.followers) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.1.ddl.sqlpp
index 257c4dd..1c55a9a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.1.ddl.sqlpp
@@ -43,4 +43,14 @@
   `message-text` : string
 };
 
-create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
\ No newline at end of file
+create type t1 AS {
+
+};
+
+create type t2 AS {
+id: int,
+compType: t1
+};
+
+create  dataset TweetMessages(TweetMessageType) primary key tweetid hints (`CARDINALITY`=`100`);
+create dataset d1(t2) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.2.update.sqlpp
index 4a0e7ed..1426f85 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.2.update.sqlpp
@@ -20,3 +20,8 @@
 use TinySocial;
 
 load  dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`));
+
+insert into d1([
+{"id":1, "compType":{"sth":33}},
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones", "Abby"]}
+]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.3.query.sqlpp
index 3047c11..55c3569 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.3.query.sqlpp
@@ -29,5 +29,6 @@
   "t7": (array_sort("non_array")),
   "t8": (array_sort([])),
   "t9": (array_sort(missing)),
-  "t10": (array_sort(null))
+  "t10": (array_sort(null)),
+  "t11": (select array_sort(d.followers) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_star/array_star.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_star/array_star.2.update.sqlpp
index 4a490a9..2c88183 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_star/array_star.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_star/array_star.2.update.sqlpp
@@ -21,5 +21,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":[{"a":"a_val1", "b": "b_val1"}, {"a":"a_val2", "b":"b_val2"}, {"a":"a_val3", "b":"b_val3"}]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_star/array_star.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_star/array_star.3.query.sqlpp
index 5b027ee..442c02a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_star/array_star.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_star/array_star.3.query.sqlpp
@@ -38,5 +38,6 @@
   "t16": (array_star([])),
   "t17": (array_star("non_array")),
   "t18": (array_star(missing)),
-  "t19": (array_star(null))
+  "t19": (array_star(null)),
+  "t20": (select array_star(d.followers) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.3.query.sqlpp
index 412580b..f87ab97 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.3.query.sqlpp
@@ -33,5 +33,6 @@
   "t11": (array_symdiff([3,5,1], "non_array", [2,5,1])),
   "t12": (array_symdiff(missing, "non_array", [2,5,1])),
   "t13": (array_symdiff([], [], [])),
-  "t14": (array_symdiff([2], [3,2], []))
+  "t14": (array_symdiff([2], [3,2], [])),
+  "t15": (select array_symdiff(d.followers, ["Emily Jones", "sth2"], ["sth", "sth2"]) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.3.query.sqlpp
index 5fc2e38..31759eb 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.3.query.sqlpp
@@ -33,5 +33,6 @@
   "t11": (array_symdiffn([3,5,1], "non_array", [2,5,1])),
   "t12": (array_symdiffn(missing, "non_array", [2,5,1])),
   "t13": (array_symdiffn([], [], [])),
-  "t14": (array_symdiffn([2], [3,2], []))
+  "t14": (array_symdiffn([2], [3,2], [])),
+  "t15": (select array_symdiffn(d.followers, ["Emily Jones", "sth2"], ["sth", "sth2"], ["sth2", 4]) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.2.update.sqlpp
index 2767210..1c4bad0 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.2.update.sqlpp
@@ -23,5 +23,5 @@
 
 insert into d1([
 {"id":1, "compType":{"sth":33}},
-{"id":2, "compType":{"sth":44}}
+{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
 ]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.3.query.sqlpp
index 98fc159..8e87893 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.3.query.sqlpp
@@ -35,5 +35,6 @@
   "t13": (array_union([3,5,1], "non_array", [2,5,1])),
   "t14": (array_union(missing, "non_array", [2,5,1])),
   "t15": (array_union([], [], [])),
-  "t16": (array_union([], [3,2], []))
+  "t16": (array_union([], [3,2], [])),
+  "t17": (select array_union(d.followers, ["John Green", "sth"], ["sth", "1"]) from d1 d)
 };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_append/array_append.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_append/array_append.3.adm
index 33f9a09..f1f17c2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_append/array_append.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_append/array_append.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "t-mobile", "customization", "sth", 5 }} }, { "$1": {{ "verizon", "voice-clarity", "sth", 5 }} }, { "$1": {{ "iphone", "platform", "sth", 5 }} }, { "$1": {{ "samsung", "voice-command", "sth", 5 }} }, { "$1": {{ "verizon", "shortcut-menu", "sth", 5 }} }, { "$1": {{ "motorola", "speed", "sth", 5 }} }, { "$1": {{ "sprint", "voice-command", "sth", 5 }} }, { "$1": {{ "motorola", "speed", "sth", 5 }} }, { "$1": {{ "iphone", "voice-clarity", "sth", 5 }} }, { "$1": {{ "samsung", "platform", "sth", 5 }} }, { "$1": {{ "t-mobile", "shortcut-menu", "sth", 5 }} }, { "$1": {{ "verizon", "voicemail-service", "sth", 5 }} } ], "t2": [ { "$2": [ 3, "John", [ { "sth": 33 }, { "sth": 44 } ] ] } ], "t4": null, "t5": null, "t7": [ 5, 10, 12.0, "sth" ], "t9": [ 3, 3, [ 9 ], null, "sth" ] }
+{ "t1": [ { "$1": {{ "t-mobile", "customization", "sth", 5 }} }, { "$1": {{ "verizon", "voice-clarity", "sth", 5 }} }, { "$1": {{ "iphone", "platform", "sth", 5 }} }, { "$1": {{ "samsung", "voice-command", "sth", 5 }} }, { "$1": {{ "verizon", "shortcut-menu", "sth", 5 }} }, { "$1": {{ "motorola", "speed", "sth", 5 }} }, { "$1": {{ "sprint", "voice-command", "sth", 5 }} }, { "$1": {{ "motorola", "speed", "sth", 5 }} }, { "$1": {{ "iphone", "voice-clarity", "sth", 5 }} }, { "$1": {{ "samsung", "platform", "sth", 5 }} }, { "$1": {{ "t-mobile", "shortcut-menu", "sth", 5 }} }, { "$1": {{ "verizon", "voicemail-service", "sth", 5 }} } ], "t2": [ { "$2": [ 3, "John", [ { "sth": 33 }, { "sth": 44 } ] ] } ], "t4": null, "t5": null, "t7": [ 5, 10, 12.0, "sth" ], "t9": [ 3, 3, [ 9 ], null, "sth" ], "t10": [ {  }, { "$3": [ "John Green", "Emily Jones", "sth1", "sth2" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_concat/array_concat.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_concat/array_concat.3.adm
index 8fa9f22..2ee9cbc 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_concat/array_concat.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_concat/array_concat.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "t-mobile", "customization", "sth", 5, 3, 2 }} }, { "$1": {{ "verizon", "voice-clarity", "sth", 5, 3, 2 }} }, { "$1": {{ "iphone", "platform", "sth", 5, 3, 2 }} }, { "$1": {{ "samsung", "voice-command", "sth", 5, 3, 2 }} }, { "$1": {{ "verizon", "shortcut-menu", "sth", 5, 3, 2 }} }, { "$1": {{ "motorola", "speed", "sth", 5, 3, 2 }} }, { "$1": {{ "sprint", "voice-command", "sth", 5, 3, 2 }} }, { "$1": {{ "motorola", "speed", "sth", 5, 3, 2 }} }, { "$1": {{ "iphone", "voice-clarity", "sth", 5, 3, 2 }} }, { "$1": {{ "samsung", "platform", "sth", 5, 3, 2 }} }, { "$1": {{ "t-mobile", "shortcut-menu", "sth", 5, 3, 2 }} }, { "$1": {{ "verizon", "voicemail-service", "sth", 5, 3, 2 }} } ], "t2": [ { "$2": [ 3, "John", { "sth": 33 }, { "sth": 44 } ] } ], "t4": null, "t5": null, "t7": [ 5, 10, 12.0 ], "t9": [ 3, null, 3, [ 9 ], null, null, null ] }
+{ "t1": [ { "$1": {{ "t-mobile", "customization", "sth", 5, 3, 2 }} }, { "$1": {{ "verizon", "voice-clarity", "sth", 5, 3, 2 }} }, { "$1": {{ "iphone", "platform", "sth", 5, 3, 2 }} }, { "$1": {{ "samsung", "voice-command", "sth", 5, 3, 2 }} }, { "$1": {{ "verizon", "shortcut-menu", "sth", 5, 3, 2 }} }, { "$1": {{ "motorola", "speed", "sth", 5, 3, 2 }} }, { "$1": {{ "sprint", "voice-command", "sth", 5, 3, 2 }} }, { "$1": {{ "motorola", "speed", "sth", 5, 3, 2 }} }, { "$1": {{ "iphone", "voice-clarity", "sth", 5, 3, 2 }} }, { "$1": {{ "samsung", "platform", "sth", 5, 3, 2 }} }, { "$1": {{ "t-mobile", "shortcut-menu", "sth", 5, 3, 2 }} }, { "$1": {{ "verizon", "voicemail-service", "sth", 5, 3, 2 }} } ], "t2": [ { "$2": [ 3, "John", { "sth": 33 }, { "sth": 44 } ] } ], "t4": null, "t5": null, "t7": [ 5, 10, 12.0 ], "t9": [ 3, null, 3, [ 9 ], null, null, null ], "t10": [ {  }, { "$3": [ "John Green", "Emily Jones", "sth", 5, 3, 2 ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_distinct/array_distinct.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_distinct/array_distinct.3.adm
index 0482ae3..7461980 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_distinct/array_distinct.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_distinct/array_distinct.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "t-mobile", "customization", "verizon", "platform" }} }, { "$1": {{ "verizon", "voice-clarity", "platform" }} }, { "$1": {{ "iphone", "platform", "verizon" }} }, { "$1": {{ "samsung", "voice-command", "verizon", "platform" }} }, { "$1": {{ "verizon", "shortcut-menu", "platform" }} }, { "$1": {{ "motorola", "speed", "verizon", "platform" }} }, { "$1": {{ "sprint", "voice-command", "verizon", "platform" }} }, { "$1": {{ "motorola", "speed", "verizon", "platform" }} }, { "$1": {{ "iphone", "voice-clarity", "verizon", "platform" }} }, { "$1": {{ "samsung", "platform", "verizon" }} }, { "$1": {{ "t-mobile", "shortcut-menu", "verizon", "platform" }} }, { "$1": {{ "verizon", "voicemail-service", "platform" }} } ], "t2": [ 19, 5, 7, 2 ], "t3": [ 19, 5, 7, 5.1, 2 ], "t4": [ 19, 5, "a", 7.5, "A", "John" ], "t5": [ 19, null, 7, 5 ], "t6": [ 3 ], "t7": null, "t8": [  ], "t10": null }
+{ "t1": [ { "$1": {{ "t-mobile", "customization", "verizon", "platform" }} }, { "$1": {{ "verizon", "voice-clarity", "platform" }} }, { "$1": {{ "iphone", "platform", "verizon" }} }, { "$1": {{ "samsung", "voice-command", "verizon", "platform" }} }, { "$1": {{ "verizon", "shortcut-menu", "platform" }} }, { "$1": {{ "motorola", "speed", "verizon", "platform" }} }, { "$1": {{ "sprint", "voice-command", "verizon", "platform" }} }, { "$1": {{ "motorola", "speed", "verizon", "platform" }} }, { "$1": {{ "iphone", "voice-clarity", "verizon", "platform" }} }, { "$1": {{ "samsung", "platform", "verizon" }} }, { "$1": {{ "t-mobile", "shortcut-menu", "verizon", "platform" }} }, { "$1": {{ "verizon", "voicemail-service", "platform" }} } ], "t2": [ 19, 5, 7, 2 ], "t3": [ 19, 5, 7, 5.1, 2 ], "t4": [ 19, 5, "a", 7.5, "A", "John" ], "t5": [ 19, null, 7, 5 ], "t6": [ 3 ], "t7": null, "t8": [  ], "t10": null, "t11": [ {  }, { "$2": [ "John Green", "Emily Jones", "sth" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_flatten/array_flatten.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_flatten/array_flatten.3.adm
index 180f1d3..72de628 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_flatten/array_flatten.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_flatten/array_flatten.3.adm
@@ -1 +1 @@
-{ "t1": [ 2, 3, 7, 1, 2, 8, [ 12, 13, 14 ] ], "t2": [ 2, 3, 7, 1, "a", 8, [ 12, "b", 14 ] ], "t3": [ 2, 3, 7, 1, "a", 8, 12, "b", 14 ], "t4": [ 2, 3, 7, 1, "a", 8, 12, "b", 14 ], "t5": [ 2, 3, [ 7, 1, "a" ], [ 8, [ 12, "b", 14 ] ] ], "t6": [ 2, 3, 7, 1, "a", 8, 12, "b", 14 ], "t7": [ 2, 3, 7, 1, "a", 8, 12, "b", 14 ], "t8": null, "t9": [ 2, 3, null, 7, 1, null, "a", 8, 12, null, "b", 14, null ], "t11": null, "t13": null, "t15": null, "t16": null }
+{ "t1": [ 2, 3, 7, 1, 2, 8, [ 12, 13, 14 ] ], "t2": [ 2, 3, 7, 1, "a", 8, [ 12, "b", 14 ] ], "t3": [ 2, 3, 7, 1, "a", 8, 12, "b", 14 ], "t4": [ 2, 3, 7, 1, "a", 8, 12, "b", 14 ], "t5": [ 2, 3, [ 7, 1, "a" ], [ 8, [ 12, "b", 14 ] ] ], "t6": [ 2, 3, 7, 1, "a", 8, 12, "b", 14 ], "t7": [ 2, 3, 7, 1, "a", 8, 12, "b", 14 ], "t8": null, "t9": [ 2, 3, null, 7, 1, null, "a", 8, 12, null, "b", 14, null ], "t11": null, "t13": null, "t15": null, "t16": null, "t17": [ {  }, { "$1": [ "John Green", "Emily Jones", "sth" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm
index 86bc114..8e136ca 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm
@@ -1 +1 @@
-{ "t1": [ "a", "b", 1, 2, 3 ], "t2": [ 1, 2, 3, "a", "b" ], "t3": [ 1, 1, 2, "a", "b", 4 ], "t4": [ 1, 1, 2, 7, "a", 7, "one more", 4 ], "t5": null, "t6": [ 1, 2, "a", "b", 3 ], "t7": null, "t8": null, "t10": null, "t11": [ 10, 12.0, "sth" ], "t12": null, "t13": [ 6, 9 ], "t14": [ 6, 9 ], "t15": null, "t17": [ 6, null, 9, null ], "t18": null, "t20": [ { "$1": {{ 5, "t-mobile", "customization" }} }, { "$1": {{ 5, "verizon", "voice-clarity" }} }, { "$1": {{ 5, "iphone", "platform" }} }, { "$1": {{ 5, "samsung", "voice-command" }} }, { "$1": {{ 5, "verizon", "shortcut-menu" }} }, { "$1": {{ 5, "motorola", "speed" }} }, { "$1": {{ 5, "sprint", "voice-command" }} }, { "$1": {{ 5, "motorola", "speed" }} }, { "$1": {{ 5, "iphone", "voice-clarity" }} }, { "$1": {{ 5, "samsung", "platform" }} }, { "$1": {{ 5, "t-mobile", "shortcut-menu" }} }, { "$1": {{ 5, "verizon", "voicemail-service" }} } ] }
+{ "t1": [ "a", "b", 1, 2, 3 ], "t2": [ 1, 2, 3, "a", "b" ], "t3": [ 1, 1, 2, "a", "b", 4 ], "t4": [ 1, 1, 2, 7, "a", 7, "one more", 4 ], "t5": null, "t6": [ 1, 2, "a", "b", 3 ], "t7": null, "t8": null, "t10": null, "t11": [ 10, 12.0, "sth" ], "t12": null, "t13": [ 6, 9 ], "t14": [ 6, 9 ], "t15": null, "t17": [ 6, null, 9, null ], "t18": null, "t20": [ { "$1": {{ 5, "t-mobile", "customization" }} }, { "$1": {{ 5, "verizon", "voice-clarity" }} }, { "$1": {{ 5, "iphone", "platform" }} }, { "$1": {{ 5, "samsung", "voice-command" }} }, { "$1": {{ 5, "verizon", "shortcut-menu" }} }, { "$1": {{ 5, "motorola", "speed" }} }, { "$1": {{ 5, "sprint", "voice-command" }} }, { "$1": {{ 5, "motorola", "speed" }} }, { "$1": {{ 5, "iphone", "voice-clarity" }} }, { "$1": {{ 5, "samsung", "platform" }} }, { "$1": {{ 5, "t-mobile", "shortcut-menu" }} }, { "$1": {{ 5, "verizon", "voicemail-service" }} } ], "t21": [ {  }, { "$2": [ 5, 3, "John Green", "Emily Jones" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_intersect/array_intersect.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_intersect/array_intersect.3.adm
index 250149c..2276eb4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_intersect/array_intersect.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_intersect/array_intersect.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "t-mobile" }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{ "t-mobile" }} }, { "$1": {{  }} } ], "t2": [ { "$2": [ 2, 1 ] } ], "t3": [ 3, 5 ], "t4": [ 3, 5 ], "t5": [ 3, "a" ], "t6": [ 3 ], "t7": [  ], "t8": [  ], "t9": [  ], "t10": [  ], "t12": null, "t13": null, "t15": [  ], "t16": [  ] }
+{ "t1": [ { "$1": {{ "t-mobile" }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{  }} }, { "$1": {{ "t-mobile" }} }, { "$1": {{  }} } ], "t2": [ { "$2": [ 2, 1 ] } ], "t3": [ 3, 5 ], "t4": [ 3, 5 ], "t5": [ 3, "a" ], "t6": [ 3 ], "t7": [  ], "t8": [  ], "t9": [  ], "t10": [  ], "t12": null, "t13": null, "t15": [  ], "t16": [  ], "t17": [ {  }, { "$3": [ "John Green" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_prepend/array_prepend.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_prepend/array_prepend.3.adm
index 0e3a1af..e3b0b0b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_prepend/array_prepend.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_prepend/array_prepend.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "sth", 5, "t-mobile", "customization" }} }, { "$1": {{ "sth", 5, "verizon", "voice-clarity" }} }, { "$1": {{ "sth", 5, "iphone", "platform" }} }, { "$1": {{ "sth", 5, "samsung", "voice-command" }} }, { "$1": {{ "sth", 5, "verizon", "shortcut-menu" }} }, { "$1": {{ "sth", 5, "motorola", "speed" }} }, { "$1": {{ "sth", 5, "sprint", "voice-command" }} }, { "$1": {{ "sth", 5, "motorola", "speed" }} }, { "$1": {{ "sth", 5, "iphone", "voice-clarity" }} }, { "$1": {{ "sth", 5, "samsung", "platform" }} }, { "$1": {{ "sth", 5, "t-mobile", "shortcut-menu" }} }, { "$1": {{ "sth", 5, "verizon", "voicemail-service" }} } ], "t2": [ { "$2": [ [ { "sth": 33 }, { "sth": 44 } ], 3, "John" ] } ], "t4": null, "t5": null, "t7": [ 5, 10, 12.0, "sth", 77, "val" ], "t8": [ 5, 10, null, "sth", 77, "val" ] }
+{ "t1": [ { "$1": {{ "sth", 5, "t-mobile", "customization" }} }, { "$1": {{ "sth", 5, "verizon", "voice-clarity" }} }, { "$1": {{ "sth", 5, "iphone", "platform" }} }, { "$1": {{ "sth", 5, "samsung", "voice-command" }} }, { "$1": {{ "sth", 5, "verizon", "shortcut-menu" }} }, { "$1": {{ "sth", 5, "motorola", "speed" }} }, { "$1": {{ "sth", 5, "sprint", "voice-command" }} }, { "$1": {{ "sth", 5, "motorola", "speed" }} }, { "$1": {{ "sth", 5, "iphone", "voice-clarity" }} }, { "$1": {{ "sth", 5, "samsung", "platform" }} }, { "$1": {{ "sth", 5, "t-mobile", "shortcut-menu" }} }, { "$1": {{ "sth", 5, "verizon", "voicemail-service" }} } ], "t2": [ { "$2": [ [ { "sth": 33 }, { "sth": 44 } ], 3, "John" ] } ], "t4": null, "t5": null, "t7": [ 5, 10, 12.0, "sth", 77, "val" ], "t8": [ 5, 10, null, "sth", 77, "val" ], "t10": [ {  }, { "$3": [ "sth1", "sth2", "John Green", "Emily Jones" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_put/array_put.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_put/array_put.3.adm
index e76b132..b61b69c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_put/array_put.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_put/array_put.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "t-mobile", "customization", 5 }} }, { "$1": {{ "verizon", "voice-clarity", "t-mobile", 5 }} }, { "$1": {{ "iphone", "platform", "t-mobile", 5 }} }, { "$1": {{ "samsung", "voice-command", "t-mobile", 5 }} }, { "$1": {{ "verizon", "shortcut-menu", "t-mobile", 5 }} }, { "$1": {{ "motorola", "speed", "t-mobile", 5 }} }, { "$1": {{ "sprint", "voice-command", "t-mobile", 5 }} }, { "$1": {{ "motorola", "speed", "t-mobile", 5 }} }, { "$1": {{ "iphone", "voice-clarity", "t-mobile", 5 }} }, { "$1": {{ "samsung", "platform", "t-mobile", 5 }} }, { "$1": {{ "t-mobile", "shortcut-menu", 5 }} }, { "$1": {{ "verizon", "voicemail-service", "t-mobile", 5 }} } ], "t3": null, "t5": [ 5, 10, 12.0, "sth" ], "t7": null, "t8": [ 3, 2, "sth", 9, 9 ], "t9": [ 3, 2, "sth", 1, 5 ], "t10": null }
+{ "t1": [ { "$1": {{ "t-mobile", "customization", 5 }} }, { "$1": {{ "verizon", "voice-clarity", "t-mobile", 5 }} }, { "$1": {{ "iphone", "platform", "t-mobile", 5 }} }, { "$1": {{ "samsung", "voice-command", "t-mobile", 5 }} }, { "$1": {{ "verizon", "shortcut-menu", "t-mobile", 5 }} }, { "$1": {{ "motorola", "speed", "t-mobile", 5 }} }, { "$1": {{ "sprint", "voice-command", "t-mobile", 5 }} }, { "$1": {{ "motorola", "speed", "t-mobile", 5 }} }, { "$1": {{ "iphone", "voice-clarity", "t-mobile", 5 }} }, { "$1": {{ "samsung", "platform", "t-mobile", 5 }} }, { "$1": {{ "t-mobile", "shortcut-menu", 5 }} }, { "$1": {{ "verizon", "voicemail-service", "t-mobile", 5 }} } ], "t3": null, "t5": [ 5, 10, 12.0, "sth" ], "t7": null, "t8": [ 3, 2, "sth", 9, 9 ], "t9": [ 3, 2, "sth", 1, 5 ], "t10": null, "t11": [ {  }, { "$2": [ "John Green", "Emily Jones", "sth1", "sth2" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_remove/array_remove.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_remove/array_remove.3.adm
index f579aa3..c8f9de7 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_remove/array_remove.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_remove/array_remove.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "customization" }} }, { "$1": {{ "verizon", "voice-clarity" }} }, { "$1": {{ "iphone", "platform" }} }, { "$1": {{ "samsung", "voice-command" }} }, { "$1": {{ "verizon", "shortcut-menu" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "sprint", "voice-command" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "iphone", "voice-clarity" }} }, { "$1": {{ "samsung", "platform" }} }, { "$1": {{ "shortcut-menu" }} }, { "$1": {{ "verizon", "voicemail-service" }} } ], "t3": null, "t5": [  ], "t7": null, "t8": [ 2 ], "t9": null }
+{ "t1": [ { "$1": {{ "customization" }} }, { "$1": {{ "verizon", "voice-clarity" }} }, { "$1": {{ "iphone", "platform" }} }, { "$1": {{ "samsung", "voice-command" }} }, { "$1": {{ "verizon", "shortcut-menu" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "sprint", "voice-command" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "iphone", "voice-clarity" }} }, { "$1": {{ "samsung", "platform" }} }, { "$1": {{ "shortcut-menu" }} }, { "$1": {{ "verizon", "voicemail-service" }} } ], "t3": null, "t5": [  ], "t7": null, "t8": [ 2 ], "t9": null, "t10": [ {  }, { "$2": [ "Emily Jones" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_replace/array_replace.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_replace/array_replace.3.adm
index b13b9ed..3fc58af 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_replace/array_replace.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_replace/array_replace.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "coffee-mobile", "customization" }} }, { "$1": {{ "verizon", "voice-clarity" }} }, { "$1": {{ "iphone", "platform" }} }, { "$1": {{ "samsung", "voice-command" }} }, { "$1": {{ "verizon", "shortcut-menu" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "sprint", "voice-command" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "iphone", "voice-clarity" }} }, { "$1": {{ "samsung", "platform" }} }, { "$1": {{ "coffee-mobile", "shortcut-menu" }} }, { "$1": {{ "verizon", "voicemail-service" }} } ], "t2": [ 3, -2, 1, 5, -2, 9, -2, 3, -2, 1, -2 ], "t3": [ 3, -2, 1, 5, -4, 9, -4, 3, -4, 1, -4 ], "t4": [ 3, -2, 1, 5, "2", 9, -4, 3, -4, 1, -4 ], "t5": [ 3, -2, -2, 5, "2", 9, -2, 3, "A", 1, 2 ], "t6": [ 3, -2, "a", 5, "2", 9, [ 2, 3, "A" ], 1, -2 ], "t7": [ 3, -2, "a", 5, "2", 9, [ 2, 3, "A" ], 1, [ -2 ] ], "t8": [ 3, -5, -5, 2, 2, -5, 2, 1, 1 ], "t9": [ 3, 1, 1, 2, 2, 1, 2, 1, 1 ], "t10": [ 3, -5, -5, 2, 2, -5, 2, -5, 1 ], "t11": [ 3, -5, -5, 2, 2, -5, 2, -5, -5 ], "t12": [ 3, -5, -5, 2, 2, -5, 2, -5, -5 ], "t13": [ 3, -5, -5, 2, 2, -5, 2, -5, -5 ], "t14": [ 3, -5, 1, 2, 2, 1, 2, 1, 1 ], "t15": null, "t16": null, "t17": null, "t18": [  ], "t19": [ 3, 2 ], "t21": [ null, 2, null ], "t22": null, "t23": null }
+{ "t1": [ { "$1": {{ "coffee-mobile", "customization" }} }, { "$1": {{ "verizon", "voice-clarity" }} }, { "$1": {{ "iphone", "platform" }} }, { "$1": {{ "samsung", "voice-command" }} }, { "$1": {{ "verizon", "shortcut-menu" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "sprint", "voice-command" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "iphone", "voice-clarity" }} }, { "$1": {{ "samsung", "platform" }} }, { "$1": {{ "coffee-mobile", "shortcut-menu" }} }, { "$1": {{ "verizon", "voicemail-service" }} } ], "t2": [ 3, -2, 1, 5, -2, 9, -2, 3, -2, 1, -2 ], "t3": [ 3, -2, 1, 5, -4, 9, -4, 3, -4, 1, -4 ], "t4": [ 3, -2, 1, 5, "2", 9, -4, 3, -4, 1, -4 ], "t5": [ 3, -2, -2, 5, "2", 9, -2, 3, "A", 1, 2 ], "t6": [ 3, -2, "a", 5, "2", 9, [ 2, 3, "A" ], 1, -2 ], "t7": [ 3, -2, "a", 5, "2", 9, [ 2, 3, "A" ], 1, [ -2 ] ], "t8": [ 3, -5, -5, 2, 2, -5, 2, 1, 1 ], "t9": [ 3, 1, 1, 2, 2, 1, 2, 1, 1 ], "t10": [ 3, -5, -5, 2, 2, -5, 2, -5, 1 ], "t11": [ 3, -5, -5, 2, 2, -5, 2, -5, -5 ], "t12": [ 3, -5, -5, 2, 2, -5, 2, -5, -5 ], "t13": [ 3, -5, -5, 2, 2, -5, 2, -5, -5 ], "t14": [ 3, -5, 1, 2, 2, 1, 2, 1, 1 ], "t15": null, "t16": null, "t17": null, "t18": [  ], "t19": [ 3, 2 ], "t21": [ null, 2, null ], "t22": null, "t23": null, "t25": [ {  }, { "$2": [ "John Green", "sth" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_reverse/array_reverse.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_reverse/array_reverse.3.adm
index 57e5a3c..2c24059 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_reverse/array_reverse.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_reverse/array_reverse.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "customization", "t-mobile" }} }, { "$1": {{ "voice-clarity", "verizon" }} }, { "$1": {{ "platform", "iphone" }} }, { "$1": {{ "voice-command", "samsung" }} }, { "$1": {{ "shortcut-menu", "verizon" }} }, { "$1": {{ "speed", "motorola" }} }, { "$1": {{ "voice-command", "sprint" }} }, { "$1": {{ "speed", "motorola" }} }, { "$1": {{ "voice-clarity", "iphone" }} }, { "$1": {{ "platform", "samsung" }} }, { "$1": {{ "shortcut-menu", "t-mobile" }} }, { "$1": {{ "voicemail-service", "verizon" }} } ], "t2": [ { "$2": [ 19, 7, 5 ] } ], "t3": [ { "$3": [ 19, 7.5, 5 ] } ], "t4": [ { "$4": [ "John", 19, 7.5, 5 ] } ], "t5": [ { "$5": [ 3 ] } ], "t6": [ { "$6": null } ], "t7": [ { "$7": [  ] } ], "t8": [ {  } ], "t9": [ { "$9": null } ] }
+{ "t1": [ { "$1": {{ "customization", "t-mobile" }} }, { "$1": {{ "voice-clarity", "verizon" }} }, { "$1": {{ "platform", "iphone" }} }, { "$1": {{ "voice-command", "samsung" }} }, { "$1": {{ "shortcut-menu", "verizon" }} }, { "$1": {{ "speed", "motorola" }} }, { "$1": {{ "voice-command", "sprint" }} }, { "$1": {{ "speed", "motorola" }} }, { "$1": {{ "voice-clarity", "iphone" }} }, { "$1": {{ "platform", "samsung" }} }, { "$1": {{ "shortcut-menu", "t-mobile" }} }, { "$1": {{ "voicemail-service", "verizon" }} } ], "t2": [ { "$2": [ 19, 7, 5 ] } ], "t3": [ { "$3": [ 19, 7.5, 5 ] } ], "t4": [ { "$4": [ "John", 19, 7.5, 5 ] } ], "t5": [ { "$5": [ 3 ] } ], "t6": [ { "$6": null } ], "t7": [ { "$7": [  ] } ], "t8": [ {  } ], "t9": [ { "$9": null } ], "t10": [ {  }, { "$10": [ "Emily Jones", "John Green" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_sort/array_sort.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_sort/array_sort.3.adm
index cc5be40..330b8d1 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_sort/array_sort.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_sort/array_sort.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "customization", "t-mobile" }} }, { "$1": {{ "verizon", "voice-clarity" }} }, { "$1": {{ "iphone", "platform" }} }, { "$1": {{ "samsung", "voice-command" }} }, { "$1": {{ "shortcut-menu", "verizon" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "sprint", "voice-command" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "iphone", "voice-clarity" }} }, { "$1": {{ "platform", "samsung" }} }, { "$1": {{ "shortcut-menu", "t-mobile" }} }, { "$1": {{ "verizon", "voicemail-service" }} } ], "t2": [ 2, 5, 5, 7, 7, 19 ], "t3": [ 2, 5.0, 5, 5.1, 7, 7, 19 ], "t4": [ 5, 7.5, 19, "A", "John", "a", "a" ], "t5": [ null, null, null, 5, 7, 19 ], "t6": [ 3 ], "t7": null, "t8": [  ], "t10": null }
+{ "t1": [ { "$1": {{ "customization", "t-mobile" }} }, { "$1": {{ "verizon", "voice-clarity" }} }, { "$1": {{ "iphone", "platform" }} }, { "$1": {{ "samsung", "voice-command" }} }, { "$1": {{ "shortcut-menu", "verizon" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "sprint", "voice-command" }} }, { "$1": {{ "motorola", "speed" }} }, { "$1": {{ "iphone", "voice-clarity" }} }, { "$1": {{ "platform", "samsung" }} }, { "$1": {{ "shortcut-menu", "t-mobile" }} }, { "$1": {{ "verizon", "voicemail-service" }} } ], "t2": [ 2, 5, 5, 7, 7, 19 ], "t3": [ 2, 5.0, 5, 5.1, 7, 7, 19 ], "t4": [ 5, 7.5, 19, "A", "John", "a", "a" ], "t5": [ null, null, null, 5, 7, 19 ], "t6": [ 3 ], "t7": null, "t8": [  ], "t10": null, "t11": [ {  }, { "$2": [ "Abby", "Emily Jones", "John Green" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_star/array_star.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_star/array_star.3.adm
index 810a74f..fcb0d35 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_star/array_star.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_star/array_star.3.adm
@@ -1 +1 @@
-{ "t1": { "a": [ "a_val1", "a_val2", "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] }, "t2": { "compType": [ { "sth": 33 }, { "sth": 44 } ], "id": [ 1, 2 ] }, "t3": { "a": [ "a_val1", "a_val2", "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] }, "t4": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] }, "t5": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] }, "t6": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ], "c": [ null, null, "c_val3" ] }, "t7": { "a": [ 5, 3.2, "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ], "c": [ null, null, "c_val3" ] }, "t8": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", null, "b_val3" ] }, "t9": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", null, "b_val3" ] }, "t10": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", null, "b_val3" ] }, "t11": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", null, "b_val3" ] }, "t12": { "a": [ "a_val1", null, null ], "b": [ "b_val1", null, null ] }, "t17": null, "t19": null }
+{ "t1": { "a": [ "a_val1", "a_val2", "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] }, "t2": { "compType": [ { "sth": 33 }, { "sth": 44 } ], "followers": [ null, [ { "a": "a_val1", "b": "b_val1" }, { "a": "a_val2", "b": "b_val2" }, { "a": "a_val3", "b": "b_val3" } ] ], "id": [ 1, 2 ] }, "t3": { "a": [ "a_val1", "a_val2", "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] }, "t4": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] }, "t5": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] }, "t6": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ], "c": [ null, null, "c_val3" ] }, "t7": { "a": [ 5, 3.2, "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ], "c": [ null, null, "c_val3" ] }, "t8": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", null, "b_val3" ] }, "t9": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", null, "b_val3" ] }, "t10": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", null, "b_val3" ] }, "t11": { "a": [ "a_val1", null, "a_val3" ], "b": [ "b_val1", null, "b_val3" ] }, "t12": { "a": [ "a_val1", null, null ], "b": [ "b_val1", null, null ] }, "t17": null, "t19": null, "t20": [ {  }, { "$1": { "a": [ "a_val1", "a_val2", "a_val3" ], "b": [ "b_val1", "b_val2", "b_val3" ] } } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiff/array_symdiff.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiff/array_symdiff.3.adm
index 7fcf298..de24df1 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiff/array_symdiff.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiff/array_symdiff.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "platform", "customization", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "voice-clarity", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "t-mobile", "coffee-mobile", "iphone" }} }, { "$1": {{ "platform", "samsung", "t-mobile", "voice-command", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "shortcut-menu", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "platform", "motorola", "t-mobile", "speed", "coffee-mobile" }} }, { "$1": {{ "platform", "t-mobile", "voice-command", "coffee-mobile", "sprint" }} }, { "$1": {{ "platform", "motorola", "t-mobile", "speed", "coffee-mobile" }} }, { "$1": {{ "platform", "voice-clarity", "t-mobile", "coffee-mobile", "iphone" }} }, { "$1": {{ "samsung", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "platform", "shortcut-menu", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "voicemail-service", "t-mobile", "coffee-mobile" }} } ], "t2": [ { "$2": [ 2, "John", 4, 5 ] } ], "t3": [ 2, 7 ], "t4": [ 2, 7, 5.0 ], "t5": [ 2, 7, "a" ], "t6": [ 2, 7, "A" ], "t7": [ 1, 2, 7, null, "A" ], "t8": [ 1, 2, 7, null, null, "A" ], "t10": null, "t11": null, "t13": [  ], "t14": [ 3 ] }
+{ "t1": [ { "$1": {{ "platform", "customization", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "voice-clarity", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "t-mobile", "coffee-mobile", "iphone" }} }, { "$1": {{ "platform", "samsung", "t-mobile", "voice-command", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "shortcut-menu", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "platform", "motorola", "t-mobile", "speed", "coffee-mobile" }} }, { "$1": {{ "platform", "t-mobile", "voice-command", "coffee-mobile", "sprint" }} }, { "$1": {{ "platform", "motorola", "t-mobile", "speed", "coffee-mobile" }} }, { "$1": {{ "platform", "voice-clarity", "t-mobile", "coffee-mobile", "iphone" }} }, { "$1": {{ "samsung", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "platform", "shortcut-menu", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "voicemail-service", "t-mobile", "coffee-mobile" }} } ], "t2": [ { "$2": [ 2, "John", 4, 5 ] } ], "t3": [ 2, 7 ], "t4": [ 2, 7, 5.0 ], "t5": [ 2, 7, "a" ], "t6": [ 2, 7, "A" ], "t7": [ 1, 2, 7, null, "A" ], "t8": [ 1, 2, 7, null, null, "A" ], "t10": null, "t11": null, "t13": [  ], "t14": [ 3 ], "t15": [ {  }, { "$3": [ "John Green", "sth" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiffn/array_symdiffn.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiffn/array_symdiffn.3.adm
index 0692d62..c92cfd0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiffn/array_symdiffn.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiffn/array_symdiffn.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "platform", "customization", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "voice-clarity", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "t-mobile", "coffee-mobile", "iphone" }} }, { "$1": {{ "platform", "samsung", "t-mobile", "voice-command", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "shortcut-menu", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "platform", "motorola", "t-mobile", "speed", "coffee-mobile" }} }, { "$1": {{ "platform", "t-mobile", "voice-command", "coffee-mobile", "sprint" }} }, { "$1": {{ "platform", "motorola", "t-mobile", "speed", "coffee-mobile" }} }, { "$1": {{ "platform", "voice-clarity", "t-mobile", "coffee-mobile", "iphone" }} }, { "$1": {{ "samsung", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "platform", "shortcut-menu", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "voicemail-service", "t-mobile", "coffee-mobile" }} } ], "t2": [ { "$2": [ 2, "John", 4, 5 ] } ], "t3": [ 2, 7, 3 ], "t4": [ 2, 7, 5.0, 3 ], "t5": [ 2, 7, 3, "a" ], "t6": [ 2, 7, 3, "A" ], "t7": [ 1, 2, 7, null, "A" ], "t8": [ 1, 2, 7, null, null, "A" ], "t10": null, "t11": null, "t13": [  ], "t14": [ 3 ] }
+{ "t1": [ { "$1": {{ "platform", "customization", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "voice-clarity", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "t-mobile", "coffee-mobile", "iphone" }} }, { "$1": {{ "platform", "samsung", "t-mobile", "voice-command", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "shortcut-menu", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "platform", "motorola", "t-mobile", "speed", "coffee-mobile" }} }, { "$1": {{ "platform", "t-mobile", "voice-command", "coffee-mobile", "sprint" }} }, { "$1": {{ "platform", "motorola", "t-mobile", "speed", "coffee-mobile" }} }, { "$1": {{ "platform", "voice-clarity", "t-mobile", "coffee-mobile", "iphone" }} }, { "$1": {{ "samsung", "t-mobile", "coffee-mobile" }} }, { "$1": {{ "platform", "shortcut-menu", "coffee-mobile" }} }, { "$1": {{ "platform", "verizon", "voicemail-service", "t-mobile", "coffee-mobile" }} } ], "t2": [ { "$2": [ 2, "John", 4, 5 ] } ], "t3": [ 2, 7, 3 ], "t4": [ 2, 7, 5.0, 3 ], "t5": [ 2, 7, 3, "a" ], "t6": [ 2, 7, 3, "A" ], "t7": [ 1, 2, 7, null, "A" ], "t8": [ 1, 2, 7, null, null, "A" ], "t10": null, "t11": null, "t13": [  ], "t14": [ 3 ], "t15": [ {  }, { "$3": [ "John Green", 4, "sth", "sth2" ] } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_union/array_union.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_union/array_union.3.adm
index 7377c23..8d6ebf9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_union/array_union.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_union/array_union.3.adm
@@ -1 +1 @@
-{ "t1": [ { "$1": {{ "t-mobile", "customization", "platform" }} }, { "$1": {{ "verizon", "voice-clarity", "t-mobile", "platform" }} }, { "$1": {{ "iphone", "platform", "t-mobile" }} }, { "$1": {{ "samsung", "voice-command", "t-mobile", "platform" }} }, { "$1": {{ "verizon", "shortcut-menu", "t-mobile", "platform" }} }, { "$1": {{ "motorola", "speed", "t-mobile", "platform" }} }, { "$1": {{ "sprint", "voice-command", "t-mobile", "platform" }} }, { "$1": {{ "motorola", "speed", "t-mobile", "platform" }} }, { "$1": {{ "iphone", "voice-clarity", "t-mobile", "platform" }} }, { "$1": {{ "samsung", "platform", "t-mobile" }} }, { "$1": {{ "t-mobile", "shortcut-menu", "platform" }} }, { "$1": {{ "verizon", "voicemail-service", "t-mobile", "platform" }} } ], "t2": [ { "$2": [ 1, "John", 2, 4 ] } ], "t3": [ 3, 5, 1, 7, 2 ], "t4": [ 3, 5.0, 1, 7, 2 ], "t5": [ 3, "a", 1, 7, 2 ], "t6": [ 3, "a", 1, "A", 7, 2 ], "t7": [ 3, "a", null, "A", 7, null, 2, 1 ], "t8": [ 3, "a", null, "A", 7, 2, 1 ], "t9": [ 3, null, "a", null, "A", 7, 2, 1 ], "t10": [ 3, 5, 1, 7, 2 ], "t12": null, "t13": null, "t15": [  ], "t16": [ 3, 2 ] }
+{ "t1": [ { "$1": {{ "t-mobile", "customization", "platform" }} }, { "$1": {{ "verizon", "voice-clarity", "t-mobile", "platform" }} }, { "$1": {{ "iphone", "platform", "t-mobile" }} }, { "$1": {{ "samsung", "voice-command", "t-mobile", "platform" }} }, { "$1": {{ "verizon", "shortcut-menu", "t-mobile", "platform" }} }, { "$1": {{ "motorola", "speed", "t-mobile", "platform" }} }, { "$1": {{ "sprint", "voice-command", "t-mobile", "platform" }} }, { "$1": {{ "motorola", "speed", "t-mobile", "platform" }} }, { "$1": {{ "iphone", "voice-clarity", "t-mobile", "platform" }} }, { "$1": {{ "samsung", "platform", "t-mobile" }} }, { "$1": {{ "t-mobile", "shortcut-menu", "platform" }} }, { "$1": {{ "verizon", "voicemail-service", "t-mobile", "platform" }} } ], "t2": [ { "$2": [ 1, "John", 2, 4 ] } ], "t3": [ 3, 5, 1, 7, 2 ], "t4": [ 3, 5.0, 1, 7, 2 ], "t5": [ 3, "a", 1, 7, 2 ], "t6": [ 3, "a", 1, "A", 7, 2 ], "t7": [ 3, "a", null, "A", 7, null, 2, 1 ], "t8": [ 3, "a", null, "A", 7, 2, 1 ], "t9": [ 3, null, "a", null, "A", 7, 2, 1 ], "t10": [ 3, 5, 1, 7, 2 ], "t12": null, "t13": null, "t15": [  ], "t16": [ 3, 2 ], "t17": [ {  }, { "$3": [ "John Green", "Emily Jones", "sth", "1" ] } ] }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayAddRemoveEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayAddRemoveEval.java
index a7363ab..1100a59 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayAddRemoveEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayAddRemoveEval.java
@@ -152,7 +152,7 @@
             throw new RuntimeDataException(ErrorCode.CANNOT_COMPARE_COMPLEX, sourceLocation);
         }
         // all arguments are valid
-        AbstractCollectionType listType = (AbstractCollectionType) argTypes[listOffset];
+        AbstractCollectionType listType;
         IAsterixListBuilder listBuilder;
         // create the new list to be returned. cast the input list and make it open if required
         if (listArgTag == ATypeTag.ARRAY) {
@@ -160,20 +160,24 @@
                 orderedListBuilder = new OrderedListBuilder();
             }
             listBuilder = orderedListBuilder;
-            if (makeOpen) {
+            if (makeOpen || argTypes[listOffset].getTypeTag() != ATypeTag.ARRAY) {
                 listType = DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE;
                 caster.reset(listType, argTypes[listOffset], listArgEval);
                 caster.evaluate(tuple, listArg);
+            } else {
+                listType = (AbstractCollectionType) argTypes[listOffset];
             }
         } else {
             if (unorderedListBuilder == null) {
                 unorderedListBuilder = new UnorderedListBuilder();
             }
             listBuilder = unorderedListBuilder;
-            if (makeOpen) {
+            if (makeOpen || argTypes[listOffset].getTypeTag() != ATypeTag.MULTISET) {
                 listType = DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE;
                 caster.reset(listType, argTypes[listOffset], listArgEval);
                 caster.evaluate(tuple, listArg);
+            } else {
+                listType = (AbstractCollectionType) argTypes[listOffset];
             }
         }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayProcessArraysEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayProcessArraysEval.java
index 25adc7e..3258a8d 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayProcessArraysEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayProcessArraysEval.java
@@ -87,7 +87,6 @@
         boolean returnNull = false;
         AbstractCollectionType outList = null;
         ATypeTag listTag;
-        IAType defaultOpenType;
         for (int i = 0; i < listsEval.length; i++) {
             listsEval[i].evaluate(tuple, listsArgs[i]);
             if (!returnNull) {
@@ -101,8 +100,8 @@
                     if (outList == null) {
                         outList = (AbstractCollectionType) DefaultOpenFieldType.getDefaultOpenFieldType(listTag);
                     }
-                    defaultOpenType = DefaultOpenFieldType.getDefaultOpenFieldType(argTypes[i].getTypeTag());
-                    caster.reset(defaultOpenType, argTypes[i], listsEval[i]);
+
+                    caster.reset(outList, argTypes[i], listsEval[i]);
                     caster.evaluate(tuple, listsArgs[i]);
                 }
             }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java
index f84dee7..1540ecb 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java
@@ -39,14 +39,17 @@
 import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.functions.IFunctionTypeInferer;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.util.container.IObjectPool;
 import org.apache.asterix.om.util.container.ListObjectPool;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.asterix.runtime.evaluators.common.ListAccessor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
 import org.apache.asterix.runtime.utils.ArrayFunctionsUtil;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
@@ -64,12 +67,18 @@
 
 public class ArrayIntersectDescriptor extends AbstractScalarFunctionDynamicDescriptor {
     private static final long serialVersionUID = 1L;
+    private IAType[] argTypes;
 
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ArrayIntersectDescriptor();
         }
+
+        @Override
+        public IFunctionTypeInferer createFunctionTypeInferer() {
+            return FunctionTypeInferers.SET_ARGUMENTS_TYPE;
+        }
     };
 
     public class ValueListIndex implements IValueReference {
@@ -103,6 +112,11 @@
     }
 
     @Override
+    public void setImmutableStates(Object... states) {
+        argTypes = (IAType[]) states;
+    }
+
+    @Override
     public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
             throws AlgebricksException {
         return new IScalarEvaluatorFactory() {
@@ -125,6 +139,7 @@
         private final IObjectPool<IMutableValueStorage, ATypeTag> storageAllocator;
         private final IObjectPool<List<ValueListIndex>, ATypeTag> arrayListAllocator;
         private final ArrayBackedValueStorage finalResult;
+        private final CastTypeEvaluator caster;
         private IAsterixListBuilder orderedListBuilder;
         private IAsterixListBuilder unorderedListBuilder;
 
@@ -137,6 +152,7 @@
             hashes = new Int2ObjectOpenHashMap<>();
             finalResult = new ArrayBackedValueStorage();
             listAccessor = new ListAccessor();
+            caster = new CastTypeEvaluator();
             listsArgs = new IPointable[args.length];
             listsEval = new IScalarEvaluator[args.length];
             for (int i = 0; i < args.length; i++) {
@@ -158,6 +174,7 @@
             int nextSize;
             IScalarEvaluator listEval;
             IPointable listArg;
+
             // evaluate all the lists first to make sure they're all actually lists and of the same list type
             for (int i = 0; i < listsEval.length; i++) {
                 listEval = listsEval[i];
@@ -175,6 +192,8 @@
                             outList = (AbstractCollectionType) DefaultOpenFieldType.getDefaultOpenFieldType(listTag);
                         }
 
+                        caster.reset(outList, argTypes[i], listsEval[i]);
+                        caster.evaluate(tuple, listsArgs[i]);
                         nextSize = getNumItems(outList, listArg.getByteArray(), listArg.getStartOffset());
                         if (nextSize < minSize) {
                             minSize = nextSize;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java
index 217490b..2c4c308 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java
@@ -143,8 +143,7 @@
                 return;
             }
 
-            IAType openListType = DefaultOpenFieldType.getDefaultOpenFieldType(inputListType.getTypeTag());
-            caster.reset(openListType, inputListType, listEval);
+            caster.reset(DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE, inputListType, listEval);
             caster.evaluate(tuple, list);
 
             fieldNameToValues.clear();