Ali Alsuliman has submitted this change and it was merged. 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 Reviewed-on: https://asterix-gerrit.ics.uci.edu/3173 Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Michael Blow <mb...@apache.org> Reviewed-by: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Reviewed-by: Till Westmann <ti...@apache.org> --- 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.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.022.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.023.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.regexjson A asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.005.regexjson A asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.006.regexjson A asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.007.regexjson 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.regexjson A asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.021.regexjson A asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.022.regexjson 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/LogicalComparatorUtil.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/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.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 M asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractValueComparisonEvaluator.java 52 files changed, 1,451 insertions(+), 23 deletions(-) Approvals: Till Westmann: Looks good to me, approved Jenkins: Verified; ; Verified Michael Blow: Dmitry Lychagin: Looks good to me, but someone else must approve Objections: Jenkins: Violations found 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..84334c8 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.004.query.sqlpp @@ -0,0 +1,64 @@ +/* + * 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; + +{ +"t1": {"c": "[tinyint('1'),tinyint('2')] = [tinyint('1'),tinyint('2')]", "r": [tinyint('1'),tinyint('2')] = [tinyint('1'),tinyint('2')]}, +"t2": {"c": "['a','b','c'] = ['a','b','c']", "r": ['a','b','c'] = ['a','b','c']}, +"t3": {"c": "['A','b','c'] = ['a','b','c']", "r": ['A','b','c'] = ['a','b','c']}, +"t4": {"c": "['a','b','c'] < ['a','b','d']", "r": ['a','b','c'] < ['a','b','d']}, +"t5": {"c": "['blue', 'black', 'orange'] < ['purple', 'green']", "r": ['blue', 'black', 'orange'] < ['purple', 'green']}, +"t6": {"c": "['blue', 'black', 'orange'] > ['purple', 'green']", "r": ['blue', 'black', 'orange'] > ['purple', 'green']}, +"t7": {"c": "['blue', 'black', 'orange'] >= ['blue', 'black', 'orange']", "r": ['blue', 'black', 'orange'] >= ['blue', 'black', 'orange']}, +"t8": {"c": "[true] > [false]", "r": [true] > [false]}, +"t9": {"c": "[true, false, true] = [true, false, true]", "r": [true, false, true] = [true, false, true]}, +"t10": {"c": "[true, false, false] >= [true, true]", "r": [true, false, false] >= [true, true]}, +"t11": {"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')]}, + +"t12": {"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')]}, + +"t13": {"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')]}, + +"t14": {"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')]}, + +"t15": {"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')]}, + +"t16": {"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')]}, + +"t17": {"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')]}, + +"t18": {"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')]}, + +"t19": {"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')]}, + +"t20": {"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..641dc76 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.005.query.sqlpp @@ -0,0 +1,63 @@ +/* + * 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; + +{ +"t1": {"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')]}, + +"t2": {"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')]}, + +"t3": {"c":"[duration('P100Y12MT12M'), duration('-PT20.943S')] = [duration('P100Y12MT12M'), duration('-PT20.943S')]", +"r":[duration('P100Y12MT12M'), duration('-PT20.943S')] = [duration('P100Y12MT12M'), duration('-PT20.943S')]}, + +"t4": {"c": "[duration('P100Y12MT12M'), duration('-PT20.943S')] <= [duration('P100Y12MT12M'), duration('-PT20.943S')]", +"r":[duration('P100Y12MT12M'), duration('-PT20.943S')] <= [duration('P100Y12MT12M'), duration('-PT20.943S')]}, + +"t5": {"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')]}, + +"t6": {"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')]}, + +"t7": {"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')]}, + +"t8": {"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')]}, + +"t9": {"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'))]}, + +"t10": {"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'))]}, + +"t11": {"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')]}, + +"t12": {"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')]}, + +"t13": {"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..54106a9 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.006.query.sqlpp @@ -0,0 +1,40 @@ +/* + * 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. + */ + +// simple mixed types + +use test; + +{ +"t1": {"c":"[smallint('23'), 2] = [23, float('2')]", "r":[smallint('23'), 2] = [23, float('2')]}, +"t2": {"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']}, +"t3": {"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]}, +"t4": {"c":"['black', int('4'), float('3.3')] > ['black', bigint('4')]", "r":['black', int('4'), float('3.3')] > ['black', bigint('4')]}, +"t5": {"c":"['joe',3] > [7,'james']", "r":['joe',3] > [7,'james']}, +"t6": {"c":"[] = []", "r":[] = []}, +"t7": {"c":"[] != []", "r":[] != []}, +"t8": {"c":"[] > []", "r":[] > []}, +"t9": {"c":"[] < []", "r":[] < []}, +"t10": {"c":"[] < [1,3]", "r":[] < [1,3]}, +"t11": {"c":"[] > [1,3]", "r":[] > [1,3]}, +"t12": {"c":"[8] = 8", "r":[8] = 8}, +"t13": {"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]}, +"t14": {"c":"[true, 'steve', 12.0] != [1, 'mat']", "r": [true, "steve", 12.0] != [1, "mat"]} +}; \ 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..dbb9798 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.007.query.sqlpp @@ -0,0 +1,63 @@ +/* + * 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; + +{ +"t1": {"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]]}, +"t2": {"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')]]}, + +"t3": {"c":"[['white','yellow','brown'], 6] != [['white','yellow','brown'], double('6')]", +"r":[["white","yellow","brown"], 6] != [["white","yellow","brown"], double('6')]}, + +"t4": {"c":"[['white','yellow','brown'], 6] != [double('6'), ['white','yellow','brown']]", +"r":[["white","yellow","brown"], 6] != [double('6'), ["white","yellow","brown"]]}, + +"t5": {"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')]}, + +"t6": {"c":"[[[1,2], 99], 77] <= [[['flute',2], 99], 77]", "r":[[[1,2], 99], 77] <= [[['flute',2], 99], 77]}, +"t7": {"c":"[[[1,2], 99], 77] <= [[[missing,2], 99], 77]", "r":[[[1,2], 99], 77] <= [[[missing,2], 99], 77]}, +"t8": {"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']]}, + +"t9": {"c":"[[1, null], 9] = [[1, 2], 9]", "r":[[1, null], 9] = [[1, 2], 9]}, +"t10": {"c":"[[1, null], 9] = [[1, 2], 99]", "r":[[1, null], 9] = [[1, 2], 99]}, + +"t11": {"c":"[[1, null], 9] < [[1, 2], 9]", "r":[[1, null], 9] < [[1, 2], 9]}, +"t12": {"c":"[[1, null], 9] < [[1, 2], 99]", "r":[[1, null], 9] < [[1, 2], 99]}, + +"t13": {"c":"[[1, null], 9] > [[1, 2], 9]", "r":[[1, null], 9] > [[1, 2], 9]}, +"t14": {"c":"[[1, null], 9] > [[1, 2], 99]", "r":[[1, null], 9] > [[1, 2], 99]}, + +// mismatch +"t15": {"c":"[1,2] = {{1,2}}", "r":[1,2] = {{1,2}} }, +"t16": {"c":"{'id':99, 'name':'sam'} != [99, 'sam']", "r": {"id":99, "name":"sam"} != [99, 'sam']}, + +"t17": {"c":"[[1, 'string'], 9] = [[1, 2], 9]", "r":[[1, 'string'], 9] = [[1, 2], 9]}, +"t18": {"c":"[[1, 'string'], 9] = [[1, 2], 99]", "r":[[1, 'string'], 9] = [[1, 2], 99]}, + +"t19": {"c":"[[1, 'string'], 9] < [[1, 2], 9]", "r":[[1, 'string'], 9] < [[1, 2], 9]}, +"t20": {"c":"[[1, 'string'], 9] < [[1, 2], 99]", "r":[[1, 'string'], 9] < [[1, 2], 99]}, + +"t21": {"c":"[[1, 'string'], 9] > [[1, 2], 9]", "r":[[1, 'string'], 9] > [[1, 2], 9]}, +"t22": {"c":"[[1, 'string'], 9] > [[1, 2], 99]", "r":[[1, 'string'], 9] > [[1, 2], 99]} +}; \ 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..88eb21b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.020.query.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. + */ + +// floating-points + +use test; + +{ +"t1": {"c": "[0,1] = [double('0'), float('1')]", "r":[0,1] = [double('0'), float('1')]}, +"t2": {"c": "[-0, -1] = [float('-0'), -1]", "r": [-0, -1] = [float('-0'), -1]}, + +"t3": {"c":"[double('INF')] > [0]", "r":[double('INF')] > [0]}, +"t4": {"c":"[double('-INF')] < [0]", "r":[double('-INF')] < [0]}, +"t5": {"c":"[double('INF')] > [-0]", "r":[double('INF')] > [-0]}, +"t6": {"c":"[double('-INF')] < [-0]", "r":[double('-INF')] < [-0]}, +"t7": {"c":"[double('INF')] > [double('-0')]", "r":[double('INF')] > [double('-0')]}, +"t8": {"c":"[double('-INF')] < [double('-0')]", "r":[double('-INF')] < [double('-0')]}, + +"t9": {"c":"[double('NaN')] > [0]", "r":[double('NaN')] > [0]}, +"t10": {"c":"[double('NaN')] < [0]", "r":[double('NaN')] < [0]}, +"t11": {"c":"[double('NaN')] > [-0]", "r":[double('NaN')] > [-0]}, +"t12": {"c":"[double('NaN')] < [-0]", "r":[double('NaN')] < [-0]}, +"t13": {"c":"[double('NaN')] > [double('-0')]", "r":[double('NaN')] > [double('-0')]}, +"t14": {"c":"[double('NaN')] < [double('-0')]", "r":[double('NaN')] < [double('-0')]}, + +"t15": {"c":"[double('-INF')] < [double('INF')]", "r":[double('-INF')] < [double('INF')]}, + +"t16": {"c":"[double('INF')] > [double('NaN')]", "r":[double('INF')] > [double('NaN')]}, +"t17": {"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.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.021.query.sqlpp new file mode 100644 index 0000000..4155342 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.021.query.sqlpp @@ -0,0 +1,83 @@ +/* + * 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. + */ + +// nulls and missings + +use test; + +{ +"t1": {"c":"[9,2] = null", "r":[9,2] = null}, +"t2": {"c":"[9,2] = missing", "r":[9,2] = missing}, + +"t3": {"c":"[9,2] > null", "r":[9,2] > null}, +"t4": {"c":"[9,2] > missing", "r":[9,2] > missing}, + +"t5": {"c":"['red', null] < ['red', null]", "r":['red', null] < ['red', null]}, +"t6": {"c":"[missing,2] < [null,3]", "r":[missing,2] < [null,3]}, +"t7": {"c":"[1,2] < [1,2,missing]", "r":[1,2] < [1,2,missing]}, +"t8": {"c":"[1,2] < [1,2,null]", "r":[1,2] < [1,2,null]}, +"t9": {"c":"[null,5] >= [null,5]", "r":[null,5] >= [null,5]}, +"t10": {"c":"[null,8] < [4, 9]", "r":[null,8] < [4, 9]}, +"t11": {"c":"[1,2,missing] != [1,2,missing]", "r":[1,2,missing] != [1,2,missing]}, + +"t12": {"c":"[null,1] = [1,1,3]", "r":[null,1] = [1,1,3]}, +"t13": {"c":"[null,1] != [1,1,3]", "r":[null,1] != [1,1,3]}, +"t14": {"c":"[null,1] > [1,1,3]", "r":[null,1] > [1,1,3]}, + +"t15": {"c":"[null, null, null] = [null, null, null]", "r": [null, null, null] = [null, null, null]}, +"t16": {"c":"[missing, missing] = [missing, missing]", "r": [missing, missing] = [missing, missing]}, + +"t17": {"c":"[99, null, 3] = [1, 2, 3]", "r":[99, null, 3] = [1, 2, 3]}, +"t18": {"c":"[1, null, 3] = [1, 2, 3]", "r":[1, null, 3] = [1, 2, 3]}, +"t19": {"c":"[1, missing, 3] = [1, 2, 3]", "r":[1, missing, 3] = [1, 2, 3]}, +"t20": {"c":"[1, null, missing, 4] = [1, 2, 3, 4]", "r":[1, null, missing, 4] = [1, 2, 3, 4]}, +"t21": {"c":"[1, null, missing, null, 5] = [1, 2, 3, 4, 5]", "r":[1, null, missing, null, 5] = [1, 2, 3, 4, 5]}, +"t22": {"c":"[1, missing, null, missing, 5] = [1, 2, 3, 4, 5]", "r":[1, missing, null, missing, 5] = [1, 2, 3, 4, 5]}, + +"t23": {"c":"[1, null, 3] = [1, 2, 99]", "r":[1, null, 3] = [1, 2, 99]}, +"t24": {"c":"[1, missing, 3] = [1, 2, 99]", "r":[1, missing, 3] = [1, 2, 99]}, +"t25": {"c":"[1, null, missing, 4] = [1, 2, 3, 99]", "r":[1, null, missing, 4] = [1, 2, 3, 99]}, +"t26": {"c":"[1, null, missing, null, 5] = [1, 2, 3, 4, 99]", "r":[1, null, missing, null, 5] = [1, 2, 3, 4, 99]}, +"t27": {"c":"[1, missing, null, missing, 5] = [1, 2, 3, 4, 99]", "r":[1, missing, null, missing, 5] = [1, 2, 3, 4, 99]}, + +"t28": {"c":"[1, null, 3] != [1, 2, 3]", "r":[1, null, 3] != [1, 2, 3]}, +"t29": {"c":"[1, missing, 3] != [1, 2, 3]", "r":[1, missing, 3] != [1, 2, 3]}, +"t30": {"c":"[1, null, missing, 4] != [1, 2, 3, 4]", "r":[1, null, missing, 4] != [1, 2, 3, 4]}, + +"t31": {"c":"[1, null, 3] != [1, 2, 99]", "r":[1, null, 3] != [1, 2, 99]}, +"t32": {"c":"[1, missing, 3] != [1, 2, 99]", "r":[1, missing, 3] != [1, 2, 99]}, +"t33": {"c":"[1, null, missing, 4] != [1, 2, 3, 99]", "r":[1, null, missing, 4] != [1, 2, 3, 99]}, + +"t34": {"c":"[1, null, 3] < [1, 2, 3]", "r":[1, null, 3] < [1, 2, 3]}, +"t35": {"c":"[1, missing, 3] < [1, 2, 3]", "r":[1, missing, 3] < [1, 2, 3]}, +"t36": {"c":"[1, null, missing, 4] < [1, 2, 3, 4]", "r":[1, null, missing, 4] < [1, 2, 3, 4]}, +"t37": {"c":"[1, missing, null, 4] < [1, 2, 3, 4]", "r":[1, missing, null, 4] < [1, 2, 3, 4]}, + +"t38": {"c":"[1, null, 3] < [1, 2, 99]", "r":[1, null, 3] < [1, 2, 99]}, +"t39": {"c":"[1, missing, 3] < [1, 2, 99]", "r":[1, missing, 3] < [1, 2, 99]}, + +"t40": {"c":"[1, null, 99] < [1, 2, 3]", "r":[1, null, 99] < [1, 2, 3]}, +"t41": {"c":"[1, missing, 99] < [1, 2, 3]", "r":[1, missing, 99] < [1, 2, 3]}, + +"t42": {"c":"[99, null, 3] < [1, 2, 3]", "r":[99, null, 3] < [1, 2, 3]}, +"t43": {"c":"[-99, null, 3] < [1, 2, 3]", "r":[-99, null, 3] < [1, 2, 3]}, + +"t44": {"c":"[99, null, 3] >= [1, 2, 3]", "r":[99, null, 3] >= [1, 2, 3]}, +"t45": {"c":"[-99, null, 3] >= [1, 2, 3]", "r":[-99, null, 3] >= [1, 2, 3]} +}; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.022.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.022.query.sqlpp new file mode 100644 index 0000000..57e3b44 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.022.query.sqlpp @@ -0,0 +1,60 @@ +/* + * 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. + */ + +// nulls, missings, incomparable + +use test; + +{ +"t1": {"c":"[1, 'string'] != [2, 9]", "r":[1, 'string'] != [2, 9]}, +"t2": {"c":"[1, 'string'] > [2, 9]", "r":[1, 'string'] > [2, 9]}, +"t3": {"c":"[9, {'id': 2}] < [1, {'id': 3}]", "r":[9, {'id': 2}] < [1, {'id': 3}]}, +"t4": {"c":"[1, 2] = ['string', 2, 3, 4]", "r":[1, 2] = ['string', 2, 3, 4]}, +"t5": {"c":"[null, 2, 3, 4, 5] = [1, 2]", "r":[null, 2, 3, 4, 5] = [1, 2]}, +"t6": {"c":"[1, null, 3] = [1, 2, 'string']", "r":[1, null, 3] = [1, 2, 'string']}, +"t7": {"c":"[1, null] = [2, 5]", "r":[1, null] = [2, 5]}, +"t8": {"c":"[1, null, 3, 7] = [1, 2, 9, 5]", "r":[1, null, 3, 7] = [1, 2, 9, 5]}, +"t9": {"c":"[null, 'string'] < [1, 2]", "r":[null, 'string'] < [1, 2]}, + +"t10": {"c":"[missing, 'string'] < [1, 2]", "r":[missing, 'string'] < [1, 2]}, + +"t12": {"c":"[null, {'id':3}] < [2, {'id': 4}]", "r":[null, {'id':3}] < [2, {'id': 4}]}, +"t13": {"c":"[null, {'id':3}, 8] < [2, {'id': 4}, 9]", "r":[null, {'id':3}, 8] < [2, {'id': 4}, 9]}, + +"t14": {"c":"[88, [7, 1], [['string', 44]]] > [3, [-2, -3], [[5, 4]]]", "r":[88, [7, 1], [['string', 44]]] > [3, [-2, -3], [[5, 4]]]}, +"t15": {"c":"[88, null, [['string', 44]]] > [3, [-2, -3], [[5, 4]]]", "r":[88, null, [['string', 44]]] > [3, [-2, -3], [[5, 4]]]}, +"t16": {"c":"[88, missing, [['string', 44]]] > [3, [-2, -3], [[5, 4]]]", "r":[88, missing, [['string', 44]]] > [3, [-2, -3], [[5, 4]]]}, +"t17": {"c":"[null, 88, [['string', 44]]] > [3, 8, [[5, 4]]]", "r":[null, 88, [['string', 44]]] > [3, 8, [[5, 4]]]}, +"t18": {"c":"[null, missing, 88, [['string', 44]]] > [3, 5, 8, [[5, 4]]]", "r":[null, missing, 88, [['string', 44]]] > [3, 5, 8, [[5, 4]]]}, + +"t19": {"c":"[88, [7, 1], [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]", "r":[88, [7, 1], [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]}, +"t20": {"c":"[88, null, [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]", "r":[88, null, [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]}, +"t21": {"c":"[88, missing, [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]", "r":[88, missing, [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]}, +"t22": {"c":"[null, 88, [[-1, -44]]] > [3, 8, [[5, 4]]]", "r":[null, 88, [[-1, -44]]] > [3, 8, [[5, 4]]]}, +"t23": {"c":"[null, missing, 88, [[-1, -44]]] > [3, 5, 8, [[5, 4]]]", "r":[null, missing, 88, [[-1, -44]]] > [3, 5, 8, [[5, 4]]]}, +"t24": {"c":"[missing, null, 88, [[-1, -44]]] > [3, 5, 8, [[5, 4]]]", "r":[missing, null, 88, [[-1, -44]]] > [3, 5, 8, [[5, 4]]]}, +"t25": {"c": "[1, null, 9, missing] < [1, 2, 3, 4]", "r": [1, null, 9, missing] < [1, 2, 3, 4]}, +"t26": {"c": "[1, null, 3, missing] < [1, 2, 3, 4]", "r": [1, null, 3, missing] < [1, 2, 3, 4]}, +"t27": {"c": "[1, null, missing, 4] < [1, 2, 3, 4]", "r": [1, null, missing, 4] < [1, 2, 3, 4]}, +"t28": {"c": "[1, null, missing, 9] < [1, 2, 3, 4]", "r": [1, null, missing, 9] < [1, 2, 3, 4]}, +"t29": {"c": "[1, null, 9, missing] = [1, 2, 3, 4]", "r": [1, null, 9, missing] = [1, 2, 3, 4]}, +"t30": {"c": "[1, null, 3, missing] = [1, 2, 3, 4]", "r": [1, null, 3, missing] = [1, 2, 3, 4]}, +"t31": {"c": "[1, null, missing, 4] = [1, 2, 3, 4]", "r": [1, null, missing, 4] = [1, 2, 3, 4]}, +"t32": {"c": "[1, null, missing, 9] = [1, 2, 3, 4]", "r": [1, null, missing, 9] = [1, 2, 3, 4]} +}; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.023.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.023.ddl.sqlpp new file mode 100644 index 0000000..ff41019 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/comparison/arrays/arrays.023.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.regexjson b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.004.regexjson new file mode 100644 index 0000000..801b66a --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.004.regexjson @@ -0,0 +1,22 @@ +{ +"t1": { "c": "[tinyint('1'),tinyint('2')] = [tinyint('1'),tinyint('2')]", "r": true }, +"t2": { "c": "['a','b','c'] = ['a','b','c']", "r": true }, +"t3": { "c": "['A','b','c'] = ['a','b','c']", "r": false }, +"t4": { "c": "['a','b','c'] < ['a','b','d']", "r": true }, +"t5": { "c": "['blue', 'black', 'orange'] < ['purple', 'green']", "r": true }, +"t6": { "c": "['blue', 'black', 'orange'] > ['purple', 'green']", "r": false }, +"t7": { "c": "['blue', 'black', 'orange'] >= ['blue', 'black', 'orange']", "r": true }, +"t8": { "c": "[true] > [false]", "r": true }, +"t9": { "c": "[true, false, true] = [true, false, true]", "r": true }, +"t10": { "c": "[true, false, false] >= [true, true]", "r": false }, +"t11": { "c": "[point('23.22,30.50'), point('-13.22,30.50')] = [point('23.22,30.50'), point('-13.22,30.50')]", "r": true }, +"t12": { "c": "[point('23.22,30.50'), point('-13.22,30.50')] <= [point('23.22,30.50'), point('-13.22,30.50')]", "r": null }, +"t13": { "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 }, +"t14": { "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 }, +"t15": { "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 }, +"t16": { "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 }, +"t17": { "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 }, +"t18": { "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 }, +"t19": { "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 }, +"t20": { "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.regexjson b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.005.regexjson new file mode 100644 index 0000000..d0b75ac --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.005.regexjson @@ -0,0 +1,15 @@ +{ +"t1": { "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 }, +"t2": { "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 }, +"t3": { "c": "[duration('P100Y12MT12M'), duration('-PT20.943S')] = [duration('P100Y12MT12M'), duration('-PT20.943S')]", "r": true }, +"t4": { "c": "[duration('P100Y12MT12M'), duration('-PT20.943S')] <= [duration('P100Y12MT12M'), duration('-PT20.943S')]", "r": null }, +"t5": { "c": "[year_month_duration('P100Y'), year_month_duration('P200Y')] = [year_month_duration('P100Y'), year_month_duration('P200Y')]", "r": true }, +"t6": { "c": "[year_month_duration('P100Y'), year_month_duration('P200Y')] < [year_month_duration('P150Y'), year_month_duration('P200Y')]", "r": true }, +"t7": { "c": "[day_time_duration('PT30M'), day_time_duration('PT10M')] = [day_time_duration('PT30M'), day_time_duration('PT10M')]", "r": true }, +"t8": { "c": "[day_time_duration('PT40M'), day_time_duration('PT10M')] > [day_time_duration('PT30M'), day_time_duration('PT10M')]", "r": true }, +"t9": { "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 }, +"t10": { "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 }, +"t11": { "c": "[date('2013-01-01'), date('2014-01-01')] < [date('2016-01-01'), date('2014-01-01')]", "r": true }, +"t12": { "c": "[time('12:12:12.039Z'), time('10:12:12.039Z')] > [time('11:12:12.039Z'), time('10:12:12.039Z')]", "r": true }, +"t13": { "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.regexjson b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.006.regexjson new file mode 100644 index 0000000..670679d --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.006.regexjson @@ -0,0 +1,16 @@ +{ +"t1": { "c": "[smallint('23'), 2] = [23, float('2')]", "r": true }, +"t2": { "c": "['green', 2, date('2013-01-01'), 'blue'] = ['green', double('2'), date('2013-01-01'), 'blue']", "r": true }, +"t3": { "c": "[1,point('23.22,30.50'), 3] < [1,point('23.22,30.50'),4]", "r": null }, +"t4": { "c": "['black', int('4'), float('3.3')] > ['black', bigint('4')]", "r": true }, +"t5": { "c": "['joe',3] > [7,'james']", "r": null }, +"t6": { "c": "[] = []", "r": true }, +"t7": { "c": "[] != []", "r": false }, +"t8": { "c": "[] > []", "r": false }, +"t9": { "c": "[] < []", "r": false }, +"t10": { "c": "[] < [1,3]", "r": true }, +"t11": { "c": "[] > [1,3]", "r": false }, +"t12": { "c": "[8] = 8", "r": null }, +"t13": { "c": "[1,point('23.22,30.50'), 3] = [1,point('23.22,30.50'),3]", "r": true }, +"t14": { "c": "[true, 'steve', 12.0] != [1, 'mat']", "r": null } +} \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.007.regexjson b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.007.regexjson new file mode 100644 index 0000000..07a679b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.007.regexjson @@ -0,0 +1,24 @@ +{ +"t1": { "c": "[[1.0,4], [5,9,11,14]] = [[1.0,4], [5,9,11,14]]", "r": true }, +"t2": { "c": "[[5,2,7], ['green','black'], [date('2013-01-01')]] = [[5,2,7], ['green','black'], [date('2013-01-01')]]", "r": true }, +"t3": { "c": "[['white','yellow','brown'], 6] != [['white','yellow','brown'], double('6')]", "r": false }, +"t4": { "c": "[['white','yellow','brown'], 6] != [double('6'), ['white','yellow','brown']]", "r": null }, +"t5": { "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 }, +"t6": { "c": "[[[1,2], 99], 77] <= [[['flute',2], 99], 77]", "r": null }, +"t7": { "c": "[[[1,2], 99], 77] <= [[[missing,2], 99], 77]" }, +"t8": { "c": "[5, [8,1], [[0, 4], 'b']] > [5, [8,1], [[0, 4], 'a', 'c']]", "r": true }, +"t9": { "c": "[[1, null], 9] = [[1, 2], 9]", "r": null }, +"t10": { "c": "[[1, null], 9] = [[1, 2], 99]", "r": false }, +"t11": { "c": "[[1, null], 9] < [[1, 2], 9]", "r": null }, +"t12": { "c": "[[1, null], 9] < [[1, 2], 99]", "r": null }, +"t13": { "c": "[[1, null], 9] > [[1, 2], 9]", "r": null }, +"t14": { "c": "[[1, null], 9] > [[1, 2], 99]", "r": null }, +"t15": { "c": "[1,2] = {{1,2}}", "r": null }, +"t16": { "c": "{'id':99, 'name':'sam'} != [99, 'sam']", "r": null }, +"t17": { "c": "[[1, 'string'], 9] = [[1, 2], 9]", "r": null }, +"t18": { "c": "[[1, 'string'], 9] = [[1, 2], 99]", "r": null }, +"t19": { "c": "[[1, 'string'], 9] < [[1, 2], 9]", "r": null }, +"t20": { "c": "[[1, 'string'], 9] < [[1, 2], 99]", "r": null }, +"t21": { "c": "[[1, 'string'], 9] > [[1, 2], 9]", "r": null }, +"t22": { "c": "[[1, 'string'], 9] > [[1, 2], 99]", "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..9d9d409 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.015.adm @@ -0,0 +1,8 @@ +{ "id": 1, "array1": [ 1.0, "sql++" ], "OP": "= is_null", "array2": [ "green", "black", "white" ] } +{ "id": 3, "array1": [ 1.0, "sql++" ], "OP": "= is_null", "array2": [ null, 3, 3 ] } +{ "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.016.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.016.adm new file mode 100644 index 0000000..1ad95b2 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.016.adm @@ -0,0 +1,8 @@ +{ "id": 1, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": [ "green", "black", "white" ] } +{ "id": 3, "array1": [ 1.0, "sql++" ], "OP": "> is_null", "array2": [ null, 3, 3 ] } +{ "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.regexjson b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.020.regexjson new file mode 100644 index 0000000..5de56c3 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.020.regexjson @@ -0,0 +1,19 @@ +{ +"t1": { "c": "[0,1] = [double('0'), float('1')]", "r": true }, +"t2": { "c": "[-0, -1] = [float('-0'), -1]", "r": false }, +"t3": { "c": "[double('INF')] > [0]", "r": true }, +"t4": { "c": "[double('-INF')] < [0]", "r": true }, +"t5": { "c": "[double('INF')] > [-0]", "r": true }, +"t6": { "c": "[double('-INF')] < [-0]", "r": true }, +"t7": { "c": "[double('INF')] > [double('-0')]", "r": true }, +"t8": { "c": "[double('-INF')] < [double('-0')]", "r": true }, +"t9": { "c": "[double('NaN')] > [0]", "r": true }, +"t10": { "c": "[double('NaN')] < [0]", "r": false }, +"t11": { "c": "[double('NaN')] > [-0]", "r": true }, +"t12": { "c": "[double('NaN')] < [-0]", "r": false }, +"t13": { "c": "[double('NaN')] > [double('-0')]", "r": true }, +"t14": { "c": "[double('NaN')] < [double('-0')]", "r": false }, +"t15": { "c": "[double('-INF')] < [double('INF')]", "r": true }, +"t16": { "c": "[double('INF')] > [double('NaN')]", "r": false }, +"t17": { "c": "[double('-INF')] < [double('NaN')]", "r": true } +} \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.021.regexjson b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.021.regexjson new file mode 100644 index 0000000..98ff30e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.021.regexjson @@ -0,0 +1,47 @@ +{ +"t1": { "c": "[9,2] = null", "r": null }, +"t2": { "c": "[9,2] = missing" }, +"t3": { "c": "[9,2] > null", "r": null }, +"t4": { "c": "[9,2] > missing" }, +"t5": { "c": "['red', null] < ['red', null]", "r": null }, +"t6": { "c": "[missing,2] < [null,3]" }, +"t7": { "c": "[1,2] < [1,2,missing]", "r": true }, +"t8": { "c": "[1,2] < [1,2,null]", "r": true }, +"t9": { "c": "[null,5] >= [null,5]", "r": null }, +"t10": { "c": "[null,8] < [4, 9]", "r": null }, +"t11": { "c": "[1,2,missing] != [1,2,missing]" }, +"t12": { "c": "[null,1] = [1,1,3]", "r": false }, +"t13": { "c": "[null,1] != [1,1,3]", "r": true }, +"t14": { "c": "[null,1] > [1,1,3]", "r": null }, +"t15": { "c": "[null, null, null] = [null, null, null]", "r": null }, +"t16": { "c": "[missing, missing] = [missing, missing]" }, +"t17": { "c": "[99, null, 3] = [1, 2, 3]", "r": false }, +"t18": { "c": "[1, null, 3] = [1, 2, 3]", "r": null }, +"t19": { "c": "[1, missing, 3] = [1, 2, 3]" }, +"t20": { "c": "[1, null, missing, 4] = [1, 2, 3, 4]" }, +"t21": { "c": "[1, null, missing, null, 5] = [1, 2, 3, 4, 5]" }, +"t22": { "c": "[1, missing, null, missing, 5] = [1, 2, 3, 4, 5]" }, +"t23": { "c": "[1, null, 3] = [1, 2, 99]", "r": false }, +"t24": { "c": "[1, missing, 3] = [1, 2, 99]", "r": false }, +"t25": { "c": "[1, null, missing, 4] = [1, 2, 3, 99]", "r": false }, +"t26": { "c": "[1, null, missing, null, 5] = [1, 2, 3, 4, 99]", "r": false }, +"t27": { "c": "[1, missing, null, missing, 5] = [1, 2, 3, 4, 99]", "r": false }, +"t28": { "c": "[1, null, 3] != [1, 2, 3]", "r": null }, +"t29": { "c": "[1, missing, 3] != [1, 2, 3]" }, +"t30": { "c": "[1, null, missing, 4] != [1, 2, 3, 4]" }, +"t31": { "c": "[1, null, 3] != [1, 2, 99]", "r": true }, +"t32": { "c": "[1, missing, 3] != [1, 2, 99]", "r": true }, +"t33": { "c": "[1, null, missing, 4] != [1, 2, 3, 99]", "r": true }, +"t34": { "c": "[1, null, 3] < [1, 2, 3]", "r": null }, +"t35": { "c": "[1, missing, 3] < [1, 2, 3]" }, +"t36": { "c": "[1, null, missing, 4] < [1, 2, 3, 4]" }, +"t37": { "c": "[1, missing, null, 4] < [1, 2, 3, 4]" }, +"t38": { "c": "[1, null, 3] < [1, 2, 99]", "r": null }, +"t39": { "c": "[1, missing, 3] < [1, 2, 99]" }, +"t40": { "c": "[1, null, 99] < [1, 2, 3]", "r": null }, +"t41": { "c": "[1, missing, 99] < [1, 2, 3]" }, +"t42": { "c": "[99, null, 3] < [1, 2, 3]", "r": false }, +"t43": { "c": "[-99, null, 3] < [1, 2, 3]", "r": true }, +"t44": { "c": "[99, null, 3] >= [1, 2, 3]", "r": true }, +"t45": { "c": "[-99, null, 3] >= [1, 2, 3]", "r": false } +} \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.022.regexjson b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.022.regexjson new file mode 100644 index 0000000..3e158ee --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/comparison/arrays/arrays.022.regexjson @@ -0,0 +1,33 @@ +{ +"t1": { "c": "[1, 'string'] != [2, 9]", "r": null }, +"t2": { "c": "[1, 'string'] > [2, 9]", "r": null }, +"t3": { "c": "[9, {'id': 2}] < [1, {'id': 3}]", "r": null }, +"t4": { "c": "[1, 2] = ['string', 2, 3, 4]", "r": null }, +"t5": { "c": "[null, 2, 3, 4, 5] = [1, 2]", "r": false }, +"t6": { "c": "[1, null, 3] = [1, 2, 'string']", "r": null }, +"t7": { "c": "[1, null] = [2, 5]", "r": false }, +"t8": { "c": "[1, null, 3, 7] = [1, 2, 9, 5]", "r": false }, +"t9": { "c": "[null, 'string'] < [1, 2]", "r": null }, +"t10": { "c": "[missing, 'string'] < [1, 2]", "r": null }, +"t12": { "c": "[null, {'id':3}] < [2, {'id': 4}]", "r": null }, +"t13": { "c": "[null, {'id':3}, 8] < [2, {'id': 4}, 9]", "r": null }, +"t14": { "c": "[88, [7, 1], [['string', 44]]] > [3, [-2, -3], [[5, 4]]]", "r": null }, +"t15": { "c": "[88, null, [['string', 44]]] > [3, [-2, -3], [[5, 4]]]", "r": null }, +"t16": { "c": "[88, missing, [['string', 44]]] > [3, [-2, -3], [[5, 4]]]", "r": null }, +"t17": { "c": "[null, 88, [['string', 44]]] > [3, 8, [[5, 4]]]", "r": null }, +"t18": { "c": "[null, missing, 88, [['string', 44]]] > [3, 5, 8, [[5, 4]]]", "r": null }, +"t19": { "c": "[88, [7, 1], [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]", "r": true }, +"t20": { "c": "[88, null, [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]", "r": true }, +"t21": { "c": "[88, missing, [[-1, -44]]] > [3, [-2, -3], [[5, 4]]]", "r": true }, +"t22": { "c": "[null, 88, [[-1, -44]]] > [3, 8, [[5, 4]]]", "r": null }, +"t23": { "c": "[null, missing, 88, [[-1, -44]]] > [3, 5, 8, [[5, 4]]]" }, +"t24": { "c": "[missing, null, 88, [[-1, -44]]] > [3, 5, 8, [[5, 4]]]" }, +"t25": {"c": "[1, null, 9, missing] < [1, 2, 3, 4]", "r": null }, +"t26": {"c": "[1, null, 3, missing] < [1, 2, 3, 4]"}, +"t27": {"c": "[1, null, missing, 4] < [1, 2, 3, 4]"}, +"t28": {"c": "[1, null, missing, 9] < [1, 2, 3, 4]"}, +"t29": {"c": "[1, null, 9, missing] = [1, 2, 3, 4]", "r": false}, +"t30": {"c": "[1, null, 3, missing] = [1, 2, 3, 4]"}, +"t31": {"c": "[1, null, missing, 4] = [1, 2, 3, 4]"}, +"t32": {"c": "[1, null, missing, 9] = [1, 2, 3, 4]", "r": false} +} \ 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..8b4348c 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,13 +22,14 @@ import org.apache.hyracks.api.exceptions.HyracksDataException; public interface ILogicalBinaryComparator { + enum Result { MISSING, NULL, EQ, LT, GT, - MISMATCH + INCOMPARABLE } static Result asResult(int result) { 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..ba114c0 --- /dev/null +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ListAccessorUtil.java @@ -0,0 +1,90 @@ +/* + * 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 getItem(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(); + } + + boolean itemIncludesTag = listItemTag == ATypeTag.ANY; + ATypeTag itemTag = itemIncludesTag ? EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(listBytes[itemOffset]) + : listItemTag; + 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/LogicalComparatorUtil.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComparatorUtil.java index 29c6758..7b8b11d 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComparatorUtil.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComparatorUtil.java @@ -73,7 +73,7 @@ return ILogicalBinaryComparator.Result.NULL; } if (!ATypeHierarchy.isCompatible(leftTag, rightTag)) { - return ILogicalBinaryComparator.Result.MISMATCH; + return ILogicalBinaryComparator.Result.INCOMPARABLE; } return null; } 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..a1c1faa 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,66 @@ */ 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.typecomputer.impl.TypeComputeUtils; 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.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()) { - return Result.NULL; + // make sure both left and right are complex types + if (!leftRuntimeTag.isDerivedType() || !rightRuntimeTag.isDerivedType()) { + throw new IllegalStateException("Input types are not complex type"); } - // 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 +89,7 @@ if (comparisonResult != null) { return comparisonResult; } + // TODO(ali): deallocate when implemented return Result.NULL; } @@ -75,12 +97,14 @@ public Result compare(IAObject leftConstant, byte[] rightBytes, int rightStart, int rightLen) { // TODO(ali): not defined currently for constant complex types Result result = compare(rightBytes, rightStart, rightLen, leftConstant); - if (result == Result.LT) { - return Result.GT; - } else if (result == Result.GT) { - return Result.LT; + switch (result) { + case LT: + return Result.GT; + case GT: + return Result.LT; + default: + return result; } - return result; } @Override @@ -92,6 +116,144 @@ 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 (leftRuntimeTag != rightRuntimeTag) { + return Result.INCOMPARABLE; + } + switch (leftRuntimeTag) { + case MULTISET: + return compareMultisets(leftType, leftRuntimeTag, leftBytes, leftStart, rightType, rightRuntimeTag, + rightBytes, rightStart); + case ARRAY: + return compareArrays(leftType, leftRuntimeTag, leftBytes, leftStart, rightType, rightRuntimeTag, + rightBytes, rightStart); + case OBJECT: + 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); + IAType leftListCompileType = TypeComputeUtils.getActualType(leftType); + if (leftListCompileType.getTypeTag() == ATypeTag.ANY) { + leftListCompileType = DefaultOpenFieldType.getDefaultOpenFieldType(leftListTag); + } + IAType rightListCompileType = TypeComputeUtils.getActualType(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 unknownResult = null; + Result determiningResult = null; + Result tempResult; + byte leftItemTagByte; + byte rightItemTagByte; + ATypeTag leftItemRuntimeTag; + ATypeTag rightItemRuntimeTag; + try { + for (int i = 0; i < leftNumItems && i < rightNumItems; i++) { + ListAccessorUtil.getItem(leftBytes, leftStart, i, leftListTag, leftItemTag, leftItem, leftStorage); + ListAccessorUtil.getItem(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()) { + tempResult = compareComplex(leftItemCompileType, leftItemRuntimeTag, leftItem.getByteArray(), + leftItem.getStartOffset(), leftItem.getLength(), rightItemCompileType, rightItemRuntimeTag, + rightItem.getByteArray(), rightItem.getStartOffset(), rightItem.getLength()); + } else { + tempResult = scalarComparator.compare(leftItem.getByteArray(), leftItem.getStartOffset(), + leftItem.getLength(), rightItem.getByteArray(), rightItem.getStartOffset(), + rightItem.getLength()); + } + + if (tempResult == Result.INCOMPARABLE) { + return tempResult; + } + + // skip to next pair if current one is equal or the result of the comparison has already been decided + if (tempResult != Result.EQ && determiningResult == null) { + // tempResult = NULL, MISSING, LT, GT + if ((tempResult == Result.NULL || tempResult == Result.MISSING)) { + // keep unknown response if there is no yet a determining result switching to missing if found + if (unknownResult != Result.MISSING) { + unknownResult = tempResult; + } + } else { + // tempResult = LT, GT + determiningResult = tempResult; + } + } + } + + // reaching here means the two arrays are comparable + if (isEquality && leftNumItems != rightNumItems) { + return ILogicalBinaryComparator.asResult(Integer.compare(leftNumItems, rightNumItems)); + } + // for >, < make unknownResult the determiningResult if unknownResult was encountered before finding one + if (!isEquality && unknownResult != null) { + determiningResult = unknownResult; + } + if (determiningResult != null) { + return determiningResult; + } + if (unknownResult != null) { + return unknownResult; + } + return ILogicalBinaryComparator.asResult(Integer.compare(leftNumItems, rightNumItems)); + } catch (IOException e) { + throw HyracksDataException.create(e); + } finally { + storageAllocator.free(rightStorage); + storageAllocator.free(leftStorage); + voidPointableAllocator.free(rightItem); + voidPointableAllocator.free(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 + // equality is the only operation defined for multiset + if (!isEquality) { + return Result.INCOMPARABLE; + } + 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 + // equality is the only operation defined for records + if (!isEquality) { + return Result.INCOMPARABLE; + } return Result.NULL; } } diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.java index b6f2634..f4896dc 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.java @@ -89,7 +89,7 @@ return comparisonResult; } if (comparisonUndefined(leftTag, rightTag, isEquality)) { - return Result.NULL; + return Result.INCOMPARABLE; } // compare number if one of args is number comparisonResult = @@ -99,9 +99,9 @@ } // comparing non-numeric - // return null if !=, the assumption here is only numeric types are compatible with each other + // throw an exception if !=, the assumption here is only numeric types are compatible with each other if (leftTag != rightTag) { - return Result.NULL; + throw new IllegalStateException("Two different non-numeric tags but they are compatible"); } leftStart++; 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..a911c72 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 free(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..bdc1943 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 free(E element) { + for (int i = pool.size() - 1; i >= 0; i--) { + if (element == pool.get(i)) { + usedBits.clear(i); + return true; + } + } + return false; + } } diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractValueComparisonEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractValueComparisonEvaluator.java index dc9cdee..fd84e47 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractValueComparisonEvaluator.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractValueComparisonEvaluator.java @@ -50,7 +50,7 @@ writeMissing(result); break; case NULL: - case MISMATCH: + case INCOMPARABLE: writeNull(result); break; default: -- To view, visit https://asterix-gerrit.ics.uci.edu/3173 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2fef48d7c6189362f44786b8d89d89c5f91d4b10 Gerrit-PatchSet: 8 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Ali Alsuliman <ali.al.solai...@gmail.com> Gerrit-Reviewer: Ali Alsuliman <ali.al.solai...@gmail.com> Gerrit-Reviewer: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Gerrit-Reviewer: Michael Blow <mb...@apache.org> Gerrit-Reviewer: Till Westmann <ti...@apache.org>