Ali Alsuliman has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/3173

Change subject: [ASTERIXDB-2516][RT] add support for array deep comparison
......................................................................

[ASTERIXDB-2516][RT] add support for array deep comparison

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

Details:
Add support for array deep comparison.
- modified LogicalComplexBinaryComparator.java to allow array comparison
- added test cases for array comparison
- changed interface IObjectPool.java to allow freeing a specific object

Change-Id: I2fef48d7c6189362f44786b8d89d89c5f91d4b10
---
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.001.ddl.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.002.update.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.003.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.004.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.005.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.006.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.007.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.008.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.009.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.010.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.011.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.012.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.013.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.014.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.015.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.016.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.017.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.018.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.019.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.020.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.021.ddl.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.003.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.004.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.005.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.006.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.007.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.008.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.009.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.010.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.011.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.012.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.013.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.014.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.015.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.016.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.017.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.018.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.019.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.020.adm
M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
M 
asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java
A 
asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ListAccessorUtil.java
M 
asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java
M 
asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/IObjectPool.java
M 
asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/ListObjectPool.java
45 files changed, 1,164 insertions(+), 11 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/73/3173/1

diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.001.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.001.ddl.sqlpp
new file mode 100644
index 0000000..1b3414c
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.001.ddl.sqlpp
@@ -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.
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+use test;
+
+create type openType as {id:int, arrayF1:[int]?};
+create type closedType as closed {id:int, arrayF1:[int], arrayF2:[string]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.002.update.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.002.update.sqlpp
new file mode 100644
index 0000000..f7b8fd1
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.002.update.sqlpp
@@ -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.
+ */
+
+use test;
+
+insert into openDs([
+{"id":1 ,"arrayF1":[5,1,4] ,"arrayF2":["green", "black", "white"]},
+{"id":2 ,"arrayF1":[1,3] ,"arrayF2":[1.0, "sql++"]},
+{"id":3 ,"arrayF1":[6,2,1,4] ,"arrayF2":[missing,3,3]},
+{"id":4 ,"arrayF1":null ,"arrayF2":[[1,5,6], [9,4,1]]},
+{"id":5 ,"arrayF1":[1,3,1] ,"arrayF2":[[4,4], ["orange", "purple"], 99]},
+{"id":6 ,"arrayF1":null ,"arrayF2":null},
+{"id":7 ,"arrayF1":[0]},
+{"id":8 ,"arrayF1":[] ,"arrayF2":[ [[[88,99], [100,111]]], [11,12] ]},
+{"id":9 ,"arrayF1":[3] ,"arrayF2":56},
+{"id":10 ,"arrayF1":[6,2,1,4] ,"arrayF2":["green", "black", "white"]}
+]);
+
+insert into closedDs([
+{"id":1 ,"arrayF1":[3,3,3] ,"arrayF2":["aaa", "bb"]},
+{"id":2 ,"arrayF1":[7,1,2,1] ,"arrayF2":["zzz", "low"]},
+{"id":3 ,"arrayF1":[9,4,1,4,1,5] ,"arrayF2":["coin", "dollar"]},
+{"id":4 ,"arrayF1":[0,-1,-2] ,"arrayF2":["football", "soccer", "basketball"]},
+{"id":5 ,"arrayF1":[-0,3,1] ,"arrayF2":["black", "green", "white"]},
+{"id":6 ,"arrayF1":[3,-5,-11] ,"arrayF2":["python", "java", "Go"]},
+{"id":7 ,"arrayF1":[-7,99] ,"arrayF2":["sql++", "sql++"]},
+{"id":8 ,"arrayF1":[-111,222] ,"arrayF2":["steve"]},
+{"id":9 ,"arrayF1":[] ,"arrayF2":[]},
+{"id":10 ,"arrayF1":[3,3,3] ,"arrayF2":["python", "java", "Go"]}
+]);
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.003.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.003.query.sqlpp
new file mode 100644
index 0000000..6833339
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.003.query.sqlpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+// basic number comparisons
+
+use test;
+
+from
+[
+  {"c": "[1,2] = [1,2]", "r": [1,2] = [1,2]},
+  {"c": "[1,2] < [1,2]", "r": [1,2] < [1,2]},
+  {"c": "[1,2] <= [1,2]", "r": [1,2] <= [1,2]},
+  {"c": "[1,2] >= [1,2]", "r": [1,2] >= [1,2]},
+  {"c": "[1,2] > [1,2]", "r": [1,2] > [1,2]},
+  {"c": "[1,2] != [1,2]", "r": [1,2] != [1,2]},
+  {"c": "[2,1] = [1,2]", "r": [2,1] = [1,2]},
+  {"c": "[2,1] < [1,2]", "r": [2,1] < [1,2]},
+  {"c": "[2,1] <= [1,2]", "r": [2,1] <= [1,2]},
+  {"c": "[2,1] >= [1,2]", "r": [2,1] >= [1,2]},
+  {"c": "[2,1] > [1,2]", "r": [2,1] > [1,2]},
+  {"c": "[2,1] != [1,2]", "r": [2,1] != [1,2]},
+  {"c": "[1,2,3] = [1,2]", "r": [1,2,3] = [1,2]},
+  {"c": "[1,2,3] < [1,2]", "r": [1,2,3] < [1,2]},
+  {"c": "[1,2,3] <= [1,2]", "r": [1,2,3] <= [1,2]},
+  {"c": "[1,2,3] >= [1,2]", "r": [1,2,3] >= [1,2]},
+  {"c": "[1,2,3] > [1,2]", "r": [1,2,3] > [1,2]},
+  {"c": "[1,2,3] != [1,2]", "r": [1,2,3] != [1,2]},
+  {"c": "[2,1,3] = [1,2]", "r": [2,1,3] = [1,2]},
+  {"c": "[2,1,3] < [1,2]", "r": [2,1,3] < [1,2]},
+  {"c": "[2,1,3] <= [1,2]", "r": [2,1,3] <= [1,2]},
+  {"c": "[2,1,3] >= [1,2]", "r": [2,1,3] >= [1,2]},
+  {"c": "[2,1,3] > [1,2]", "r": [2,1,3] > [1,2]},
+  {"c": "[2,1,3] != [1,2]", "r": [2,1,3] != [1,2]},
+  {"c": "[1,2] = [1,2,3]", "r": [1,2] = [1,2,3]},
+  {"c": "[1,2] < [1,2,3]", "r": [1,2] < [1,2,3]},
+  {"c": "[1,2] <= [1,2,3]", "r": [1,2] <= [1,2,3]},
+  {"c": "[1,2] >= [1,2,3]", "r": [1,2] >= [1,2,3]},
+  {"c": "[1,2] > [1,2,3]", "r": [1,2] > [1,2,3]},
+  {"c": "[1,2] != [1,2,3]", "r": [1,2] != [1,2,3]},
+  {"c": "[1,2,3,4,5,6] = [1,2,3,4,5,6]", "r": [1,2,3,4,5,6] = [1,2,3,4,5,6]},
+  {"c": "[1,2,3,4,5,5] = [1,2,3,4,5,6]", "r": [1,2,3,4,5,5] = [1,2,3,4,5,6]}
+] as v select value v;
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.004.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.004.query.sqlpp
new file mode 100644
index 0000000..641f07b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.004.query.sqlpp
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+// other types basic comparisons
+
+use test;
+
+{"c": "[tinyint('1'),tinyint('2')] = [tinyint('1'),tinyint('2')]", "r": 
[tinyint('1'),tinyint('2')] = [tinyint('1'),tinyint('2')]};
+{"c": "['a','b','c'] = ['a','b','c']", "r": ['a','b','c'] = ['a','b','c']};
+{"c": "['A','b','c'] = ['a','b','c']", "r": ['A','b','c'] = ['a','b','c']};
+{"c": "['a','b','c'] < ['a','b','d']", "r": ['a','b','c'] < ['a','b','d']};
+{"c": "['blue', 'black', 'orange'] < ['purple', 'green']", "r": ['blue', 
'black', 'orange'] < ['purple', 'green']};
+{"c": "['blue', 'black', 'orange'] > ['purple', 'green']", "r": ['blue', 
'black', 'orange'] > ['purple', 'green']};
+{"c": "['blue', 'black', 'orange'] >= ['blue', 'black', 'orange']", "r": 
['blue', 'black', 'orange'] >= ['blue', 'black', 'orange']};
+{"c": "[true] > [false]", "r": [true] > [false]};
+{"c": "[true, false, true] = [true, false, true]", "r": [true, false, true] = 
[true, false, true]};
+{"c": "[true, false, false] >= [true, true]", "r": [true, false, false] >= 
[true, true]};
+{"c": "[point('23.22,30.50'), point('-13.22,30.50')] = [point('23.22,30.50'), 
point('-13.22,30.50')]",
+"r": [point('23.22,30.50'), point('-13.22,30.50')] = [point('23.22,30.50'), 
point('-13.22,30.50')]};
+
+{"c": "[point('23.22,30.50'), point('-13.22,30.50')] <= [point('23.22,30.50'), 
point('-13.22,30.50')]",
+"r": [point('23.22,30.50'), point('-13.22,30.50')] <= [point('23.22,30.50'), 
point('-13.22,30.50')]};
+
+{"c":"[line('10.1234,11.1e-1 +10.2E-2,-11.22'), line('0.1234,-1.00e-10 
+10.5E-2,-01.02')] != [line('10.1234,11.1e-1 +10.2E-2,-11.22'), 
line('0.1234,-1.00e-10 +10.5E-2,-01.02')]",
+"r": [line('10.1234,11.1e-1 +10.2E-2,-11.22'), line('0.1234,-1.00e-10 
+10.5E-2,-01.02')] != [line('10.1234,11.1e-1 +10.2E-2,-11.22'), 
line('0.1234,-1.00e-10 +10.5E-2,-01.02')]};
+
+{"c":"[line('10.1234,11.1e-1 +10.2E-2,-11.22'), line('0.1234,-1.00e-10 
+10.5E-2,-01.02')] > [line('10.1234,11.1e-1 +10.2E-2,-11.22'), 
line('0.1234,-1.00e-10 +10.5E-2,-01.02')]",
+"r": [line('10.1234,11.1e-1 +10.2E-2,-11.22'), line('0.1234,-1.00e-10 
+10.5E-2,-01.02')] > [line('10.1234,11.1e-1 +10.2E-2,-11.22'), 
line('0.1234,-1.00e-10 +10.5E-2,-01.02')]};
+
+{"c": "[rectangle('5.1,11.8 87.6,15.6548'), rectangle('0.1234,-1.00e-10 
5.5487,0.48765')] = [rectangle('5.1,11.8 87.6,15.6548'), 
rectangle('0.1234,-1.00e-10 5.5487,0.48765')]",
+"r": [rectangle('5.1,11.8 87.6,15.6548'), rectangle('0.1234,-1.00e-10 
5.5487,0.48765')] = [rectangle('5.1,11.8 87.6,15.6548'), 
rectangle('0.1234,-1.00e-10 5.5487,0.48765')]};
+
+{"c": "[rectangle('5.1,11.8 87.6,15.6548'), rectangle('0.1234,-1.00e-10 
5.5487,0.48765')] < [rectangle('5.1,11.8 87.6,15.6548'), 
rectangle('0.1234,-1.00e-10 5.5487,0.48765')]",
+"r":[rectangle('5.1,11.8 87.6,15.6548'), rectangle('0.1234,-1.00e-10 
5.5487,0.48765')] < [rectangle('5.1,11.8 87.6,15.6548'), 
rectangle('0.1234,-1.00e-10 5.5487,0.48765')]};
+
+{"c": "[circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 
+10.5E-2')] = [circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 
+10.5E-2')]",
+"r": [circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 +10.5E-2')] 
= [circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 +10.5E-2')]};
+
+{"c": "[circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 
+10.5E-2')] <= [circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 
+10.5E-2')]",
+"r": [circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 +10.5E-2')] 
<= [circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 +10.5E-2')]};
+
+{"c": "[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')] != 
[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')]",
+"r": [polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')] != 
[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')]};
+
+{"c":"[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')] >= 
[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')]",
+"r":[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')] >= 
[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')]};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.005.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.005.query.sqlpp
new file mode 100644
index 0000000..3ea0245
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.005.query.sqlpp
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+// other types basic comparisons
+
+use test;
+
+{"c": "[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')] = 
[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')]",
+"r": [point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')] = 
[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')]};
+
+{"c":"[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')] > 
[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')]",
+"r": [point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')] > 
[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')]};
+
+{"c":"[duration('P100Y12MT12M'), duration('-PT20.943S')] = 
[duration('P100Y12MT12M'), duration('-PT20.943S')]",
+"r":[duration('P100Y12MT12M'), duration('-PT20.943S')] = 
[duration('P100Y12MT12M'), duration('-PT20.943S')]};
+
+{"c": "[duration('P100Y12MT12M'), duration('-PT20.943S')] <= 
[duration('P100Y12MT12M'), duration('-PT20.943S')]",
+"r":[duration('P100Y12MT12M'), duration('-PT20.943S')] <= 
[duration('P100Y12MT12M'), duration('-PT20.943S')]};
+
+{"c":"[year_month_duration('P100Y'), year_month_duration('P200Y')] = 
[year_month_duration('P100Y'), year_month_duration('P200Y')]",
+"r": [year_month_duration('P100Y'), year_month_duration('P200Y')] = 
[year_month_duration('P100Y'), year_month_duration('P200Y')]};
+
+{"c":"[year_month_duration('P100Y'), year_month_duration('P200Y')] < 
[year_month_duration('P150Y'), year_month_duration('P200Y')]",
+"r": [year_month_duration('P100Y'), year_month_duration('P200Y')] < 
[year_month_duration('P150Y'), year_month_duration('P200Y')]};
+
+{"c":"[day_time_duration('PT30M'), day_time_duration('PT10M')] = 
[day_time_duration('PT30M'), day_time_duration('PT10M')]",
+"r": [day_time_duration('PT30M'), day_time_duration('PT10M')] = 
[day_time_duration('PT30M'), day_time_duration('PT10M')]};
+
+{"c":"[day_time_duration('PT40M'), day_time_duration('PT10M')] > 
[day_time_duration('PT30M'), day_time_duration('PT10M')]",
+"r":[day_time_duration('PT40M'), day_time_duration('PT10M')] > 
[day_time_duration('PT30M'), day_time_duration('PT10M')]};
+
+{"c":"[interval(date('2013-01-01'), date('20130505')), 
interval(date('2012-01-01'), date('20130505'))] = [interval(date('2013-01-01'), 
date('20130505')), interval(date('2012-01-01'), date('20130505'))]",
+"r": [interval(date('2013-01-01'), date('20130505')), 
interval(date('2012-01-01'), date('20130505'))] = [interval(date('2013-01-01'), 
date('20130505')), interval(date('2012-01-01'), date('20130505'))]};
+
+{"c":"[interval(date('2013-01-01'), date('20130505')), 
interval(date('2012-01-01'), date('20130505'))] < [interval(date('2013-01-01'), 
date('20130505')), interval(date('2012-01-01'), date('20130505'))]",
+"r":[interval(date('2013-01-01'), date('20130505')), 
interval(date('2012-01-01'), date('20130505'))] < [interval(date('2013-01-01'), 
date('20130505')), interval(date('2012-01-01'), date('20130505'))]};
+
+{"c":"[date('2013-01-01'), date('2014-01-01')] < [date('2016-01-01'), 
date('2014-01-01')]",
+"r":[date('2013-01-01'), date('2014-01-01')] < [date('2016-01-01'), 
date('2014-01-01')]};
+
+{"c":"[time('12:12:12.039Z'), time('10:12:12.039Z')] > [time('11:12:12.039Z'), 
time('10:12:12.039Z')]",
+"r":[time('12:12:12.039Z'), time('10:12:12.039Z')] > [time('11:12:12.039Z'), 
time('10:12:12.039Z')]};
+
+{"c":"[datetime('2013-01-01T12:12:12.039Z'), 
datetime('-19700101T000000000-0800')] = [datetime('2013-01-01T12:12:12.039Z'), 
datetime('-19700101T000000000-0800')]",
+"r":[datetime('2013-01-01T12:12:12.039Z'), 
datetime('-19700101T000000000-0800')] = [datetime('2013-01-01T12:12:12.039Z'), 
datetime('-19700101T000000000-0800')]};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.006.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.006.query.sqlpp
new file mode 100644
index 0000000..7f1d633
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.006.query.sqlpp
@@ -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.
+ */
+
+// mixed types
+
+use test;
+
+{"c":"[smallint('23'), 2] = [23, float('2')]", "r":[smallint('23'), 2] = [23, 
float('2')]};
+{"c":"['green', 2, date('2013-01-01'), 'blue'] = ['green', double('2'), 
date('2013-01-01'), 'blue']",
+"r":['green', 2, date('2013-01-01'), 'blue'] = ['green', double('2'), 
date('2013-01-01'), 'blue']};
+
+{"c":"[1,point('23.22,30.50'), 3] < [1,point('23.22,30.50'),4]", 
"r":[1,point('23.22,30.50'), 3] < [1,point('23.22,30.50'),4]};
+{"c":"['black', int('4'), float('3.3')] > ['black', bigint('4')]", 
"r":['black', int('4'), float('3.3')] > ['black', bigint('4')]};
+{"c":"['red', null] < ['red', null]", "r":['red', null] < ['red', null]};
+{"c":"[missing,2] < [null,3]", "r":[missing,2] < [null,3]};
+{"c":"[1,2] < [1,2,missing]", "r":[1,2] < [1,2,missing]};
+{"c":"[1,2] < [1,2,null]", "r":[1,2] < [1,2,null]};
+{"c":"[null,5] >= [null,5]", "r":[null,5] >= [null,5]};
+{"c":"[null,8] < [4, 9]", "r":[null,8] < [4, 9]};
+{"c":"[1,2,missing] != [1,2,missing]", "r":[1,2,missing] != [1,2,missing]};
+{"c":"['joe',3] > [7,'james']", "r":['joe',3] > [7,'james']};
+{"c":"[] = []", "r":[] = []};
+{"c":"[] != []", "r":[] != []};
+{"c":"[] > []", "r":[] > []};
+{"c":"[] < []", "r":[] < []};
+{"c":"[] < [1,3]", "r":[] < [1,3]};
+{"c":"[] > [1,3]", "r":[] > [1,3]};
+{"c":"[8] = 8", "r":[8] = 8};
+{"c":"[9,2] > null", "r":[9,2] > null};
+{"c":"[9,2] > missing", "r":[9,2] > missing};
+{"c":"[null,1] = [1,1,3]", "r":[null,1] = [1,1,3]};
+{"c":"[null,1] != [1,1,3]", "r":[null,1] != [1,1,3]};
+{"c":"[null,1] > [1,1,3]", "r":[null,1] > [1,1,3]};
+{"c":"[1,point('23.22,30.50'), 3] = [1,point('23.22,30.50'),3]", 
"r":[1,point('23.22,30.50'), 3] = [1,point('23.22,30.50'),3]};
+{"c":"[true, 'steve', 12.0] != [1, 'mat']", "r": [true, "steve", 12.0] != [1, 
"mat"]};
+{"c":"[null, null, null] = [null, null, null]", "r": [null, null, null] = 
[null, null, null]};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.007.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.007.query.sqlpp
new file mode 100644
index 0000000..d6c4a4a
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.007.query.sqlpp
@@ -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.
+ */
+
+// nesting
+
+use test;
+
+{"c":"[[1.0,4], [5,9,11,14]] = [[1.0,4], [5,9,11,14]]", "r":[[1.0,4], 
[5,9,11,14]] = [[1.0,4], [5,9,11,14]]};
+{"c":"[[5,2,7], ['green','black'], [date('2013-01-01')]] = [[5,2,7], 
['green','black'], [date('2013-01-01')]]",
+"r":[[5,2,7], ["green","black"], [date('2013-01-01')]] = [[5,2,7], 
["green","black"], [date('2013-01-01')]]};
+
+{"c":"[['white','yellow','brown'], 6] != [['white','yellow','brown'], 
double('6')]",
+"r":[["white","yellow","brown"], 6] != [["white","yellow","brown"], 
double('6')]};
+
+{"c":"[['white','yellow','brown'], 6] != [double('6'), 
['white','yellow','brown']]",
+"r":[["white","yellow","brown"], 6] != [double('6'), 
["white","yellow","brown"]]};
+
+{"c":"[ [[1,2,3], 'gold', ['sql++', 5]], [tinyint('4'), tinyint('5')], 
smallint('2')] > [ [[1,2,3], 'gold', ['sql++', 5]], [bigint('4'), int('5')], 
double('0.2')]",
+"r":[ [[1,2,3], 'gold', ['sql++', 5]], [tinyint('4'), tinyint('5')], 
smallint('2')] > [ [[1,2,3], 'gold', ['sql++', 5]], [bigint('4'), int('5')], 
double('0.2')]};
+
+{"c":"[[[1,2], 99], 77] <= [[['flute',2], 99], 77]", "r":[[[1,2], 99], 77] <= 
[[['flute',2], 99], 77]};
+{"c":"[[[1,2], 99], 77] <= [[[missing,2], 99], 77]", "r":[[[1,2], 99], 77] <= 
[[[missing,2], 99], 77]};
+{"c":"[5, [8,1], [[0, 4], 'b']] > [5, [8,1], [[0, 4], 'a', 'c']]", "r":[5, 
[8,1], [[0, 4], 'b']] > [5, [8,1], [[0, 4], 'a', 'c']]};
+
+// mismatch
+{"c":"[1,2] = {{1,2}}", "r":[1,2] = {{1,2}} };
+{"c":"{'id':99, 'name':'sam'} != [99, 'sam']", "r": {"id":99, "name":"sam"} != 
[99, 'sam']};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.008.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.008.query.sqlpp
new file mode 100644
index 0000000..8fbfc42
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.008.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+let con = [1,2]
+where t.arrayF1 > con
+select value {"id": t.id, "array1": t.arrayF1, "OP": ">", "array2": con}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.009.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.009.query.sqlpp
new file mode 100644
index 0000000..c8fc3ad
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.009.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+where t.arrayF1 < [1,2]
+select value {"id": t.id, "array1": t.arrayF1, "OP": "<", "array2": [1,2]}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.010.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.010.query.sqlpp
new file mode 100644
index 0000000..ee334bc
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.010.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+let con = [6,2,1,4]
+where t.arrayF1 = con
+select value {"id": t.id, "array1": t.arrayF1, "OP": "=", "array2": con}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.011.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.011.query.sqlpp
new file mode 100644
index 0000000..546bf80
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.011.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+let con = [1,2]
+where is_null(t.arrayF1 > con)
+select value {"id": t.id, "array1": t.arrayF1, "OP": "> is_null", "array2": 
con}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.012.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.012.query.sqlpp
new file mode 100644
index 0000000..fd4069b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.012.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+let con = [[1,5,6], [9,555,1]]
+where con > t.arrayF2
+select value {"id": t.id, "array1": con, "OP": ">", "array2": t.arrayF2}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.013.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.013.query.sqlpp
new file mode 100644
index 0000000..7798720
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.013.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+let con = ["green", "black", "white"], con2 = [1,4]
+where con = t.arrayF2 OR t.arrayF1 < con2
+select value t
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.014.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.014.query.sqlpp
new file mode 100644
index 0000000..8bdabdc
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.014.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+where is_missing([2,1] < t.arrayF2)
+select value {"id": t.id, "array1": [2,1], "OP": "< is_missing", "array2": 
t.arrayF2}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.015.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.015.query.sqlpp
new file mode 100644
index 0000000..8e37d48
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.015.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+where is_null([1.0, "sql++"] = t.arrayF2)
+select value {"id": t.id, "array1": [1.0, "sql++"], "OP": "= is_null", 
"array2": t.arrayF2}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.016.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.016.query.sqlpp
new file mode 100644
index 0000000..c809675
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.016.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from openDs t
+where is_null([1.0, "sql++"] > t.arrayF2)
+select value {"id": t.id, "array1": [1.0, "sql++"], "OP": "> is_null", 
"array2": t.arrayF2}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.017.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.017.query.sqlpp
new file mode 100644
index 0000000..8b7d97c
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.017.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from closedDs t
+where t.arrayF1 = [double('0'),-1,-2]
+select value {"id": t.id, "array1": t.arrayF1, "OP": "=", "array2": 
[double('0'),-1,-2]}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.018.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.018.query.sqlpp
new file mode 100644
index 0000000..2920456
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.018.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from closedDs t
+where t.arrayF1 < [1,2]
+select value {"id": t.id, "array1": t.arrayF1, "OP": "<", "array2": [1,2]}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.019.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.019.query.sqlpp
new file mode 100644
index 0000000..e531e52
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.019.query.sqlpp
@@ -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.
+ */
+
+// from dataset
+
+use test;
+
+from closedDs t
+let con = ["coin", "dollar", "bill"]
+where t.arrayF2 > con
+select value {"id": t.id, "array1": t.arrayF2, "OP": ">", "array2": con}
+order by t.id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.020.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.020.query.sqlpp
new file mode 100644
index 0000000..56f52ee
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.020.query.sqlpp
@@ -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.
+ */
+
+// floating-points
+
+use test;
+
+{"c": "[0,1] = [double('0'), float('1')]", "r":[0,1] = [double('0'), 
float('1')]};
+{"c": "[-0, -1] = [float('-0'), -1]", "r": [-0, -1] = [float('-0'), -1]};
+
+{"c":"[double('INF')] > [0]", "r":[double('INF')] > [0]};
+{"c":"[double('-INF')] < [0]", "r":[double('-INF')] < [0]};
+{"c":"[double('INF')] > [-0]", "r":[double('INF')] > [-0]};
+{"c":"[double('-INF')] < [-0]", "r":[double('-INF')] < [-0]};
+{"c":"[double('INF')] > [double('-0')]", "r":[double('INF')] > [double('-0')]};
+{"c":"[double('-INF')] < [double('-0')]", "r":[double('-INF')] < 
[double('-0')]};
+
+{"c":"[double('NaN')] > [0]", "r":[double('NaN')] > [0]};
+{"c":"[double('NaN')] < [0]", "r":[double('NaN')] < [0]};
+{"c":"[double('NaN')] > [-0]", "r":[double('NaN')] > [-0]};
+{"c":"[double('NaN')] < [-0]", "r":[double('NaN')] < [-0]};
+{"c":"[double('NaN')] > [double('-0')]", "r":[double('NaN')] > [double('-0')]};
+{"c":"[double('NaN')] < [double('-0')]", "r":[double('NaN')] < [double('-0')]};
+
+{"c":"[double('-INF')] < [double('INF')]", "r":[double('-INF')] < 
[double('INF')]};
+
+{"c":"[double('INF')] > [double('NaN')]", "r":[double('INF')] > 
[double('NaN')]};
+{"c":"[double('-INF')] < [double('NaN')]", "r":[double('-INF')] < 
[double('NaN')]};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.021.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.021.ddl.sqlpp
new file mode 100644
index 0000000..ff41019
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.021.ddl.sqlpp
@@ -0,0 +1,20 @@
+/*
+ * 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;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.003.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.003.adm
new file mode 100644
index 0000000..313f0c8
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.003.adm
@@ -0,0 +1,32 @@
+{ "c": "[1,2] = [1,2]", "r": true }
+{ "c": "[1,2] < [1,2]", "r": false }
+{ "c": "[1,2] <= [1,2]", "r": true }
+{ "c": "[1,2] >= [1,2]", "r": true }
+{ "c": "[1,2] > [1,2]", "r": false }
+{ "c": "[1,2] != [1,2]", "r": false }
+{ "c": "[2,1] = [1,2]", "r": false }
+{ "c": "[2,1] < [1,2]", "r": false }
+{ "c": "[2,1] <= [1,2]", "r": false }
+{ "c": "[2,1] >= [1,2]", "r": true }
+{ "c": "[2,1] > [1,2]", "r": true }
+{ "c": "[2,1] != [1,2]", "r": true }
+{ "c": "[1,2,3] = [1,2]", "r": false }
+{ "c": "[1,2,3] < [1,2]", "r": false }
+{ "c": "[1,2,3] <= [1,2]", "r": false }
+{ "c": "[1,2,3] >= [1,2]", "r": true }
+{ "c": "[1,2,3] > [1,2]", "r": true }
+{ "c": "[1,2,3] != [1,2]", "r": true }
+{ "c": "[2,1,3] = [1,2]", "r": false }
+{ "c": "[2,1,3] < [1,2]", "r": false }
+{ "c": "[2,1,3] <= [1,2]", "r": false }
+{ "c": "[2,1,3] >= [1,2]", "r": true }
+{ "c": "[2,1,3] > [1,2]", "r": true }
+{ "c": "[2,1,3] != [1,2]", "r": true }
+{ "c": "[1,2] = [1,2,3]", "r": false }
+{ "c": "[1,2] < [1,2,3]", "r": true }
+{ "c": "[1,2] <= [1,2,3]", "r": true }
+{ "c": "[1,2] >= [1,2,3]", "r": false }
+{ "c": "[1,2] > [1,2,3]", "r": false }
+{ "c": "[1,2] != [1,2,3]", "r": true }
+{ "c": "[1,2,3,4,5,6] = [1,2,3,4,5,6]", "r": true }
+{ "c": "[1,2,3,4,5,5] = [1,2,3,4,5,6]", "r": false }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.004.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.004.adm
new file mode 100644
index 0000000..1536975
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.004.adm
@@ -0,0 +1,20 @@
+{ "c": "[tinyint('1'),tinyint('2')] = [tinyint('1'),tinyint('2')]", "r": true }
+{ "c": "['a','b','c'] = ['a','b','c']", "r": true }
+{ "c": "['A','b','c'] = ['a','b','c']", "r": false }
+{ "c": "['a','b','c'] < ['a','b','d']", "r": true }
+{ "c": "['blue', 'black', 'orange'] < ['purple', 'green']", "r": true }
+{ "c": "['blue', 'black', 'orange'] > ['purple', 'green']", "r": false }
+{ "c": "['blue', 'black', 'orange'] >= ['blue', 'black', 'orange']", "r": true 
}
+{ "c": "[true] > [false]", "r": true }
+{ "c": "[true, false, true] = [true, false, true]", "r": true }
+{ "c": "[true, false, false] >= [true, true]", "r": false }
+{ "c": "[point('23.22,30.50'), point('-13.22,30.50')] = [point('23.22,30.50'), 
point('-13.22,30.50')]", "r": true }
+{ "c": "[point('23.22,30.50'), point('-13.22,30.50')] <= 
[point('23.22,30.50'), point('-13.22,30.50')]", "r": null }
+{ "c": "[line('10.1234,11.1e-1 +10.2E-2,-11.22'), line('0.1234,-1.00e-10 
+10.5E-2,-01.02')] != [line('10.1234,11.1e-1 +10.2E-2,-11.22'), 
line('0.1234,-1.00e-10 +10.5E-2,-01.02')]", "r": false }
+{ "c": "[line('10.1234,11.1e-1 +10.2E-2,-11.22'), line('0.1234,-1.00e-10 
+10.5E-2,-01.02')] > [line('10.1234,11.1e-1 +10.2E-2,-11.22'), 
line('0.1234,-1.00e-10 +10.5E-2,-01.02')]", "r": null }
+{ "c": "[rectangle('5.1,11.8 87.6,15.6548'), rectangle('0.1234,-1.00e-10 
5.5487,0.48765')] = [rectangle('5.1,11.8 87.6,15.6548'), 
rectangle('0.1234,-1.00e-10 5.5487,0.48765')]", "r": true }
+{ "c": "[rectangle('5.1,11.8 87.6,15.6548'), rectangle('0.1234,-1.00e-10 
5.5487,0.48765')] < [rectangle('5.1,11.8 87.6,15.6548'), 
rectangle('0.1234,-1.00e-10 5.5487,0.48765')]", "r": null }
+{ "c": "[circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 
+10.5E-2')] = [circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 
+10.5E-2')]", "r": true }
+{ "c": "[circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 
+10.5E-2')] <= [circle('10.1234,11.1e-1 +10.2E-2'), circle('0.1234,-1.00e-10 
+10.5E-2')]", "r": null }
+{ "c": "[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')] != 
[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')]", "r": false }
+{ "c": "[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')] >= 
[polygon('-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81'), 
polygon('9.9,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81')]", "r": null }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.005.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.005.adm
new file mode 100644
index 0000000..eb35fdb
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.005.adm
@@ -0,0 +1,13 @@
+{ "c": "[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')] = 
[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')]", "r": true }
+{ "c": "[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')] > 
[point3d('44.0,13.0,41.0'), point3d('11.0,22.55,77.98')]", "r": null }
+{ "c": "[duration('P100Y12MT12M'), duration('-PT20.943S')] = 
[duration('P100Y12MT12M'), duration('-PT20.943S')]", "r": true }
+{ "c": "[duration('P100Y12MT12M'), duration('-PT20.943S')] <= 
[duration('P100Y12MT12M'), duration('-PT20.943S')]", "r": null }
+{ "c": "[year_month_duration('P100Y'), year_month_duration('P200Y')] = 
[year_month_duration('P100Y'), year_month_duration('P200Y')]", "r": true }
+{ "c": "[year_month_duration('P100Y'), year_month_duration('P200Y')] < 
[year_month_duration('P150Y'), year_month_duration('P200Y')]", "r": true }
+{ "c": "[day_time_duration('PT30M'), day_time_duration('PT10M')] = 
[day_time_duration('PT30M'), day_time_duration('PT10M')]", "r": true }
+{ "c": "[day_time_duration('PT40M'), day_time_duration('PT10M')] > 
[day_time_duration('PT30M'), day_time_duration('PT10M')]", "r": true }
+{ "c": "[interval(date('2013-01-01'), date('20130505')), 
interval(date('2012-01-01'), date('20130505'))] = [interval(date('2013-01-01'), 
date('20130505')), interval(date('2012-01-01'), date('20130505'))]", "r": true }
+{ "c": "[interval(date('2013-01-01'), date('20130505')), 
interval(date('2012-01-01'), date('20130505'))] < [interval(date('2013-01-01'), 
date('20130505')), interval(date('2012-01-01'), date('20130505'))]", "r": null }
+{ "c": "[date('2013-01-01'), date('2014-01-01')] < [date('2016-01-01'), 
date('2014-01-01')]", "r": true }
+{ "c": "[time('12:12:12.039Z'), time('10:12:12.039Z')] > 
[time('11:12:12.039Z'), time('10:12:12.039Z')]", "r": true }
+{ "c": "[datetime('2013-01-01T12:12:12.039Z'), 
datetime('-19700101T000000000-0800')] = [datetime('2013-01-01T12:12:12.039Z'), 
datetime('-19700101T000000000-0800')]", "r": true }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.006.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.006.adm
new file mode 100644
index 0000000..a32669b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.006.adm
@@ -0,0 +1,27 @@
+{ "c": "[smallint('23'), 2] = [23, float('2')]", "r": true }
+{ "c": "['green', 2, date('2013-01-01'), 'blue'] = ['green', double('2'), 
date('2013-01-01'), 'blue']", "r": true }
+{ "c": "[1,point('23.22,30.50'), 3] < [1,point('23.22,30.50'),4]", "r": null }
+{ "c": "['black', int('4'), float('3.3')] > ['black', bigint('4')]", "r": true 
}
+{ "c": "['red', null] < ['red', null]", "r": null }
+{ "c": "[missing,2] < [null,3]" }
+{ "c": "[1,2] < [1,2,missing]", "r": true }
+{ "c": "[1,2] < [1,2,null]", "r": true }
+{ "c": "[null,5] >= [null,5]", "r": null }
+{ "c": "[null,8] < [4, 9]", "r": null }
+{ "c": "[1,2,missing] != [1,2,missing]" }
+{ "c": "['joe',3] > [7,'james']", "r": null }
+{ "c": "[] = []", "r": true }
+{ "c": "[] != []", "r": false }
+{ "c": "[] > []", "r": false }
+{ "c": "[] < []", "r": false }
+{ "c": "[] < [1,3]", "r": true }
+{ "c": "[] > [1,3]", "r": false }
+{ "c": "[8] = 8", "r": null }
+{ "c": "[9,2] > null", "r": null }
+{ "c": "[9,2] > missing" }
+{ "c": "[null,1] = [1,1,3]", "r": false }
+{ "c": "[null,1] != [1,1,3]", "r": true }
+{ "c": "[null,1] > [1,1,3]", "r": null }
+{ "c": "[1,point('23.22,30.50'), 3] = [1,point('23.22,30.50'),3]", "r": true }
+{ "c": "[true, 'steve', 12.0] != [1, 'mat']", "r": true }
+{ "c": "[null, null, null] = [null, null, null]", "r": null }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.007.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.007.adm
new file mode 100644
index 0000000..4f957c6
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.007.adm
@@ -0,0 +1,10 @@
+{ "c": "[[1.0,4], [5,9,11,14]] = [[1.0,4], [5,9,11,14]]", "r": true }
+{ "c": "[[5,2,7], ['green','black'], [date('2013-01-01')]] = [[5,2,7], 
['green','black'], [date('2013-01-01')]]", "r": true }
+{ "c": "[['white','yellow','brown'], 6] != [['white','yellow','brown'], 
double('6')]", "r": false }
+{ "c": "[['white','yellow','brown'], 6] != [double('6'), 
['white','yellow','brown']]", "r": null }
+{ "c": "[ [[1,2,3], 'gold', ['sql++', 5]], [tinyint('4'), tinyint('5')], 
smallint('2')] > [ [[1,2,3], 'gold', ['sql++', 5]], [bigint('4'), int('5')], 
double('0.2')]", "r": true }
+{ "c": "[[[1,2], 99], 77] <= [[['flute',2], 99], 77]", "r": null }
+{ "c": "[[[1,2], 99], 77] <= [[[missing,2], 99], 77]" }
+{ "c": "[5, [8,1], [[0, 4], 'b']] > [5, [8,1], [[0, 4], 'a', 'c']]", "r": true 
}
+{ "c": "[1,2] = {{1,2}}", "r": null }
+{ "c": "{'id':99, 'name':'sam'} != [99, 'sam']", "r": null }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.008.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.008.adm
new file mode 100644
index 0000000..fffea9b
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.008.adm
@@ -0,0 +1,6 @@
+{ "id": 1, "array1": [ 5, 1, 4 ], "OP": ">", "array2": [ 1, 2 ] }
+{ "id": 2, "array1": [ 1, 3 ], "OP": ">", "array2": [ 1, 2 ] }
+{ "id": 3, "array1": [ 6, 2, 1, 4 ], "OP": ">", "array2": [ 1, 2 ] }
+{ "id": 5, "array1": [ 1, 3, 1 ], "OP": ">", "array2": [ 1, 2 ] }
+{ "id": 9, "array1": [ 3 ], "OP": ">", "array2": [ 1, 2 ] }
+{ "id": 10, "array1": [ 6, 2, 1, 4 ], "OP": ">", "array2": [ 1, 2 ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.009.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.009.adm
new file mode 100644
index 0000000..e0e0240
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.009.adm
@@ -0,0 +1,2 @@
+{ "id": 7, "array1": [ 0 ], "OP": "<", "array2": [ 1, 2 ] }
+{ "id": 8, "array1": [  ], "OP": "<", "array2": [ 1, 2 ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.010.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.010.adm
new file mode 100644
index 0000000..4c6dfd5
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.010.adm
@@ -0,0 +1,2 @@
+{ "id": 3, "array1": [ 6, 2, 1, 4 ], "OP": "=", "array2": [ 6, 2, 1, 4 ] }
+{ "id": 10, "array1": [ 6, 2, 1, 4 ], "OP": "=", "array2": [ 6, 2, 1, 4 ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.011.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.011.adm
new file mode 100644
index 0000000..9bb9a35
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.011.adm
@@ -0,0 +1,2 @@
+{ "id": 4, "array1": null, "OP": "> is_null", "array2": [ 1, 2 ] }
+{ "id": 6, "array1": null, "OP": "> is_null", "array2": [ 1, 2 ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.012.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.012.adm
new file mode 100644
index 0000000..8b79c27
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.012.adm
@@ -0,0 +1 @@
+{ "id": 4, "array1": [ [ 1, 5, 6 ], [ 9, 555, 1 ] ], "OP": ">", "array2": [ [ 
1, 5, 6 ], [ 9, 4, 1 ] ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.013.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.013.adm
new file mode 100644
index 0000000..5a26b0d
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.013.adm
@@ -0,0 +1,6 @@
+{ "id": 1, "arrayF1": [ 5, 1, 4 ], "arrayF2": [ "green", "black", "white" ] }
+{ "id": 2, "arrayF1": [ 1, 3 ], "arrayF2": [ 1.0, "sql++" ] }
+{ "id": 5, "arrayF1": [ 1, 3, 1 ], "arrayF2": [ [ 4, 4 ], [ "orange", "purple" 
], 99 ] }
+{ "id": 7, "arrayF1": [ 0 ] }
+{ "id": 8, "arrayF1": [  ], "arrayF2": [ [ [ [ 88, 99 ], [ 100, 111 ] ] ], [ 
11, 12 ] ] }
+{ "id": 10, "arrayF1": [ 6, 2, 1, 4 ], "arrayF2": [ "green", "black", "white" 
] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.014.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.014.adm
new file mode 100644
index 0000000..6cfa561
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.014.adm
@@ -0,0 +1,2 @@
+{ "id": 3, "array1": [ 2, 1 ], "OP": "< is_missing", "array2": [ null, 3, 3 ] }
+{ "id": 7, "array1": [ 2, 1 ], "OP": "< is_missing" }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.015.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.015.adm
new file mode 100644
index 0000000..fb47cda
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.015.adm
@@ -0,0 +1,4 @@
+{ "id": 4, "array1": [ 1.0, "sql++" ], "OP": "= is_null", "array2": [ [ 1, 5, 
6 ], [ 9, 4, 1 ] ] }
+{ "id": 6, "array1": [ 1.0, "sql++" ], "OP": "= is_null", "array2": null }
+{ "id": 8, "array1": [ 1.0, "sql++" ], "OP": "= is_null", "array2": [ [ [ [ 
88, 99 ], [ 100, 111 ] ] ], [ 11, 12 ] ] }
+{ "id": 9, "array1": [ 1.0, "sql++" ], "OP": "= is_null", "array2": 56 }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.016.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.016.adm
new file mode 100644
index 0000000..8caf8aa
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.016.adm
@@ -0,0 +1,7 @@
+{ "id": 1, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": [ "green", 
"black", "white" ] }
+{ "id": 4, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": [ [ 1, 5, 
6 ], [ 9, 4, 1 ] ] }
+{ "id": 5, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": [ [ 4, 4 
], [ "orange", "purple" ], 99 ] }
+{ "id": 6, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": null }
+{ "id": 8, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": [ [ [ [ 
88, 99 ], [ 100, 111 ] ] ], [ 11, 12 ] ] }
+{ "id": 9, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": 56 }
+{ "id": 10, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": [ 
"green", "black", "white" ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.017.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.017.adm
new file mode 100644
index 0000000..3a0b0e6
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.017.adm
@@ -0,0 +1 @@
+{ "id": 4, "array1": [ 0, -1, -2 ], "OP": "=", "array2": [ 0.0, -1, -2 ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.018.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.018.adm
new file mode 100644
index 0000000..b35f8c2
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.018.adm
@@ -0,0 +1,5 @@
+{ "id": 4, "array1": [ 0, -1, -2 ], "OP": "<", "array2": [ 1, 2 ] }
+{ "id": 5, "array1": [ 0, 3, 1 ], "OP": "<", "array2": [ 1, 2 ] }
+{ "id": 7, "array1": [ -7, 99 ], "OP": "<", "array2": [ 1, 2 ] }
+{ "id": 8, "array1": [ -111, 222 ], "OP": "<", "array2": [ 1, 2 ] }
+{ "id": 9, "array1": [  ], "OP": "<", "array2": [ 1, 2 ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.019.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.019.adm
new file mode 100644
index 0000000..438737f
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.019.adm
@@ -0,0 +1,6 @@
+{ "id": 2, "array1": [ "zzz", "low" ], "OP": ">", "array2": [ "coin", 
"dollar", "bill" ] }
+{ "id": 4, "array1": [ "football", "soccer", "basketball" ], "OP": ">", 
"array2": [ "coin", "dollar", "bill" ] }
+{ "id": 6, "array1": [ "python", "java", "Go" ], "OP": ">", "array2": [ 
"coin", "dollar", "bill" ] }
+{ "id": 7, "array1": [ "sql++", "sql++" ], "OP": ">", "array2": [ "coin", 
"dollar", "bill" ] }
+{ "id": 8, "array1": [ "steve" ], "OP": ">", "array2": [ "coin", "dollar", 
"bill" ] }
+{ "id": 10, "array1": [ "python", "java", "Go" ], "OP": ">", "array2": [ 
"coin", "dollar", "bill" ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.020.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.020.adm
new file mode 100644
index 0000000..c3d33eb
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.020.adm
@@ -0,0 +1,17 @@
+{ "c": "[0,1] = [double('0'), float('1')]", "r": true }
+{ "c": "[-0, -1] = [float('-0'), -1]", "r": false }
+{ "c": "[double('INF')] > [0]", "r": true }
+{ "c": "[double('-INF')] < [0]", "r": true }
+{ "c": "[double('INF')] > [-0]", "r": true }
+{ "c": "[double('-INF')] < [-0]", "r": true }
+{ "c": "[double('INF')] > [double('-0')]", "r": true }
+{ "c": "[double('-INF')] < [double('-0')]", "r": true }
+{ "c": "[double('NaN')] > [0]", "r": true }
+{ "c": "[double('NaN')] < [0]", "r": false }
+{ "c": "[double('NaN')] > [-0]", "r": true }
+{ "c": "[double('NaN')] < [-0]", "r": false }
+{ "c": "[double('NaN')] > [double('-0')]", "r": true }
+{ "c": "[double('NaN')] < [double('-0')]", "r": false }
+{ "c": "[double('-INF')] < [double('INF')]", "r": true }
+{ "c": "[double('INF')] > [double('NaN')]", "r": false }
+{ "c": "[double('-INF')] < [double('NaN')]", "r": true }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 24c2f28..d368b45 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -2380,7 +2380,11 @@
         <output-dir compare="Text">neginfif</output-dir>
       </compilation-unit>
     </test-case>
-
+    <test-case FilePath="comparison">
+      <compilation-unit name="arrays">
+        <output-dir compare="Text">arrays</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="constructor">
     <test-case FilePath="constructor">
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java
index 270c9dd..a894ce9 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java
@@ -22,6 +22,7 @@
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public interface ILogicalBinaryComparator {
+
     enum Result {
         MISSING,
         NULL,
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ListAccessorUtil.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ListAccessorUtil.java
new file mode 100644
index 0000000..aa85af2
--- /dev/null
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ListAccessorUtil.java
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+package org.apache.asterix.dataflow.data.common;
+
+import java.io.IOException;
+
+import 
org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
+import 
org.apache.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.asterix.om.utils.NonTaggedFormatUtil;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+
+/**
+ * Utility class for accessing serialized unordered and ordered lists.
+ */
+public class ListAccessorUtil {
+
+    // TODO(ali): refactor 
ListAccessor/AOrderedListSerializerDeserializer/AUnorderedListSerializerDeserializer
 methods
+    // TODO(ali): AListPointable
+    private ListAccessorUtil() {
+    }
+
+    /**
+     * @param listBytes bytes of an array or multiset
+     * @param start offset to the beginning of the array or multiset
+     * @param itemIndex the index of the item requested
+     * @param listTag the type of list passed
+     * @param listItemTag the item type declared by the list. If the item type 
is ANY, each item includes its own tag
+     * @param pointable a pointable that will be set to point to the item 
requested
+     * @param storage if list is strongly typed, the item tag will be written 
followed by the item value to this storage
+     * @return true when the item requested has been written to the storage. 
false when a pointer to the item was set
+     * @throws IOException
+     */
+    public static boolean getOrWriteItem(byte[] listBytes, int start, int 
itemIndex, ATypeTag listTag,
+            ATypeTag listItemTag, IPointable pointable, 
ArrayBackedValueStorage storage) throws IOException {
+        int itemOffset;
+        if (listTag == ATypeTag.MULTISET) {
+            itemOffset = 
AUnorderedListSerializerDeserializer.getItemOffset(listBytes, start, itemIndex);
+        } else if (listTag == ATypeTag.ARRAY) {
+            itemOffset = 
AOrderedListSerializerDeserializer.getItemOffset(listBytes, start, itemIndex);
+        } else {
+            throw new IllegalStateException();
+        }
+
+        ATypeTag itemTag = listItemTag;
+        boolean itemIncludesTag = listItemTag == ATypeTag.ANY;
+        if (itemIncludesTag) {
+            itemTag = 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(listBytes[itemOffset]);
+        }
+        int itemValueLength = 
NonTaggedFormatUtil.getFieldValueLength(listBytes, itemOffset, itemTag, 
itemIncludesTag);
+        if (itemIncludesTag) {
+            // +1 to account for the already included tag
+            pointable.set(listBytes, itemOffset, itemValueLength + 1);
+            return false;
+        } else {
+            storage.reset();
+            storage.getDataOutput().writeByte(listItemTag.serialize());
+            storage.getDataOutput().write(listBytes, itemOffset, 
itemValueLength);
+            pointable.set(storage);
+            return true;
+        }
+    }
+
+    public static int numberOfItems(byte[] listBytes, int start) {
+        if (listBytes[start] == ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
+            return 
AUnorderedListSerializerDeserializer.getNumberOfItems(listBytes, start);
+        } else if (listBytes[start] == 
ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
+            return 
AOrderedListSerializerDeserializer.getNumberOfItems(listBytes, start);
+        } else {
+            throw new IllegalStateException();
+        }
+    }
+}
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java
index 050685f..e40138c 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java
@@ -18,45 +18,67 @@
  */
 package org.apache.asterix.dataflow.data.nontagged.comparators;
 
+import java.io.IOException;
+
+import org.apache.asterix.builders.AbvsBuilderFactory;
 import org.apache.asterix.dataflow.data.common.ILogicalBinaryComparator;
+import org.apache.asterix.dataflow.data.common.ListAccessorUtil;
 import org.apache.asterix.om.base.IAObject;
+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.EnumDeserializer;
 import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
+import org.apache.asterix.om.util.container.IObjectFactory;
+import org.apache.asterix.om.util.container.IObjectPool;
+import org.apache.asterix.om.util.container.ListObjectPool;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IMutableValueStorage;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 
 public class LogicalComplexBinaryComparator implements 
ILogicalBinaryComparator {
 
-    @SuppressWarnings("squid:S1068") // unused variable, remove once used
+    private static final IObjectFactory<IPointable, Void> VOID_FACTORY = 
(type) -> new VoidPointable();
     private final IAType leftType;
-    @SuppressWarnings("squid:S1068") // unused variable, remove once used
     private final IAType rightType;
-    @SuppressWarnings("squid:S1068") // unused variable, remove once used
     private final boolean isEquality;
-    @SuppressWarnings("squid:S1068") // unused variable, remove once used
     private final LogicalScalarBinaryComparator scalarComparator;
+    private final IObjectPool<IMutableValueStorage, ATypeTag> storageAllocator;
+    private final IObjectPool<IPointable, Void> voidPointableAllocator;
 
     public LogicalComplexBinaryComparator(IAType leftType, IAType rightType, 
boolean isEquality) {
         this.leftType = leftType;
         this.rightType = rightType;
         this.isEquality = isEquality;
         this.scalarComparator = new LogicalScalarBinaryComparator(isEquality);
+        storageAllocator = new ListObjectPool<>(new AbvsBuilderFactory());
+        voidPointableAllocator = new ListObjectPool<>(VOID_FACTORY);
     }
 
     @Override
     public Result compare(byte[] leftBytes, int leftStart, int leftLen, byte[] 
rightBytes, int rightStart, int rightLen)
             throws HyracksDataException {
-        ATypeTag leftTag = 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftBytes[leftStart]);
-        ATypeTag rightTag = 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(rightBytes[rightStart]);
-        Result comparisonResult = 
LogicalComparatorUtil.returnMissingOrNullOrMismatch(leftTag, rightTag);
+        ATypeTag leftRuntimeTag = 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftBytes[leftStart]);
+        ATypeTag rightRuntimeTag = 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(rightBytes[rightStart]);
+        Result comparisonResult = 
LogicalComparatorUtil.returnMissingOrNullOrMismatch(leftRuntimeTag, 
rightRuntimeTag);
         if (comparisonResult != null) {
             return comparisonResult;
         }
-        if (!leftTag.isDerivedType() || !rightTag.isDerivedType()) {
+        // make sure both left and right are complex types
+        if (!leftRuntimeTag.isDerivedType() || 
!rightRuntimeTag.isDerivedType()) {
+            // maybe we can invoke the scalar comparison? or we can even 
reduce this comparator to be the generic one?
             return Result.NULL;
         }
-        // TODO(ali): complex types(records, arrays, multisets) logic here
-        return Result.NULL;
+        try {
+            return compareComplex(leftType, leftRuntimeTag, leftBytes, 
leftStart, leftLen, rightType, rightRuntimeTag,
+                    rightBytes, rightStart, rightLen);
+        } finally {
+            storageAllocator.reset();
+            voidPointableAllocator.reset();
+        }
     }
 
     @Override
@@ -68,6 +90,7 @@
         if (comparisonResult != null) {
             return comparisonResult;
         }
+        // TODO(ali): deallocate when implemented
         return Result.NULL;
     }
 
@@ -92,6 +115,119 @@
         if (comparisonResult != null) {
             return comparisonResult;
         }
+        // TODO(ali): deallocate when implemented
+        return Result.NULL;
+    }
+
+    private Result compareComplex(IAType leftType, ATypeTag leftRuntimeTag, 
byte[] leftBytes, int leftStart,
+            int leftLen, IAType rightType, ATypeTag rightRuntimeTag, byte[] 
rightBytes, int rightStart, int rightLen)
+            throws HyracksDataException {
+        if (!ATypeHierarchy.isCompatible(leftRuntimeTag, rightRuntimeTag)) {
+            return Result.MISMATCH;
+        }
+        switch (leftRuntimeTag) {
+            case MULTISET:
+                // equality is the only operation defined for multiset
+                if (!isEquality) {
+                    return Result.NULL;
+                }
+                return compareMultisets(leftType, leftRuntimeTag, leftBytes, 
leftStart, rightType, rightRuntimeTag,
+                        rightBytes, rightStart);
+            case ARRAY:
+                return compareArrays(leftType, leftRuntimeTag, leftBytes, 
leftStart, rightType, rightRuntimeTag,
+                        rightBytes, rightStart);
+            case OBJECT:
+                // equality is the only operation defined for records
+                if (!isEquality) {
+                    return Result.NULL;
+                }
+                return compareRecords(leftType, leftBytes, leftStart, leftLen, 
rightType, rightBytes, rightStart,
+                        rightLen);
+            default:
+                return Result.NULL;
+        }
+    }
+
+    private Result compareArrays(IAType leftType, ATypeTag leftListTag, byte[] 
leftBytes, int leftStart,
+            IAType rightType, ATypeTag rightListTag, byte[] rightBytes, int 
rightStart) throws HyracksDataException {
+        // reaching here, both left and right have to be arrays (should be 
enforced)
+        int leftNumItems = ListAccessorUtil.numberOfItems(leftBytes, 
leftStart);
+        int rightNumItems = ListAccessorUtil.numberOfItems(rightBytes, 
rightStart);
+        // short-circuiting when comparison is for equality and the two arrays 
have different sizes
+        if (isEquality && leftNumItems != rightNumItems) {
+            return 
ILogicalBinaryComparator.asResult(Integer.compare(leftNumItems, rightNumItems));
+        }
+        IAType leftListCompileType = leftType;
+        if (leftListCompileType.getTypeTag() == ATypeTag.ANY) {
+            leftListCompileType = 
DefaultOpenFieldType.getDefaultOpenFieldType(leftListTag);
+        }
+        IAType rightListCompileType = rightType;
+        if (rightListCompileType.getTypeTag() == ATypeTag.ANY) {
+            rightListCompileType = 
DefaultOpenFieldType.getDefaultOpenFieldType(rightListTag);
+        }
+        IAType leftItemCompileType = ((AbstractCollectionType) 
leftListCompileType).getItemType();
+        IAType rightItemCompileType = ((AbstractCollectionType) 
rightListCompileType).getItemType();
+        ATypeTag leftItemTag = leftItemCompileType.getTypeTag();
+        ATypeTag rightItemTag = rightItemCompileType.getTypeTag();
+
+        // TODO(ali): could be optimized to not need pointable when changing 
comparator to be non-tagged & no visitable
+        IPointable leftItem = voidPointableAllocator.allocate(null);
+        IPointable rightItem = voidPointableAllocator.allocate(null);
+        // TODO(ali): optimize to not need this storage, will require 
optimizing records comparison to not use visitable
+        ArrayBackedValueStorage leftStorage = (ArrayBackedValueStorage) 
storageAllocator.allocate(null);
+        ArrayBackedValueStorage rightStorage = (ArrayBackedValueStorage) 
storageAllocator.allocate(null);
+        Result result;
+        byte leftItemTagByte;
+        byte rightItemTagByte;
+        ATypeTag leftItemRuntimeTag;
+        ATypeTag rightItemRuntimeTag;
+        try {
+            for (int i = 0; i < leftNumItems && i < rightNumItems; i++) {
+                ListAccessorUtil.getOrWriteItem(leftBytes, leftStart, i, 
leftListTag, leftItemTag, leftItem,
+                        leftStorage);
+                ListAccessorUtil.getOrWriteItem(rightBytes, rightStart, i, 
rightListTag, rightItemTag, rightItem,
+                        rightStorage);
+                leftItemTagByte = 
leftItem.getByteArray()[leftItem.getStartOffset()];
+                rightItemTagByte = 
rightItem.getByteArray()[rightItem.getStartOffset()];
+
+                // if both tags are derived, get item type or default to open 
item if array is open, then call complex
+                leftItemRuntimeTag = 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftItemTagByte);
+                rightItemRuntimeTag = 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(rightItemTagByte);
+                if (leftItemRuntimeTag.isDerivedType() && 
rightItemRuntimeTag.isDerivedType()) {
+                    result = compareComplex(leftItemCompileType, 
leftItemRuntimeTag, leftItem.getByteArray(),
+                            leftItem.getStartOffset(), leftItem.getLength(), 
rightItemCompileType, rightItemRuntimeTag,
+                            rightItem.getByteArray(), 
rightItem.getStartOffset(), rightItem.getLength());
+                } else {
+                    result = scalarComparator.compare(leftItem.getByteArray(), 
leftItem.getStartOffset(),
+                            leftItem.getLength(), rightItem.getByteArray(), 
rightItem.getStartOffset(),
+                            rightItem.getLength());
+                }
+
+                if (result != Result.EQ) {
+                    return result;
+                }
+            }
+
+            return 
ILogicalBinaryComparator.asResult(Integer.compare(leftNumItems, rightNumItems));
+        } catch (IOException e) {
+            throw HyracksDataException.create(e);
+        } finally {
+            storageAllocator.markFree(rightStorage);
+            storageAllocator.markFree(leftStorage);
+            voidPointableAllocator.markFree(rightItem);
+            voidPointableAllocator.markFree(leftItem);
+        }
+    }
+
+    private Result compareMultisets(IAType leftType, ATypeTag leftListTag, 
byte[] leftBytes, int leftStart,
+            IAType rightType, ATypeTag rightListTag, byte[] rightBytes, int 
rightStart) throws HyracksDataException {
+        // TODO(ali): multiset comparison logic here
+        return Result.NULL;
+    }
+
+    private Result compareRecords(IAType leftType, byte[] leftBytes, int 
leftStart, int leftLen, IAType rightType,
+            byte[] rightBytes, int rightStart, int rightLen) {
+        // TODO(ali): record comparison logic here
         return Result.NULL;
     }
 }
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/IObjectPool.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/IObjectPool.java
index d3d76e6..9bf9911 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/IObjectPool.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/IObjectPool.java
@@ -37,4 +37,6 @@
      * Mark all instances in the pool as unused
      */
     public void reset();
+
+    boolean markFree(E element);
 }
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/ListObjectPool.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/ListObjectPool.java
index 2f8789c..5dc422e 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/ListObjectPool.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/container/ListObjectPool.java
@@ -82,4 +82,15 @@
     public void reset() {
         usedBits.clear();
     }
+
+    @Override
+    public boolean markFree(E element) {
+        for (int i = pool.size() - 1; i >= 0; i--) {
+            if (element == pool.get(i)) {
+                usedBits.clear(i);
+                return true;
+            }
+        }
+        return false;
+    }
 }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/3173
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2fef48d7c6189362f44786b8d89d89c5f91d4b10
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Ali Alsuliman <[email protected]>

Reply via email to