[NO ISSUE][FUN] Modify array functions to allow comparing complex
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
This change is to modify the array functions to compare complex
types like arrays and records. The change also includes a small
fix to IsomorphismVariableMappingVisitor where the
NestedTupleSourceOperator visit method would downcast the args
without checking first they are of the same operator types.
- changed test cases
- changed NullMissingTest to pass the args types for functions
that need them.
Change-Id: I416989cf902eda38224a3b00340e478fc4e3a60c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3313
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/runtime/NullMissingTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/runtime/NullMissingTest.java
index 5d40207..35b379f 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/runtime/NullMissingTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/runtime/NullMissingTest.java
@@ -31,8 +31,11 @@
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.functions.FunctionCollection;
+import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -50,14 +53,14 @@
List<IFunctionDescriptorFactory> functions =
FunctionCollection.createDefaultFunctionCollection().getFunctionDescriptorFactories();
int testedFunctions = 0;
- Set<FunctionIdentifier> excluded = new HashSet<>();
- buildExcluded(excluded);
+ Set<FunctionIdentifier> functionsRequiringTypes = new HashSet<>();
+ buildFunctionsRequiringTypes(functionsRequiringTypes);
for (IFunctionDescriptorFactory func : functions) {
String className = func.getClass().getName();
// We test all generated functions except
// record and cast functions, which requires type settings (we test them in runtime tests).
if (className.contains("Gen") && !className.contains("record") && !className.contains("Cast")) {
- testFunction(func, excluded, className);
+ testFunction(func, className, functionsRequiringTypes);
++testedFunctions;
}
}
@@ -66,21 +69,25 @@
testedFunctions >= 217);
}
- private void testFunction(IFunctionDescriptorFactory funcFactory, Set<FunctionIdentifier> excluded,
- String className) throws Exception {
+ private void testFunction(IFunctionDescriptorFactory funcFactory, String className,
+ Set<FunctionIdentifier> functionsRequiringTypes) throws Exception {
IFunctionDescriptor functionDescriptor = funcFactory.createFunctionDescriptor();
- if (!(functionDescriptor instanceof AbstractScalarFunctionDynamicDescriptor)
- || excluded.contains(functionDescriptor.getIdentifier())) {
+ if (!(functionDescriptor instanceof AbstractScalarFunctionDynamicDescriptor)) {
System.out.println("Excluding " + className);
return;
}
System.out.println("Testing " + className);
AbstractScalarFunctionDynamicDescriptor funcDesc = (AbstractScalarFunctionDynamicDescriptor) functionDescriptor;
int inputArity = funcDesc.getIdentifier().getArity();
- Iterator<IScalarEvaluatorFactory[]> argEvalFactoryIterator = getArgCombinations(inputArity);
+ boolean t = functionsRequiringTypes.contains(funcDesc.getIdentifier()); // whether to build args types or not
+ Iterator<Pair<IScalarEvaluatorFactory[], IAType[]>> argEvalFactoryIterator = getArgCombinations(inputArity, t);
int index = 0;
while (argEvalFactoryIterator.hasNext()) {
- IScalarEvaluatorFactory evalFactory = funcDesc.createEvaluatorFactory(argEvalFactoryIterator.next());
+ Pair<IScalarEvaluatorFactory[], IAType[]> next = argEvalFactoryIterator.next();
+ if (next.second != null) {
+ funcDesc.setImmutableStates((Object[]) next.second);
+ }
+ IScalarEvaluatorFactory evalFactory = funcDesc.createEvaluatorFactory(next.first);
IHyracksTaskContext ctx = mock(IHyracksTaskContext.class);
IScalarEvaluator evaluator = evalFactory.createScalarEvaluator(ctx);
IPointable resultPointable = new VoidPointable();
@@ -96,10 +103,10 @@
}
}
- private Iterator<IScalarEvaluatorFactory[]> getArgCombinations(int inputArity) {
+ private Iterator<Pair<IScalarEvaluatorFactory[], IAType[]>> getArgCombinations(int inputArity, boolean buildTypes) {
int argSize = inputArity >= 0 ? inputArity : 3;
final int numCombinations = 1 << argSize;
- return new Iterator<IScalarEvaluatorFactory[]>() {
+ return new Iterator<Pair<IScalarEvaluatorFactory[], IAType[]>>() {
private int index = 0;
@Override
@@ -108,33 +115,40 @@
}
@Override
- public IScalarEvaluatorFactory[] next() {
+ public Pair<IScalarEvaluatorFactory[], IAType[]> next() {
IScalarEvaluatorFactory[] scalarEvaluatorFactories = new IScalarEvaluatorFactory[argSize];
+ IAType[] argsTypes = buildTypes ? new IAType[argSize] : null;
for (int j = 0; j < argSize; ++j) {
- byte serializedTypeTag = (index & (1 << j)) != 0 ? ATypeTag.SERIALIZED_MISSING_TYPE_TAG
- : ATypeTag.SERIALIZED_NULL_TYPE_TAG;
- scalarEvaluatorFactories[j] = new ConstantEvalFactory(new byte[] { serializedTypeTag });
+ IAType type = (index & (1 << j)) != 0 ? BuiltinType.AMISSING : BuiltinType.ANULL;
+ scalarEvaluatorFactories[j] = new ConstantEvalFactory(new byte[] { type.getTypeTag().serialize() });
+ if (buildTypes) {
+ argsTypes[j] = type;
+ }
}
++index;
- return scalarEvaluatorFactories;
+ return new Pair<>(scalarEvaluatorFactories, argsTypes);
}
};
}
- // adds functions that require setImmutables be called in order to set the args types
- private void buildExcluded(Set<FunctionIdentifier> excluded) {
- excluded.add(BuiltinFunctions.EQ);
- excluded.add(BuiltinFunctions.LT);
- excluded.add(BuiltinFunctions.GT);
- excluded.add(BuiltinFunctions.GE);
- excluded.add(BuiltinFunctions.LE);
- excluded.add(BuiltinFunctions.NEQ);
- excluded.add(BuiltinFunctions.MISSING_IF);
- excluded.add(BuiltinFunctions.NAN_IF);
- excluded.add(BuiltinFunctions.NEGINF_IF);
- excluded.add(BuiltinFunctions.NULL_IF);
- excluded.add(BuiltinFunctions.POSINF_IF);
+ // those are the functions that need IATypes of their args and use them in the function constructor
+ private void buildFunctionsRequiringTypes(Set<FunctionIdentifier> functionsRequiringTypes) {
+ functionsRequiringTypes.add(BuiltinFunctions.ARRAY_POSITION);
+ functionsRequiringTypes.add(BuiltinFunctions.ARRAY_CONTAINS);
+ functionsRequiringTypes.add(BuiltinFunctions.ARRAY_SORT);
+ functionsRequiringTypes.add(BuiltinFunctions.ARRAY_DISTINCT);
+ functionsRequiringTypes.add(BuiltinFunctions.EQ);
+ functionsRequiringTypes.add(BuiltinFunctions.LT);
+ functionsRequiringTypes.add(BuiltinFunctions.GT);
+ functionsRequiringTypes.add(BuiltinFunctions.GE);
+ functionsRequiringTypes.add(BuiltinFunctions.LE);
+ functionsRequiringTypes.add(BuiltinFunctions.NEQ);
+ functionsRequiringTypes.add(BuiltinFunctions.MISSING_IF);
+ functionsRequiringTypes.add(BuiltinFunctions.NAN_IF);
+ functionsRequiringTypes.add(BuiltinFunctions.NEGINF_IF);
+ functionsRequiringTypes.add(BuiltinFunctions.NULL_IF);
+ functionsRequiringTypes.add(BuiltinFunctions.POSINF_IF);
}
}
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.1.ddl.sqlpp
index 257c4dd..5234562 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.2.update.sqlpp
index 4a0e7ed..4aee1aa 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.2.update.sqlpp
@@ -20,3 +20,18 @@
use TinySocial;
load dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`));
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] ]},
+{"id": 3, "list_f": [ 1 , 2 ]},
+{"id": 4, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 5, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]},
+{"id": 6, "list_f": null},
+{"id": 7}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 2, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]}
+]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.4.query.sqlpp
index d5f9bb38b..059558a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.4.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.4.query.sqlpp
@@ -19,9 +19,25 @@
/*
* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is [2,3]
+* Expected Res : Success
*/
use TinySocial;
-select array_contains([5,1,9], [2,3]);
\ No newline at end of file
+{
+ "t1": (select array_contains([1, [2,3], 5], [2,3])),
+ "t2": (select array_contains([1, [2,3.0], 5], [2,3])),
+ "t3": (select array_contains([1, [2,3.8], 5], [2,3.8])),
+ "t4": (select array_contains([ [7,4,3], [1], [9,2], [4,0,2,2] ], [9,2])),
+ "t5": (select array_contains([ [7,4,3], [1], [9,2], [4,0,2,2] ], [2,9])),
+ "t6": (select array_contains([ [7,4,3], [1], [9,2], [4,0,2,2] ], [9,3])),
+ "t7": (select array_contains([ ["green","black"], "yellow", ["blue", "orange"] ], ["blue","orange"])),
+ "t8": (select array_contains([ ["green","black"], ["yellow"], ["blue", "orange"] ], ["blue","orange"])),
+ "t9": (select array_contains([ ["green","black"], "yellow", ["blue", "orange"] ], ["Blue","orange"])),
+ "t10": (select array_contains([9,2], [9,2])),
+ "t11": (from openDs select id, array_contains(list_f, [9999,3]) order by id),
+ "t12": (from openDs select id, array_contains(list_f, ["red", "black"]) order by id),
+ "t13": (from openDs select id, array_contains(list_f, {"state": "CA", "country": "US", "zip_code": 92863}) order by id),
+ "t14": (from closedDs select id, array_contains(list_f, {"state": "CA", "country": "US", "zip_code": 92863}) order by id),
+ "t15": (from closedDs select id, array_contains(list_f, {"state": "OR", "country": "US"}) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.6.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.5.ddl.sqlpp
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.6.ddl.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.5.ddl.sqlpp
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.5.query.sqlpp
deleted file mode 100755
index afecfb6..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_contains/array_contains.5.query.sqlpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
-* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is {"id": 5}
-*/
-
-use TinySocial;
-
-select array_contains([5,{"id": 5},9], {"id": 5});
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.2.update.sqlpp
index d666e41..8a3eb87 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.2.update.sqlpp
@@ -24,4 +24,16 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones", "John Green", "Emily Jones", "sth"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] , [5,1], [4,2], [5,1], [1,2] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] , ["blue", "orange"] , ["red", "black"]]},
+{"id": 3, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]},
+{"id": 4, "list_f": null},
+{"id": 5}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.4.query.sqlpp
index 4773079..ad6c9df 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.4.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.4.query.sqlpp
@@ -19,9 +19,14 @@
/*
* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is [5]
+* Expected Res : Success
*/
use TinySocial;
-select array_distinct([19, 3, [5]]);
\ No newline at end of file
+{
+ "t1": (array_distinct([ [5,1], [6,2], [9,7], [6,2], [10,11], [6,2], [0,0] ])),
+ "t2": (array_distinct([ {"id": 1, "age": 34}, {"id": 2, "age": 29}, {"id": 3, "age": 90}, {"id": 2, "age": 29}, {"id": 1, "age": 34}])),
+ "t3": (from openDs select array_distinct(list_f) order by id),
+ "t4": (from closedDs select array_distinct(list_f) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.6.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.5.ddl.sqlpp
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.6.ddl.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.5.ddl.sqlpp
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.5.query.sqlpp
deleted file mode 100755
index 0a8bdd0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_distinct/array_distinct.5.query.sqlpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
-* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is {"id": 5}
-*/
-
-use TinySocial;
-
-select array_distinct([19, 3, {"id": 5}]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.2.update.sqlpp
index 1c4bad0..210103a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.2.update.sqlpp
@@ -24,4 +24,16 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] , [5,1], [4,2], [5,1], [1,2] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] , ["blue", "orange"] , ["red", "black"]]},
+{"id": 3, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]},
+{"id": 4, "list_f": null},
+{"id": 5}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.5.query.sqlpp
index e8df7a8..9a7ef85 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.5.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_intersect/array_intersect.5.query.sqlpp
@@ -19,9 +19,16 @@
/*
* Description : Testing deep equality
-* Expected Res : Error as deep equality is not yet supported
+* Expected Res : Success
*/
use TinySocial;
-select array_intersect([3,5,1], [2,1], [5, [3,2]]);
\ No newline at end of file
+{
+ "t1": (array_intersect([5,[1,2]], [[1,2],8,5], [[1,3],5,[1,2]])),
+ "t2": (array_intersect([[5,5],[1,2]], [[1,2],[8,5]], [[1,3],[5,5],[1,2]])),
+ "t3": (array_intersect([{"id": 1, "age": 34}, {"id": 2, "age": 29}], [{"id": 3, "age": 90}, {"id": 2, "age": 29}], [{"id": 2, "age": 29}, {"id": 1, "age": 34}])),
+ "t4": (from openDs select array_intersect(list_f, [ [9999,3], [1,2] ], [[9999,3]]) order by id),
+ "t5": (from openDs select array_intersect(list_f, [ {"state": "OH", "country": "US"} , {"state": "IL", "country": "US", "zip_code": 92863} ], [ {"state": "OH", "country": "US"}]) order by id),
+ "t6": (from closedDs select array_intersect(list_f, [ {"state": "OH", "country": "US"} , {"state": "IL", "country": "US", "zip_code": 92863} ], [ {"state": "OH", "country": "US"}]) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.1.ddl.sqlpp
index 257c4dd..5234562 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.2.update.sqlpp
index 4a0e7ed..4aee1aa 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.2.update.sqlpp
@@ -20,3 +20,18 @@
use TinySocial;
load dataset TweetMessages using localfs ((`path`=`asterix_nc1://data/tinysocial/twm.adm`),(`format`=`adm`));
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] ]},
+{"id": 3, "list_f": [ 1 , 2 ]},
+{"id": 4, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 5, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]},
+{"id": 6, "list_f": null},
+{"id": 7}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 2, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]}
+]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.4.query.sqlpp
index 429747e..d83db6e 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.4.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.4.query.sqlpp
@@ -19,9 +19,25 @@
/*
* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is [2,3]
+* Expected Res : Success
*/
use TinySocial;
-select array_position([5,1,9], [2,3]);
\ No newline at end of file
+{
+ "t1": (select array_position([1, [2,3], 5], [2,3])),
+ "t2": (select array_position([1, [2,3.0], 5], [2,3])),
+ "t3": (select array_position([1, [2,3.8], 5], [2,3.8])),
+ "t4": (select array_position([ [7,4,3], [1], [9,2], [4,0,2,2] ], [9,2])),
+ "t5": (select array_position([ [7,4,3], [1], [9,2], [4,0,2,2] ], [2,9])),
+ "t6": (select array_position([ [7,4,3], [1], [9,2], [4,0,2,2] ], [9,3])),
+ "t7": (select array_position([ ["green","black"], "yellow", ["blue", "orange"] ], ["blue","orange"])),
+ "t8": (select array_position([ ["green","black"], ["yellow"], ["blue", "orange"] ], ["blue","orange"])),
+ "t9": (select array_position([ ["green","black"], "yellow", ["blue", "orange"] ], ["Blue","orange"])),
+ "t10": (select array_position([9,2], [9,2])),
+ "t11": (from openDs select id, array_position(list_f, [1,2,1]) order by id),
+ "t12": (from openDs select id, array_position(list_f, ["red", "black"]) order by id),
+ "t13": (from openDs select id, array_position(list_f, {"state": "CA", "country": "US", "zip_code": 92863}) order by id),
+ "t14": (from closedDs select id, array_position(list_f, {"state": "CA", "country": "US", "zip_code": 92863}) order by id),
+ "t15": (from closedDs select id, array_position(list_f, {"state": "OR", "country": "US"}) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.6.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.5.ddl.sqlpp
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.6.ddl.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.5.ddl.sqlpp
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.5.query.sqlpp
deleted file mode 100755
index 4a657a5..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_position/array_position.5.query.sqlpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
-* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is {"id": 5}
-*/
-
-use TinySocial;
-
-select array_position([5,{"id": 5},9], {"id": 5});
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.2.update.sqlpp
index 1c4bad0..7e8e5ba 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.2.update.sqlpp
@@ -24,4 +24,19 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] ]},
+{"id": 3, "list_f": [ 1 , 2 ]},
+{"id": 4, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 5, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]},
+{"id": 6, "list_f": null},
+{"id": 7}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 2, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.4.query.sqlpp
index 8eee258..61e41cf 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.4.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.4.query.sqlpp
@@ -19,9 +19,15 @@
/*
* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is coming from a sub-query
+* Expected Res : Success
*/
use TinySocial;
-select array_put([3, "John"], (select value v.compType from d1 v));
\ No newline at end of file
+{
+ "t1": (array_put([1,2,3, [9,8]], 5, ["adding a list", "yes"])),
+ "t2": (array_put([ [5,1,2] , [3,2] , [90,100] ], [3,2], [80,100])),
+ "t3": (array_put([ {"id": 1, "age": 34}, {"id": 2, "age": 29}, {"id": 3, "age": 90}], {"id": 4, "age": 90}, {"id": 2, "age": 29})),
+ "t4": (from openDs select array_put(list_f, [9999,3], {"state": "OH", "country": "US"}) order by id),
+ "t5": (from closedDs select array_put(list_f, [9999,3], {"state": "OH", "country": "US"}) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.6.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.5.ddl.sqlpp
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.6.ddl.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.5.ddl.sqlpp
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.5.query.sqlpp
deleted file mode 100755
index 61c7d47..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_put/array_put.5.query.sqlpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
-* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is [9]
-*/
-
-use TinySocial;
-
-select array_put([3], 3, [9], 4, "sth");
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.2.update.sqlpp
index 1c4bad0..7e8e5ba 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.2.update.sqlpp
@@ -24,4 +24,19 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] ]},
+{"id": 3, "list_f": [ 1 , 2 ]},
+{"id": 4, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 5, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]},
+{"id": 6, "list_f": null},
+{"id": 7}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 2, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.4.query.sqlpp
index c684b1b..efaaa85 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.4.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.4.query.sqlpp
@@ -19,9 +19,15 @@
/*
* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is coming from a sub-query
+* Expected Res : Success
*/
use TinySocial;
-select array_remove([3, "John"], (select value v.compType from d1 v));
\ No newline at end of file
+{
+ "t1": (array_remove([1,2,3, [9,8], ["str1", "str2"], [90,100]], [9,8], [90,100])),
+ "t2": (array_remove([ [5,1,2] , [3,2] , [90,100] ], [3,2], [80,100])),
+ "t3": (array_remove([ {"id": 1, "age": 34}, {"id": 2, "age": 29}, {"id": 3, "age": 90}], {"id": 4, "age": 90}, {"id": 2, "age": 29})),
+ "t4": (from openDs select array_remove(list_f, [9999,3], {"state": "OH", "country": "US"}) order by id),
+ "t5": (from closedDs select array_remove(list_f, [9999,3], {"state": "OH", "country": "US"}) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.6.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.5.ddl.sqlpp
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.6.ddl.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.5.ddl.sqlpp
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.5.query.sqlpp
deleted file mode 100755
index e79c163..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_remove/array_remove.5.query.sqlpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
-* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is [9]
-*/
-
-use TinySocial;
-
-select array_remove([3], 3, [9], 4, "sth");
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.2.update.sqlpp
index 1c4bad0..7e8e5ba 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.2.update.sqlpp
@@ -24,4 +24,19 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] ]},
+{"id": 3, "list_f": [ 1 , 2 ]},
+{"id": 4, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 5, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]},
+{"id": 6, "list_f": null},
+{"id": 7}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} ]},
+{"id": 2, "list_f": [ {"state": "OR", "country": "US", "zip_code": null} , {"state": "IL", "country": "US", "zip_code": 92863} ]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.4.query.sqlpp
index 7cd1cd3..922c6a8 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.4.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_replace/array_replace.4.query.sqlpp
@@ -19,9 +19,15 @@
/*
* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values
+* Expected Res : Success
*/
use TinySocial;
-select array_replace([3,2,3], [3], 9);
\ No newline at end of file
+{
+ "t1": (array_replace([ [5,1], [6,2], [9,7], [6,2], [10,11]], [6,2], [0,0])),
+ "t2": (array_replace([ {"id": 1, "age": 34}, {"id": 2, "age": 29}, {"id": 3, "age": 90}, {"id": 4, "age": 10}], {"id": 2, "age": 29}, {"id": 8, "age": 200})),
+ "t3": (from openDs select array_replace(list_f, [9999,3], "replace done") order by id),
+ "t4": (from openDs select array_replace(list_f, {"state": "OH", "country": "US"}, "replace done") order by id),
+ "t5": (from closedDs select array_replace(list_f, {"state": "OH", "country": "US"}, "replace done") order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.2.update.sqlpp
index 1426f85..293b0ac 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.2.update.sqlpp
@@ -24,4 +24,16 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones", "Abby"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] , [5,1], [4,2], [5,1], [1,2] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] , ["blue", "orange"] ]},
+{"id": 3, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "CA", "country": "US", "zip_code": 12863}]},
+{"id": 4, "list_f": null},
+{"id": 5}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "CA", "country": "US", "zip_code": 12863}]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.4.query.sqlpp
index 65b0521..e3a0a4b 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.4.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.4.query.sqlpp
@@ -19,9 +19,14 @@
/*
* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is [5]
+* Expected Res : Success
*/
use TinySocial;
-select array_sort([19, 3, [5]]);
\ No newline at end of file
+{
+ "t1": (array_sort([ [5,1], [6,2], [9,7], [6,2], [10,11], [6,2], [0,0] ])),
+ "t2": (array_sort([ {"id": 1, "age": 34}, {"id": 2, "age": 29}, {"id": 3, "age": 90}, {"id": 4, "age": 10}, {"id": 5, "age": 90}])),
+ "t3": (from openDs select array_sort(list_f) order by id),
+ "t4": (from closedDs select array_sort(list_f) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.6.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.5.ddl.sqlpp
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.6.ddl.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.5.ddl.sqlpp
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.5.query.sqlpp
deleted file mode 100755
index cc1745e..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_sort/array_sort.5.query.sqlpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
-* Description : Testing an array function that needs to compare elements
-* Expected Res : Error due to comparing non-primitive values, which is {"id": 5}
-*/
-
-use TinySocial;
-
-select array_sort([19, 3, {"id": 5}]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.2.update.sqlpp
index 1c4bad0..210103a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.2.update.sqlpp
@@ -24,4 +24,16 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] , [5,1], [4,2], [5,1], [1,2] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] , ["blue", "orange"] , ["red", "black"]]},
+{"id": 3, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]},
+{"id": 4, "list_f": null},
+{"id": 5}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.5.query.sqlpp
index f74b160..01e93e7 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.5.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiff/array_symdiff.5.query.sqlpp
@@ -19,9 +19,16 @@
/*
* Description : Testing deep equality
-* Expected Res : Error as deep equality is not yet supported
+* Expected Res : Success
*/
use TinySocial;
-select array_symdiff([3,5,1], [2,1], [5, [3,2]]);
\ No newline at end of file
+{
+ "t1": (array_symdiff([5,[1,2]], [[1,2],8,5], [[1,3],5,[1,2]])),
+ "t2": (array_symdiff([[5,5],[1,2]], [[1,2],[8,5]], [[1,3],[5,5],[1,2]])),
+ "t3": (array_symdiff([{"id": 1, "age": 34}, {"id": 2, "age": 29}], [{"id": 3, "age": 90}, {"id": 2, "age": 29}], [{"id": 2, "age": 29}, {"id": 1, "age": 34}])),
+ "t4": (from openDs select array_symdiff(list_f, [ [9999,3], [1,2] ], [[9999,3]]) order by id),
+ "t5": (from openDs select array_symdiff(list_f, [ {"state": "OH", "country": "US"} , {"state": "IL", "country": "US", "zip_code": 92863} ], [ {"state": "OH", "country": "US"}]) order by id),
+ "t6": (from closedDs select array_symdiff(list_f, [ {"state": "OH", "country": "US"} , {"state": "IL", "country": "US", "zip_code": 92863} ], [ {"state": "OH", "country": "US"}]) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.2.update.sqlpp
index 1c4bad0..210103a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.2.update.sqlpp
@@ -24,4 +24,16 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] , [5,1], [4,2], [5,1], [1,2] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] , ["blue", "orange"] , ["red", "black"]]},
+{"id": 3, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]},
+{"id": 4, "list_f": null},
+{"id": 5}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.5.query.sqlpp
index c2b01c8..0df00e1 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.5.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_symdiffn/array_symdiffn.5.query.sqlpp
@@ -19,9 +19,16 @@
/*
* Description : Testing deep equality
-* Expected Res : Error as deep equality is not yet supported
+* Expected Res : Success
*/
use TinySocial;
-select array_symdiffn([3,5,1], [2,1], [5, [3,2]]);
\ No newline at end of file
+{
+ "t1": (array_symdiffn([5,[1,2]], [[1,2],8,5], [[1,3],5,[1,2]])),
+ "t2": (array_symdiffn([[5,5],[1,2]], [[1,2],[8,5]], [[1,3],[5,5],[1,2]])),
+ "t3": (array_symdiffn([{"id": 1, "age": 34}, {"id": 2, "age": 29}], [{"id": 3, "age": 90}, {"id": 2, "age": 29}], [{"id": 2, "age": 29}, {"id": 1, "age": 34}])),
+ "t4": (from openDs select array_symdiffn(list_f, [ [9999,3], [1,2] ], [[9999,3]]) order by id),
+ "t5": (from openDs select array_symdiffn(list_f, [ {"state": "OH", "country": "US"} , {"state": "IL", "country": "US", "zip_code": 92863}], [ {"state": "OH", "country": "US"}]) order by id),
+ "t6": (from closedDs select array_symdiffn(list_f, [ {"state": "OH", "country": "US"} , {"state": "IL", "country": "US", "zip_code": 92863}], [ {"state": "OH", "country": "US"}]) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.1.ddl.sqlpp
index 1c55a9a..601eb0c 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.1.ddl.sqlpp
@@ -22,6 +22,12 @@
use TinySocial;
+create type addressType as closed {state: string, country: string, zip_code: int?};
+create type openType as {id: int};
+create type closedType as closed {id: int, list_f: [addressType]};
+
+create dataset openDs(openType) primary key id;
+create dataset closedDs(closedType) primary key id;
create type TinySocial.TwitterUserType as
{
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.2.update.sqlpp
index 1c4bad0..210103a 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.2.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.2.update.sqlpp
@@ -24,4 +24,16 @@
insert into d1([
{"id":1, "compType":{"sth":33}},
{"id":2, "compType":{"sth":44}, "followers":["John Green", "Emily Jones"]}
+]);
+
+insert into openDs([
+{"id": 1, "list_f": [ [1,2,1], [9999,3] , [5,1], [4,2], [5,1], [1,2] ]},
+{"id": 2, "list_f": [ ["white","blue","magenta"], ["red", "black"] , ["blue", "orange"] , ["red", "black"]]},
+{"id": 3, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]},
+{"id": 4, "list_f": null},
+{"id": 5}
+]);
+
+insert into closedDs([
+{"id": 1, "list_f": [ {"state": "OH", "country": "US"} , {"state": "CA", "country": "US", "zip_code": 92863} , {"state": "OH", "country": "US"}]}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.5.query.sqlpp
index 06797db..0791cb5 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.5.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_union/array_union.5.query.sqlpp
@@ -19,9 +19,16 @@
/*
* Description : Testing deep equality
-* Expected Res : Error as deep equality is not yet supported
+* Expected Res : Success
*/
use TinySocial;
-select array_union([3,5,1], [2,1], [5, [3,2]]);
\ No newline at end of file
+{
+ "t1": (array_union([5,[1,2]], [[1,2],8,5], [[1,3],5,[1,2]])),
+ "t2": (array_union([[5,5],[1,2]], [[1,2],[8,5]], [[1,3],[5,5],[1,2]])),
+ "t3": (array_union([{"id": 1, "age": 34}, {"id": 2, "age": 29}], [{"id": 3, "age": 90}, {"id": 2, "age": 29}], [{"id": 7, "age": 29}, {"id": 1, "age": 34}])),
+ "t4": (from openDs select array_union(list_f, [ [8888,3], [1,2] ], [[9999,3]]) order by id),
+ "t5": (from openDs select array_union(list_f, [ {"state": "OH", "country": "US"} , {"state": "IL", "country": "US", "zip_code": 92863}], [ {"state": "OH", "country": "US"}]) order by id),
+ "t6": (from closedDs select array_union(list_f, [ {"state": "OH", "country": "US"} , {"state": "IL", "country": "US", "zip_code": 92863}], [ {"state": "OH", "country": "US"}]) order by id)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_contains/array_contains.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_contains/array_contains.4.adm
new file mode 100644
index 0000000..4696273
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_contains/array_contains.4.adm
@@ -0,0 +1 @@
+{ "t1": [ { "$1": true } ], "t2": [ { "$2": true } ], "t3": [ { "$3": true } ], "t4": [ { "$4": true } ], "t5": [ { "$5": false } ], "t6": [ { "$6": false } ], "t7": [ { "$7": true } ], "t8": [ { "$8": true } ], "t9": [ { "$9": false } ], "t10": [ { "$10": false } ], "t11": [ { "id": 1, "$11": true }, { "id": 2, "$11": false }, { "id": 3, "$11": false }, { "id": 4, "$11": false }, { "id": 5, "$11": false }, { "id": 6, "$11": null }, { "id": 7 } ], "t12": [ { "id": 1, "$12": false }, { "id": 2, "$12": true }, { "id": 3, "$12": false }, { "id": 4, "$12": false }, { "id": 5, "$12": false }, { "id": 6, "$12": null }, { "id": 7 } ], "t13": [ { "id": 1, "$13": false }, { "id": 2, "$13": false }, { "id": 3, "$13": false }, { "id": 4, "$13": true }, { "id": 5, "$13": false }, { "id": 6, "$13": null }, { "id": 7 } ], "t14": [ { "id": 1, "$14": true }, { "id": 2, "$14": false } ], "t15": [ { "id": 1, "$15": false }, { "id": 2, "$15": false } ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_distinct/array_distinct.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_distinct/array_distinct.4.adm
new file mode 100644
index 0000000..39263f4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_distinct/array_distinct.4.adm
@@ -0,0 +1 @@
+{ "t1": [ [ 5, 1 ], [ 6, 2 ], [ 9, 7 ], [ 10, 11 ], [ 0, 0 ] ], "t2": [ { "id": 1, "age": 34 }, { "id": 2, "age": 29 }, { "id": 3, "age": 90 } ], "t3": [ { "$1": [ [ 1, 2, 1 ], [ 9999, 3 ], [ 5, 1 ], [ 4, 2 ], [ 1, 2 ] ] }, { "$1": [ [ "white", "blue", "magenta" ], [ "red", "black" ], [ "blue", "orange" ] ] }, { "$1": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 } ] }, { "$1": null }, { } ], "t4": [ { "$2": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 } ] } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_intersect/array_intersect.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_intersect/array_intersect.4.adm
new file mode 100644
index 0000000..02e02d5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_intersect/array_intersect.4.adm
@@ -0,0 +1 @@
+{ "t1": [ 5, [ 1, 2 ] ], "t2": [ [ 1, 2 ] ], "t3": [ { "id": 2, "age": 29 } ], "t4": [ { "$1": [ [ 9999, 3 ] ] }, { "$1": [ ] }, { "$1": [ ] }, { "$1": null }, { } ], "t5": [ { "$2": [ ] }, { "$2": [ ] }, { "$2": [ { "state": "OH", "country": "US" } ] }, { "$2": null }, { } ], "t6": [ { "$3": [ { "state": "OH", "country": "US" } ] } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_position/array_position.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_position/array_position.4.adm
new file mode 100644
index 0000000..b8c398d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_position/array_position.4.adm
@@ -0,0 +1 @@
+{ "t1": [ { "$1": 1 } ], "t2": [ { "$2": 1 } ], "t3": [ { "$3": 1 } ], "t4": [ { "$4": 2 } ], "t5": [ { "$5": -1 } ], "t6": [ { "$6": -1 } ], "t7": [ { "$7": 2 } ], "t8": [ { "$8": 2 } ], "t9": [ { "$9": -1 } ], "t10": [ { "$10": -1 } ], "t11": [ { "id": 1, "$11": 0 }, { "id": 2, "$11": -1 }, { "id": 3, "$11": -1 }, { "id": 4, "$11": -1 }, { "id": 5, "$11": -1 }, { "id": 6, "$11": null }, { "id": 7 } ], "t12": [ { "id": 1, "$12": -1 }, { "id": 2, "$12": 1 }, { "id": 3, "$12": -1 }, { "id": 4, "$12": -1 }, { "id": 5, "$12": -1 }, { "id": 6, "$12": null }, { "id": 7 } ], "t13": [ { "id": 1, "$13": -1 }, { "id": 2, "$13": -1 }, { "id": 3, "$13": -1 }, { "id": 4, "$13": 1 }, { "id": 5, "$13": -1 }, { "id": 6, "$13": null }, { "id": 7 } ], "t14": [ { "id": 1, "$14": 1 }, { "id": 2, "$14": -1 } ], "t15": [ { "id": 1, "$15": -1 }, { "id": 2, "$15": -1 } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_put/array_put.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_put/array_put.4.adm
new file mode 100644
index 0000000..fd75f1e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_put/array_put.4.adm
@@ -0,0 +1 @@
+{ "t1": [ 1, 2, 3, [ 9, 8 ], 5, [ "adding a list", "yes" ] ], "t2": [ [ 5, 1, 2 ], [ 3, 2 ], [ 90, 100 ], [ 80, 100 ] ], "t3": [ { "id": 1, "age": 34 }, { "id": 2, "age": 29 }, { "id": 3, "age": 90 }, { "id": 4, "age": 90 } ], "t4": [ { "$1": [ [ 1, 2, 1 ], [ 9999, 3 ], { "state": "OH", "country": "US" } ] }, { "$1": [ [ "white", "blue", "magenta" ], [ "red", "black" ], [ 9999, 3 ], { "state": "OH", "country": "US" } ] }, { "$1": [ 1, 2, [ 9999, 3 ], { "state": "OH", "country": "US" } ] }, { "$1": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, [ 9999, 3 ] ] }, { "$1": [ { "state": "OR", "country": "US", "zip_code": null }, { "state": "IL", "country": "US", "zip_code": 92863 }, [ 9999, 3 ], { "state": "OH", "country": "US" } ] }, { "$1": null }, { } ], "t5": [ { "$2": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, [ 9999, 3 ] ] }, { "$2": [ { "state": "OR", "country": "US", "zip_code": null }, { "state": "IL", "country": "US", "zip_code": 92863 }, [ 9999, 3 ], { "state": "OH", "country": "US" } ] } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_remove/array_remove.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_remove/array_remove.4.adm
new file mode 100644
index 0000000..7e42853e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_remove/array_remove.4.adm
@@ -0,0 +1 @@
+{ "t1": [ 1, 2, 3, [ "str1", "str2" ] ], "t2": [ [ 5, 1, 2 ], [ 90, 100 ] ], "t3": [ { "id": 1, "age": 34 }, { "id": 3, "age": 90 } ], "t4": [ { "$1": [ [ 1, 2, 1 ] ] }, { "$1": [ [ "white", "blue", "magenta" ], [ "red", "black" ] ] }, { "$1": [ 1, 2 ] }, { "$1": [ { "state": "CA", "country": "US", "zip_code": 92863 } ] }, { "$1": [ { "state": "OR", "country": "US", "zip_code": null }, { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$1": null }, { } ], "t5": [ { "$2": [ { "state": "CA", "country": "US", "zip_code": 92863 } ] }, { "$2": [ { "state": "OR", "country": "US", "zip_code": null }, { "state": "IL", "country": "US", "zip_code": 92863 } ] } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_replace/array_replace.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_replace/array_replace.4.adm
new file mode 100644
index 0000000..9932af1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_replace/array_replace.4.adm
@@ -0,0 +1 @@
+{ "t1": [ [ 5, 1 ], [ 0, 0 ], [ 9, 7 ], [ 0, 0 ], [ 10, 11 ] ], "t2": [ { "id": 1, "age": 34 }, { "id": 8, "age": 200 }, { "id": 3, "age": 90 }, { "id": 4, "age": 10 } ], "t3": [ { "$1": [ [ 1, 2, 1 ], "replace done" ] }, { "$1": [ [ "white", "blue", "magenta" ], [ "red", "black" ] ] }, { "$1": [ 1, 2 ] }, { "$1": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 } ] }, { "$1": [ { "state": "OR", "country": "US", "zip_code": null }, { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$1": null }, { } ], "t4": [ { "$2": [ [ 1, 2, 1 ], [ 9999, 3 ] ] }, { "$2": [ [ "white", "blue", "magenta" ], [ "red", "black" ] ] }, { "$2": [ 1, 2 ] }, { "$2": [ "replace done", { "state": "CA", "country": "US", "zip_code": 92863 } ] }, { "$2": [ { "state": "OR", "country": "US", "zip_code": null }, { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": null }, { } ], "t5": [ { "$3": [ "replace done", { "state": "CA", "country": "US", "zip_code": 92863 } ] }, { "$3": [ { "state": "OR", "country": "US", "zip_code": null }, { "state": "IL", "country": "US", "zip_code": 92863 } ] } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_sort/array_sort.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_sort/array_sort.4.adm
new file mode 100644
index 0000000..2303896
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_sort/array_sort.4.adm
@@ -0,0 +1 @@
+{ "t1": [ [ 0, 0 ], [ 5, 1 ], [ 6, 2 ], [ 6, 2 ], [ 6, 2 ], [ 9, 7 ], [ 10, 11 ] ], "t2": [ { "id": 4, "age": 10 }, { "id": 2, "age": 29 }, { "id": 1, "age": 34 }, { "id": 3, "age": 90 }, { "id": 5, "age": 90 } ], "t3": [ { "$1": [ [ 1, 2 ], [ 1, 2, 1 ], [ 4, 2 ], [ 5, 1 ], [ 5, 1 ], [ 9999, 3 ] ] }, { "$1": [ [ "blue", "orange" ], [ "red", "black" ], [ "white", "blue", "magenta" ] ] }, { "$1": [ { "state": "CA", "country": "US", "zip_code": 12863 }, { "state": "CA", "country": "US", "zip_code": 92863 }, { "state": "OH", "country": "US" } ] }, { "$1": null }, { } ], "t4": [ { "$2": [ { "state": "CA", "country": "US", "zip_code": 12863 }, { "state": "CA", "country": "US", "zip_code": 92863 }, { "state": "OH", "country": "US" } ] } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiff/array_symdiff.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiff/array_symdiff.4.adm
new file mode 100644
index 0000000..56a8edc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiff/array_symdiff.4.adm
@@ -0,0 +1 @@
+{ "t1": [ 8, [ 1, 3 ] ], "t2": [ [ 8, 5 ], [ 1, 3 ] ], "t3": [ { "id": 3, "age": 90 } ], "t4": [ { "$1": [ [ 1, 2, 1 ], [ 5, 1 ], [ 4, 2 ] ] }, { "$1": [ [ "white", "blue", "magenta" ], [ "red", "black" ], [ "blue", "orange" ], [ 1, 2 ] ] }, { "$1": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, [ 1, 2 ] ] }, { "$1": null }, { } ], "t5": [ { "$2": [ [ 1, 2, 1 ], [ 9999, 3 ], [ 5, 1 ], [ 4, 2 ], [ 1, 2 ], { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": [ [ "white", "blue", "magenta" ], [ "red", "black" ], [ "blue", "orange" ], { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": [ { "state": "CA", "country": "US", "zip_code": 92863 }, { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": null }, { } ], "t6": [ { "$3": [ { "state": "CA", "country": "US", "zip_code": 92863 }, { "state": "IL", "country": "US", "zip_code": 92863 } ] } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiffn/array_symdiffn.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiffn/array_symdiffn.4.adm
new file mode 100644
index 0000000..c65e99d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_symdiffn/array_symdiffn.4.adm
@@ -0,0 +1 @@
+{ "t1": [ 5, [ 1, 2 ], 8, [ 1, 3 ] ], "t2": [ [ 1, 2 ], [ 8, 5 ], [ 1, 3 ] ], "t3": [ { "id": 2, "age": 29 }, { "id": 3, "age": 90 } ], "t4": [ { "$1": [ [ 1, 2, 1 ], [ 9999, 3 ], [ 5, 1 ], [ 4, 2 ] ] }, { "$1": [ [ "white", "blue", "magenta" ], [ "red", "black" ], [ "blue", "orange" ], [ 1, 2 ] ] }, { "$1": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, [ 1, 2 ] ] }, { "$1": null }, { } ], "t5": [ { "$2": [ [ 1, 2, 1 ], [ 9999, 3 ], [ 5, 1 ], [ 4, 2 ], [ 1, 2 ], { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": [ [ "white", "blue", "magenta" ], [ "red", "black" ], [ "blue", "orange" ], { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": null }, { } ], "t6": [ { "$3": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, { "state": "IL", "country": "US", "zip_code": 92863 } ] } ] }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_union/array_union.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_union/array_union.4.adm
new file mode 100644
index 0000000..f39e5a8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_union/array_union.4.adm
@@ -0,0 +1 @@
+{ "t1": [ 5, [ 1, 2 ], 8, [ 1, 3 ] ], "t2": [ [ 5, 5 ], [ 1, 2 ], [ 8, 5 ], [ 1, 3 ] ], "t3": [ { "id": 1, "age": 34 }, { "id": 2, "age": 29 }, { "id": 3, "age": 90 }, { "id": 7, "age": 29 } ], "t4": [ { "$1": [ [ 1, 2, 1 ], [ 9999, 3 ], [ 5, 1 ], [ 4, 2 ], [ 1, 2 ], [ 8888, 3 ] ] }, { "$1": [ [ "white", "blue", "magenta" ], [ "red", "black" ], [ "blue", "orange" ], [ 8888, 3 ], [ 1, 2 ], [ 9999, 3 ] ] }, { "$1": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, [ 8888, 3 ], [ 1, 2 ], [ 9999, 3 ] ] }, { "$1": null }, { } ], "t5": [ { "$2": [ [ 1, 2, 1 ], [ 9999, 3 ], [ 5, 1 ], [ 4, 2 ], [ 1, 2 ], { "state": "OH", "country": "US" }, { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": [ [ "white", "blue", "magenta" ], [ "red", "black" ], [ "blue", "orange" ], { "state": "OH", "country": "US" }, { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, { "state": "IL", "country": "US", "zip_code": 92863 } ] }, { "$2": null }, { } ], "t6": [ { "$3": [ { "state": "OH", "country": "US" }, { "state": "CA", "country": "US", "zip_code": 92863 }, { "state": "IL", "country": "US", "zip_code": 92863 } ] } ] }
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 69bc647..a2f30ad 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -2655,8 +2655,6 @@
<test-case FilePath="array_fun">
<compilation-unit name="array_position">
<output-dir compare="Text">array_position</output-dir>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
@@ -2672,8 +2670,6 @@
<test-case FilePath="array_fun">
<compilation-unit name="array_contains">
<output-dir compare="Text">array_contains</output-dir>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
@@ -2684,29 +2680,21 @@
<test-case FilePath="array_fun">
<compilation-unit name="array_put">
<output-dir compare="Text">array_put</output-dir>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
<compilation-unit name="array_remove">
<output-dir compare="Text">array_remove</output-dir>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
<compilation-unit name="array_distinct">
<output-dir compare="Text">array_distinct</output-dir>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
<compilation-unit name="array_sort">
<output-dir compare="Text">array_sort</output-dir>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
@@ -2729,7 +2717,6 @@
<compilation-unit name="array_intersect">
<output-dir compare="Text">array_intersect</output-dir>
<expected-error>Input contains different list types (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
@@ -2742,7 +2729,6 @@
<test-case FilePath="array_fun">
<compilation-unit name="array_replace">
<output-dir compare="Text">array_replace</output-dir>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
<expected-error>Invalid number of arguments for function array-replace (in line 27, at column 8)</expected-error>
<expected-error>Invalid number of arguments for function array-replace (in line 27, at column 8)</expected-error>
</compilation-unit>
@@ -2756,21 +2742,18 @@
<compilation-unit name="array_symdiff">
<output-dir compare="Text">array_symdiff</output-dir>
<expected-error>Input contains different list types (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
<compilation-unit name="array_symdiffn">
<output-dir compare="Text">array_symdiffn</output-dir>
<expected-error>Input contains different list types (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
<compilation-unit name="array_union">
<output-dir compare="Text">array_union</output-dir>
<expected-error>Input contains different list types (in line 27, at column 8)</expected-error>
- <expected-error>Cannot compare non-primitive values (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/aggregates/ScalarSTUnionDistinctAggregateDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/aggregates/ScalarSTUnionDistinctAggregateDescriptor.java
index 1c84bfd..49231ea 100644
--- a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/aggregates/ScalarSTUnionDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/aggregates/ScalarSTUnionDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.scalar.AbstractScalarDistinctAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSTUnionDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_ST_UNION_AGG_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSTUnionDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSTUnionDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSTUnionDistinctAggregateDescriptor() {
super(STUnionAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/AbstractScalarDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/AbstractScalarDistinctAggregateDescriptor.java
index 2876d40..23c4e89 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/AbstractScalarDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/AbstractScalarDistinctAggregateDescriptor.java
@@ -20,6 +20,7 @@
package org.apache.asterix.runtime.aggregates.scalar;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.unnestingfunctions.std.ScanCollectionDescriptor;
import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -29,15 +30,21 @@
public abstract class AbstractScalarDistinctAggregateDescriptor extends AbstractScalarAggregateDescriptor {
private static final long serialVersionUID = 1L;
+ private IAType aggFieldType;
public AbstractScalarDistinctAggregateDescriptor(IFunctionDescriptorFactory aggFuncDescFactory) {
super(aggFuncDescFactory);
}
@Override
+ public void setImmutableStates(Object... states) {
+ aggFieldType = (IAType) states[0];
+ }
+
+ @Override
protected IScalarEvaluator createScalarAggregateEvaluator(IAggregateEvaluator aggEval,
ScanCollectionDescriptor.ScanCollectionUnnestingFunctionFactory scanCollectionFactory,
IHyracksTaskContext ctx) throws HyracksDataException {
- return new GenericScalarDistinctAggregateFunction(aggEval, scanCollectionFactory, ctx, sourceLoc);
+ return new GenericScalarDistinctAggregateFunction(aggEval, scanCollectionFactory, ctx, sourceLoc, aggFieldType);
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/GenericScalarDistinctAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/GenericScalarDistinctAggregateFunction.java
index 2752730..75ef78b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/GenericScalarDistinctAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/GenericScalarDistinctAggregateFunction.java
@@ -24,6 +24,7 @@
import org.apache.asterix.builders.AbvsBuilderFactory;
import org.apache.asterix.builders.ArrayListFactory;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.util.container.IObjectPool;
import org.apache.asterix.om.util.container.ListObjectPool;
import org.apache.asterix.runtime.aggregates.utils.PointableHashSet;
@@ -49,12 +50,12 @@
private final PointableHashSet itemSet;
public GenericScalarDistinctAggregateFunction(IAggregateEvaluator aggFunc,
- IUnnestingEvaluatorFactory scanCollectionFactory, IHyracksTaskContext context, SourceLocation sourceLoc)
- throws HyracksDataException {
+ IUnnestingEvaluatorFactory scanCollectionFactory, IHyracksTaskContext context, SourceLocation sourceLoc,
+ IAType itemType) throws HyracksDataException {
super(aggFunc, scanCollectionFactory, context, sourceLoc);
storageAllocator = new ListObjectPool<>(new AbvsBuilderFactory());
arrayListAllocator = new ListObjectPool<>(new ArrayListFactory<>());
- itemSet = new PointableHashSet(arrayListAllocator, sourceLoc) {
+ itemSet = new PointableHashSet(arrayListAllocator, itemType) {
@Override
protected IPointable makeStoredItem(IPointable item) throws HyracksDataException {
ArrayBackedValueStorage abvs = (ArrayBackedValueStorage) storageAllocator.allocate(null);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarAvgDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarAvgDistinctAggregateDescriptor.java
index 5e5bfb0..81ba967 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarAvgDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarAvgDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.AvgAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarAvgDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_AVG_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarAvgDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarAvgDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarAvgDistinctAggregateDescriptor() {
super(AvgAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarCountDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarCountDistinctAggregateDescriptor.java
index a2b2ad1..cabd3fe 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarCountDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarCountDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.CountAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarCountDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_COUNT_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarCountDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarCountDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarCountDistinctAggregateDescriptor() {
super(CountAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarKurtosisDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarKurtosisDistinctAggregateDescriptor.java
index db6f0e8..c7cfcdd 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarKurtosisDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarKurtosisDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.KurtosisAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarKurtosisDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_KURTOSIS_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarKurtosisDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarKurtosisDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarKurtosisDistinctAggregateDescriptor() {
super(KurtosisAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarMaxDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarMaxDistinctAggregateDescriptor.java
index 932851c..702da0b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarMaxDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarMaxDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.MaxAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarMaxDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_MAX_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarMaxDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarMaxDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarMaxDistinctAggregateDescriptor() {
super(MaxAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarMinDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarMinDistinctAggregateDescriptor.java
index 8bfd545..1c193c8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarMinDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarMinDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.MinAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarMinDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_MIN_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarMinDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarMinDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarMinDistinctAggregateDescriptor() {
super(MinAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSkewnessDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSkewnessDistinctAggregateDescriptor.java
index 84da166..4f96b9b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSkewnessDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSkewnessDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SkewnessAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSkewnessDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SKEWNESS_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSkewnessDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSkewnessDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSkewnessDistinctAggregateDescriptor() {
super(SkewnessAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlAvgDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlAvgDistinctAggregateDescriptor.java
index abba17d..726a18e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlAvgDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlAvgDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlAvgAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlAvgDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_AVG_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlAvgDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlAvgDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlAvgDistinctAggregateDescriptor() {
super(SqlAvgAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlCountDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlCountDistinctAggregateDescriptor.java
index 5945c79..417f698 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlCountDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlCountDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlCountAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlCountDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_COUNT_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlCountDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlCountDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlCountDistinctAggregateDescriptor() {
super(SqlCountAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlKurtosisDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlKurtosisDistinctAggregateDescriptor.java
index de95222..dbe3d26 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlKurtosisDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlKurtosisDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlKurtosisAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlKurtosisDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_KURTOSIS_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlKurtosisDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlKurtosisDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlKurtosisDistinctAggregateDescriptor() {
super(SqlKurtosisAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlMaxDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlMaxDistinctAggregateDescriptor.java
index 02f740b..bb772c6 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlMaxDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlMaxDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlMaxAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlMaxDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_MAX_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlMaxDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlMaxDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
public ScalarSqlMaxDistinctAggregateDescriptor() {
super(SqlMaxAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlMinDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlMinDistinctAggregateDescriptor.java
index 843e4d0..6a8413b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlMinDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlMinDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlMinAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlMinDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_MIN_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlMinDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlMinDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlMinDistinctAggregateDescriptor() {
super(SqlMinAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlStddevDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlStddevDistinctAggregateDescriptor.java
index 1aa8120..ff9ce3f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlStddevDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlStddevDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlStddevAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlStddevDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_STDDEV_SAMP_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlStddevDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlStddevDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlStddevDistinctAggregateDescriptor() {
super(SqlStddevAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlStddevPopDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlStddevPopDistinctAggregateDescriptor.java
index d0c6bde..359c037 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlStddevPopDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlStddevPopDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlStddevPopAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlStddevPopDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_STDDEV_POP_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlStddevPopDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlStddevPopDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlStddevPopDistinctAggregateDescriptor() {
super(SqlStddevPopAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlSumDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlSumDistinctAggregateDescriptor.java
index 853edbb..2df817c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlSumDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlSumDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlSumAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlSumDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_SUM_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlSumDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlSumDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlSumDistinctAggregateDescriptor() {
super(SqlSumAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarDistinctAggregateDescriptor.java
index 253dba9..0f4ea43 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlVarAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlVarDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_VAR_SAMP_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlVarDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlVarDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlVarDistinctAggregateDescriptor() {
super(SqlVarAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopDistinctAggregateDescriptor.java
index 4a761ba..f1e1fbb 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SqlVarPopAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSqlVarPopDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_VAR_POP_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSqlVarPopDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSqlVarPopDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSqlVarPopDistinctAggregateDescriptor() {
super(SqlVarPopAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarStddevDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarStddevDistinctAggregateDescriptor.java
index 50141f3..1253f7c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarStddevDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarStddevDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.StddevAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarStddevDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_STDDEV_SAMP_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarStddevDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarStddevDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarStddevDistinctAggregateDescriptor() {
super(StddevAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarStddevPopDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarStddevPopDistinctAggregateDescriptor.java
index f64fdd7..5a91482 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarStddevPopDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarStddevPopDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.StddevPopAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarStddevPopDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_STDDEV_POP_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarStddevPopDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarStddevPopDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarStddevPopDistinctAggregateDescriptor() {
super(StddevPopAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSumDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSumDistinctAggregateDescriptor.java
index cbe4033..04b8547 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSumDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSumDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.SumAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarSumDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_SUM_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarSumDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarSumDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarSumDistinctAggregateDescriptor() {
super(SumAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarDistinctAggregateDescriptor.java
index 39256bb..a414580 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.VarAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarVarDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_VAR_SAMP_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarVarDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarVarDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarVarDistinctAggregateDescriptor() {
super(VarAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopDistinctAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopDistinctAggregateDescriptor.java
index 2cc0dab..c71a976 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopDistinctAggregateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopDistinctAggregateDescriptor.java
@@ -22,6 +22,8 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.std.VarPopAggregateDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
public class ScalarVarPopDistinctAggregateDescriptor extends AbstractScalarDistinctAggregateDescriptor {
@@ -30,7 +32,8 @@
public static final FunctionIdentifier FID = BuiltinFunctions.SCALAR_VAR_POP_DISTINCT;
- public static final IFunctionDescriptorFactory FACTORY = ScalarVarPopDistinctAggregateDescriptor::new;
+ public static final IFunctionDescriptorFactory FACTORY = DescriptorFactoryUtil
+ .createFactory(ScalarVarPopDistinctAggregateDescriptor::new, FunctionTypeInferers.SET_ARGUMENT_TYPE);
private ScalarVarPopDistinctAggregateDescriptor() {
super(VarPopAggregateDescriptor.FACTORY);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/utils/PointableHashSet.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/utils/PointableHashSet.java
index 3d6fccb..9099c10 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/utils/PointableHashSet.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/utils/PointableHashSet.java
@@ -21,18 +21,15 @@
import java.util.List;
-import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.exceptions.RuntimeDataException;
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
import org.apache.asterix.formats.nontagged.BinaryHashFunctionFactoryProvider;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.util.container.IObjectPool;
import org.apache.asterix.runtime.evaluators.functions.PointableHelper;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunction;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.data.std.api.IPointable;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@@ -44,8 +41,6 @@
*/
public class PointableHashSet {
- private final SourceLocation sourceLoc;
-
private final IObjectPool<List<IPointable>, ATypeTag> listAllocator;
private final IBinaryComparator comparator;
@@ -54,12 +49,11 @@
private final Int2ObjectMap<List<IPointable>> hashes;
- public PointableHashSet(IObjectPool<List<IPointable>, ATypeTag> listAllocator, SourceLocation sourceLoc) {
+ public PointableHashSet(IObjectPool<List<IPointable>, ATypeTag> listAllocator, IAType itemType) {
this.listAllocator = listAllocator;
- this.sourceLoc = sourceLoc;
- comparator = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(null, null, true)
+ comparator = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(itemType, itemType, true)
.createBinaryComparator();
- hashFunction = BinaryHashFunctionFactoryProvider.INSTANCE.getBinaryHashFunctionFactory(null)
+ hashFunction = BinaryHashFunctionFactoryProvider.INSTANCE.getBinaryHashFunctionFactory(itemType)
.createBinaryHashFunction();
hashes = new Int2ObjectOpenHashMap<>();
}
@@ -73,11 +67,6 @@
* Returns {@code true} if the set did not already contain this item, {@code false} otherwise.
*/
public boolean add(IPointable item) throws HyracksDataException {
- if (EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(item.getByteArray()[item.getStartOffset()])
- .isDerivedType()) {
- throw new RuntimeDataException(ErrorCode.CANNOT_COMPARE_COMPLEX, sourceLoc);
- }
-
// look up if it already exists
int hash = hashFunction.hash(item.getByteArray(), item.getStartOffset(), item.getLength());
List<IPointable> sameHashes = hashes.get(hash);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayAddRemoveEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayAddRemoveEval.java
index 1ed467c..f2db0e3 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayAddRemoveEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayAddRemoveEval.java
@@ -25,8 +25,8 @@
import org.apache.asterix.builders.IAsterixListBuilder;
import org.apache.asterix.builders.OrderedListBuilder;
import org.apache.asterix.builders.UnorderedListBuilder;
-import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.exceptions.RuntimeDataException;
+import org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AbstractCollectionType;
@@ -36,16 +36,14 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public abstract class AbstractArrayAddRemoveEval implements IScalarEvaluator {
- protected static final int RETURN_MISSING = -1;
- protected static final int RETURN_NULL = -2;
-
+ static final int RETURN_MISSING = -1;
+ static final int RETURN_NULL = -2;
private final IAType[] argTypes;
private final ArrayBackedValueStorage storage;
private final IPointable listArg;
@@ -54,25 +52,21 @@
private final IPointable[] valuesArgs;
private final IScalarEvaluator listArgEval;
private final IScalarEvaluator[] valuesEval;
- private final SourceLocation sourceLocation;
private final CastTypeEvaluator caster;
private final ListAccessor listAccessor;
private final int listOffset;
private final int valuesOffset;
- private final boolean comparesValues;
private final boolean makeOpen;
private final boolean acceptNullValues;
private IAsterixListBuilder orderedListBuilder;
private IAsterixListBuilder unorderedListBuilder;
- public AbstractArrayAddRemoveEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, int listOffset,
- int valuesOffset, int numValues, IAType[] argTypes, boolean comparesValues, SourceLocation sourceLocation,
- boolean makeOpen, boolean acceptNullValues) throws HyracksDataException {
+ AbstractArrayAddRemoveEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, int listOffset,
+ int valuesOffset, int numValues, IAType[] argTypes, boolean makeOpen, boolean acceptNullValues)
+ throws HyracksDataException {
this.listOffset = listOffset;
this.valuesOffset = valuesOffset;
this.argTypes = argTypes;
- this.comparesValues = comparesValues;
- this.sourceLocation = sourceLocation;
this.makeOpen = makeOpen;
this.acceptNullValues = acceptNullValues;
orderedListBuilder = null;
@@ -93,13 +87,22 @@
}
/**
+ * Returns the position at which to add the items to the list. The default is to add at the end of the list.
* @param listType the type of the list, ordered or unordered.
- * @param listArg the list into which to insert the items at the calculated returned position
+ * @param list the list into which to insert the items at the calculated returned position
* @param tuple the tuple that contains the arguments including position argument
* @return -1 if position value is missing, -2 if null, otherwise should return the adjusted position value, >= 0
*/
- protected abstract int getPosition(IFrameTupleReference tuple, IPointable listArg, ATypeTag listType)
- throws HyracksDataException;
+ protected int getPosition(IFrameTupleReference tuple, IPointable list, ATypeTag listType)
+ throws HyracksDataException {
+ if (listType == ATypeTag.ARRAY) {
+ return AOrderedListSerializerDeserializer.getNumberOfItems(list.getByteArray(), list.getStartOffset());
+ } else if (listType == ATypeTag.MULTISET) {
+ return AUnorderedListSerializerDeserializer.getNumberOfItems(list.getByteArray(), list.getStartOffset());
+ } else {
+ return RETURN_NULL;
+ }
+ }
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
@@ -109,7 +112,6 @@
// evaluate the position argument if provided by some functions
int adjustedPosition = getPosition(tuple, tempList, listArgTag);
-
if (listArgTag == ATypeTag.MISSING || adjustedPosition == RETURN_MISSING) {
PointableHelper.setMissing(result);
return;
@@ -123,12 +125,12 @@
// evaluate values to be added/removed
ATypeTag valueTag;
IAType defaultOpenType;
- boolean encounteredNonPrimitive = false;
try {
+ // TODO(ali): could be optimized to not evaluate the values again when they are constants
for (int i = 0; i < valuesEval.length; i++) {
// cast val to open if needed. don't cast if function will return null anyway, e.g. list arg not list
defaultOpenType = DefaultOpenFieldType.getDefaultOpenFieldType(argTypes[i + valuesOffset].getTypeTag());
- if (defaultOpenType != null && !returnNull) {
+ if (defaultOpenType != null && !returnNull && makeOpen) {
caster.resetAndAllocate(defaultOpenType, argTypes[i + valuesOffset], valuesEval[i]);
caster.evaluate(tuple, valuesArgs[i]);
} else {
@@ -136,10 +138,6 @@
}
valueTag =
ATYPETAGDESERIALIZER.deserialize(valuesArgs[i].getByteArray()[valuesArgs[i].getStartOffset()]);
- // for now, we don't support deep equality of object/lists. Throw an error if value is of these types
- if (comparesValues && valueTag.isDerivedType()) {
- encounteredNonPrimitive = true;
- }
if (valueTag == ATypeTag.MISSING) {
PointableHelper.setMissing(result);
return;
@@ -153,10 +151,6 @@
PointableHelper.setNull(result);
return;
}
-
- if (encounteredNonPrimitive) {
- throw new RuntimeDataException(ErrorCode.CANNOT_COMPARE_COMPLEX, sourceLocation);
- }
// all arguments are valid
AbstractCollectionType listType;
IAsterixListBuilder listBuilder;
@@ -168,6 +162,7 @@
listBuilder = orderedListBuilder;
if (makeOpen || argTypes[listOffset].getTypeTag() != ATypeTag.ARRAY) {
listType = DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE;
+ // TODO(ali): maybe casting isn't needed if compile-time type=ANY if guaranteed input list is open
caster.resetAndAllocate(listType, argTypes[listOffset], listArgEval);
caster.cast(tempList, listArg);
} else {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayProcessArraysEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayProcessArraysEval.java
index 1cf75bc..edbfbad 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayProcessArraysEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArrayProcessArraysEval.java
@@ -22,19 +22,18 @@
import java.io.IOException;
-import org.apache.asterix.builders.AbvsBuilderFactory;
import org.apache.asterix.builders.IAsterixListBuilder;
import org.apache.asterix.builders.OrderedListBuilder;
import org.apache.asterix.builders.UnorderedListBuilder;
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.common.exceptions.RuntimeDataException;
-import org.apache.asterix.om.pointables.PointableAllocator;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AbstractCollectionType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.util.container.IObjectPool;
import org.apache.asterix.om.util.container.ListObjectPool;
+import org.apache.asterix.om.util.container.ObjectFactories;
import org.apache.asterix.runtime.evaluators.common.ListAccessor;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -54,20 +53,19 @@
private final IPointable[] listsArgs;
private final IScalarEvaluator[] listsEval;
private final SourceLocation sourceLocation;
- private final boolean isComparingElements;
- private final PointableAllocator pointableAllocator;
- private final IObjectPool<IMutableValueStorage, ATypeTag> storageAllocator;
+ private final IObjectPool<IPointable, Void> pointablePool;
+ private final IObjectPool<IMutableValueStorage, Void> storageAllocator;
private final IAType[] argTypes;
private final CastTypeEvaluator caster;
private OrderedListBuilder orderedListBuilder;
private UnorderedListBuilder unorderedListBuilder;
- public AbstractArrayProcessArraysEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx,
- boolean isComparingElements, SourceLocation sourceLoc, IAType[] argTypes) throws HyracksDataException {
+ AbstractArrayProcessArraysEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLoc,
+ IAType[] argTypes) throws HyracksDataException {
orderedListBuilder = null;
unorderedListBuilder = null;
- pointableAllocator = new PointableAllocator();
- storageAllocator = new ListObjectPool<>(new AbvsBuilderFactory());
+ pointablePool = new ListObjectPool<>(ObjectFactories.VOID_FACTORY);
+ storageAllocator = new ListObjectPool<>(ObjectFactories.STORAGE_FACTORY);
finalResult = new ArrayBackedValueStorage();
listAccessor = new ListAccessor();
caster = new CastTypeEvaluator();
@@ -79,7 +77,6 @@
listsEval[i] = args[i].createScalarEvaluator(ctx);
}
sourceLocation = sourceLoc;
- this.isComparingElements = isComparingElements;
this.argTypes = argTypes;
}
@@ -141,7 +138,7 @@
} finally {
release();
storageAllocator.reset();
- pointableAllocator.reset();
+ pointablePool.reset();
caster.deallocatePointables();
}
}
@@ -149,7 +146,7 @@
private void processLists(IPointable[] listsArgs, IAsterixListBuilder listBuilder) throws IOException {
boolean itemInStorage;
boolean isUsingItem;
- IPointable item = pointableAllocator.allocateEmpty();
+ IPointable item = pointablePool.allocate(null);
ArrayBackedValueStorage storage = (ArrayBackedValueStorage) storageAllocator.allocate(null);
storage.reset();
@@ -159,13 +156,9 @@
// process the items of the current list
for (int j = 0; j < listAccessor.size(); j++) {
itemInStorage = listAccessor.getOrWriteItem(j, item, storage);
- if (ATYPETAGDESERIALIZER.deserialize(item.getByteArray()[item.getStartOffset()]).isDerivedType()
- && isComparingElements) {
- throw new RuntimeDataException(ErrorCode.CANNOT_COMPARE_COMPLEX, sourceLocation);
- }
isUsingItem = processItem(item, listIndex, listBuilder);
if (isUsingItem) {
- item = pointableAllocator.allocateEmpty();
+ item = pointablePool.allocate(null);
if (itemInStorage) {
storage = (ArrayBackedValueStorage) storageAllocator.allocate(null);
storage.reset();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArraySearchEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArraySearchEval.java
index b761c0d..70ea031 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArraySearchEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractArraySearchEval.java
@@ -22,10 +22,10 @@
import java.io.IOException;
-import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.exceptions.RuntimeDataException;
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
import org.apache.asterix.om.base.AMutableInt32;
+import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.common.ListAccessor;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -33,14 +33,12 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public abstract class AbstractArraySearchEval implements IScalarEvaluator {
- private IAType[] argTypes;
private final IPointable listArg;
private final IPointable searchedValueArg;
private final IPointable tempVal;
@@ -48,28 +46,26 @@
private final IScalarEvaluator searchedValueEval;
private final IBinaryComparator comp;
private final ListAccessor listAccessor;
- private final SourceLocation sourceLocation;
private final AMutableInt32 intValue;
protected final ArrayBackedValueStorage storage;
- public AbstractArraySearchEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLoc,
- IAType[] argTypes) throws HyracksDataException {
- this.argTypes = argTypes;
+ AbstractArraySearchEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, IAType[] argTypes)
+ throws HyracksDataException {
storage = new ArrayBackedValueStorage();
listArg = new VoidPointable();
searchedValueArg = new VoidPointable();
tempVal = new VoidPointable();
listEval = args[0].createScalarEvaluator(ctx);
searchedValueEval = args[1].createScalarEvaluator(ctx);
- comp = createComparator();
+ comp = createComparator(argTypes[0], argTypes[1]);
listAccessor = new ListAccessor();
intValue = new AMutableInt32(-1);
- sourceLocation = sourceLoc;
}
- private IBinaryComparator createComparator() {
- // TODO(ali): using old comparator behaviour for now. Should compute proper types based on args
- return BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(null, null, true)
+ private static IBinaryComparator createComparator(IAType listType, IAType searchValueType) {
+ IAType itemType = listType.getTypeTag().isListType() ? ((AbstractCollectionType) listType).getItemType()
+ : BuiltinType.ANY;
+ return BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(itemType, searchValueType, true)
.createBinaryComparator();
}
@@ -80,17 +76,13 @@
byte[] listBytes = listArg.getByteArray();
int listOffset = listArg.getStartOffset();
+ // TODO(ali): could be optimized to not evaluate again if the search value evaluator is a constant
// 2nd arg: value to search for
searchedValueEval.evaluate(tuple, searchedValueArg);
byte[] valueBytes = searchedValueArg.getByteArray();
int valueOffset = searchedValueArg.getStartOffset();
int valueLength = searchedValueArg.getLength();
- // for now, we don't support deep equality of object/lists. Throw an error if the value is of these types
- if (ATYPETAGDESERIALIZER.deserialize(valueBytes[valueOffset]).isDerivedType()) {
- throw new RuntimeDataException(ErrorCode.CANNOT_COMPARE_COMPLEX, sourceLocation);
- }
-
if (!ATYPETAGDESERIALIZER.deserialize(listBytes[listOffset]).isListType()) {
PointableHelper.setNull(result);
return;
@@ -100,7 +92,6 @@
intValue.setValue(-1);
listAccessor.reset(listBytes, listOffset);
int numItems = listAccessor.size();
-
try {
for (int i = 0; i < numItems; i++) {
listAccessor.getOrWriteItem(i, tempVal, storage);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayAppendDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayAppendDescriptor.java
index 009d7b3..1328d7f 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayAppendDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayAppendDescriptor.java
@@ -18,24 +18,18 @@
*/
package org.apache.asterix.runtime.evaluators.functions;
-import org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
-import org.apache.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
import org.apache.asterix.om.functions.BuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.functions.IFunctionTypeInferer;
-import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
* <pre>
@@ -55,17 +49,8 @@
private static final long serialVersionUID = 1L;
private IAType[] argTypes;
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new ArrayAppendDescriptor();
- }
-
- @Override
- public IFunctionTypeInferer createFunctionTypeInferer() {
- return FunctionTypeInferers.SET_ARGUMENTS_TYPE;
- }
- };
+ public static final IFunctionDescriptorFactory FACTORY =
+ DescriptorFactoryUtil.createFactory(ArrayAppendDescriptor::new, FunctionTypeInferers.SET_ARGUMENTS_TYPE);
@Override
public FunctionIdentifier getIdentifier() {
@@ -92,21 +77,8 @@
public class ArrayAppendEval extends AbstractArrayAddRemoveEval {
- public ArrayAppendEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, 0, 1, args.length - 1, argTypes, false, sourceLoc, true, true);
- }
-
- @Override
- protected int getPosition(IFrameTupleReference tuple, IPointable l, ATypeTag listTag)
- throws HyracksDataException {
- // l = list
- if (listTag == ATypeTag.ARRAY) {
- return AOrderedListSerializerDeserializer.getNumberOfItems(l.getByteArray(), l.getStartOffset());
- } else if (listTag == ATypeTag.MULTISET) {
- return AUnorderedListSerializerDeserializer.getNumberOfItems(l.getByteArray(), l.getStartOffset());
- } else {
- return RETURN_NULL;
- }
+ ArrayAppendEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ super(args, ctx, 0, 1, args.length - 1, argTypes, true, true);
}
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayConcatDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayConcatDescriptor.java
index c808ec5..5890779 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayConcatDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayConcatDescriptor.java
@@ -89,8 +89,9 @@
}
public class ArrayConcatEval extends AbstractArrayProcessArraysEval {
- public ArrayConcatEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, false, sourceLoc, argTypes);
+
+ ArrayConcatEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ super(args, ctx, sourceLoc, argTypes);
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayContainsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayContainsDescriptor.java
index 16d07c3..d9d7710 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayContainsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayContainsDescriptor.java
@@ -48,9 +48,8 @@
* It returns (or throws an error at runtime) in order:
* 1. missing, if any argument is missing.
* 2. null, if any argument is null.
- * 3. an error if the value is a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 4. null, if the input list is not a list.
- * 5. otherwise, returns true or false.
+ * 3. null, if the input list is not a list.
+ * 4. otherwise, returns true or false.
*
* </pre>
*/
@@ -96,11 +95,12 @@
public class ArrayContainsEval extends AbstractArraySearchEval {
private final ISerializerDeserializer booleanSerde;
- public ArrayContainsEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, sourceLoc, argTypes);
+ ArrayContainsEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ super(args, ctx, argTypes);
booleanSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ABOOLEAN);
}
+ @SuppressWarnings("unchecked") // unchecked call
@Override
public void processResult(AMutableInt32 intValue, IPointable result) throws HyracksDataException {
storage.reset();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayDistinctDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayDistinctDescriptor.java
index 35b9aac..5f28cbd 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayDistinctDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayDistinctDescriptor.java
@@ -26,6 +26,8 @@
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.functions.IFunctionTypeInferer;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.aggregates.utils.PointableHashSet;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
@@ -37,7 +39,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -54,8 +55,7 @@
* It returns (or throws an error at runtime) in order:
* 1. missing, if any argument is missing.
* 2. null, if the list arg is null or it's not a list.
- * 3. an error if any list item is a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 4. otherwise, a new list.
+ * 3. otherwise, a new list.
*
* </pre>
*/
@@ -94,7 +94,7 @@
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
- return new ArrayDistinctFunction(args, ctx, sourceLoc);
+ return new ArrayDistinctFunction(args, ctx);
}
};
}
@@ -104,10 +104,11 @@
private IPointable item;
private ArrayBackedValueStorage storage;
- public ArrayDistinctFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLoc)
- throws HyracksDataException {
+ ArrayDistinctFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
super(args, ctx, inputListType);
- itemSet = new PointableHashSet(arrayListAllocator, sourceLoc);
+ IAType itemType = inputListType.getTypeTag().isListType()
+ ? ((AbstractCollectionType) inputListType).getItemType() : BuiltinType.ANY;
+ itemSet = new PointableHashSet(arrayListAllocator, itemType);
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayInsertDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayInsertDescriptor.java
index 969e1d7..e8b7374 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayInsertDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayInsertDescriptor.java
@@ -23,14 +23,13 @@
import org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
import org.apache.asterix.om.functions.BuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.functions.IFunctionTypeInferer;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -63,17 +62,8 @@
private static final long serialVersionUID = 1L;
private IAType[] argTypes;
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new ArrayInsertDescriptor();
- }
-
- @Override
- public IFunctionTypeInferer createFunctionTypeInferer() {
- return FunctionTypeInferers.SET_ARGUMENTS_TYPE;
- }
- };
+ public static final IFunctionDescriptorFactory FACTORY =
+ DescriptorFactoryUtil.createFactory(ArrayInsertDescriptor::new, FunctionTypeInferers.SET_ARGUMENTS_TYPE);
@Override
public FunctionIdentifier getIdentifier() {
@@ -102,8 +92,8 @@
private final TaggedValuePointable positionArg;
private final IScalarEvaluator positionArgEval;
- public ArrayInsertEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, 0, 2, args.length - 2, argTypes, false, sourceLoc, true, true);
+ ArrayInsertEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ super(args, ctx, 0, 2, args.length - 2, argTypes, true, true);
positionArg = new TaggedValuePointable();
positionArgEval = args[1].createScalarEvaluator(ctx);
}
@@ -111,6 +101,7 @@
@Override
protected int getPosition(IFrameTupleReference tuple, IPointable l, ATypeTag listTag)
throws HyracksDataException {
+ // TODO(ali): could be optimized to evaluate only once if we know the argument is a constant
positionArgEval.evaluate(tuple, positionArg);
if (positionArg.getTag() == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
return RETURN_MISSING;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java
index ca98572..f043294 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java
@@ -42,6 +42,7 @@
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.util.container.IObjectFactory;
import org.apache.asterix.om.util.container.IObjectPool;
@@ -80,8 +81,7 @@
* 1. missing, if any argument is missing.
* 2. an error if the input lists are not of the same type (one is an ordered list while the other is unordered).
* 3. null, if any input list is null or is not a list.
- * 4. an error if any list item is a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 5. otherwise, a new list.
+ * 4. otherwise, a new list.
*
* </pre>
*/
@@ -128,7 +128,7 @@
private IPointable value;
private int listIndex;
- protected ValueListIndex() {
+ ValueListIndex() {
}
protected void set(IPointable value, int listIndex) {
@@ -154,7 +154,7 @@
protected class ValueListIndexAllocator implements IObjectFactory<ValueListIndex, ATypeTag> {
- protected ValueListIndexAllocator() {
+ ValueListIndexAllocator() {
}
@Override
@@ -181,7 +181,7 @@
private IAsterixListBuilder orderedListBuilder;
private IAsterixListBuilder unorderedListBuilder;
- public ArrayIntersectEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ ArrayIntersectEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
orderedListBuilder = null;
unorderedListBuilder = null;
pointableAllocator = new PointableAllocator();
@@ -192,8 +192,9 @@
finalResult = new ArrayBackedValueStorage();
listAccessor = new ListAccessor();
caster = new CastTypeEvaluator();
- comp = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(null, null, true)
- .createBinaryComparator();
+ // for functions that accept multiple lists arguments, they will be casted to open, hence item is ANY
+ comp = BinaryComparatorFactoryProvider.INSTANCE
+ .getBinaryComparatorFactory(BuiltinType.ANY, BuiltinType.ANY, true).createBinaryComparator();
listsArgs = new IPointable[args.length];
listsEval = new IScalarEvaluator[args.length];
pointable = new VoidPointable();
@@ -202,8 +203,8 @@
listsArgs[i] = new VoidPointable();
listsEval[i] = args[i].createScalarEvaluator(ctx);
}
- binaryHashFunction = BinaryHashFunctionFactoryProvider.INSTANCE.getBinaryHashFunctionFactory(null)
- .createBinaryHashFunction();
+ binaryHashFunction = BinaryHashFunctionFactoryProvider.INSTANCE
+ .getBinaryHashFunctionFactory(BuiltinType.ANY).createBinaryHashFunction();
}
@Override
@@ -315,7 +316,6 @@
storage.reset();
for (int j = 0; j < listAccessor.size(); j++) {
itemInStorage = listAccessor.getOrWriteItem(j, item, storage);
- validateItem(item);
if (notNullAndMissing(item)) {
hash = binaryHashFunction.hash(item.getByteArray(), item.getStartOffset(), item.getLength());
sameHashes = hashes.get(hash);
@@ -338,7 +338,6 @@
List<ValueListIndex> sameHashes;
for (int j = 0; j < listAccessor.size(); j++) {
listAccessor.getOrWriteItem(j, pointable, currentItemStorage);
- validateItem(pointable);
if (notNullAndMissing(pointable)) {
// hash the item and look up to see if it is common
hash = binaryHashFunction.hash(pointable.getByteArray(), pointable.getStartOffset(),
@@ -398,12 +397,5 @@
}
}
}
-
- // validates that the item is not derived, multisets, objects and arrays are not yet supported
- private void validateItem(IPointable item) throws RuntimeDataException {
- if (ATYPETAGDESERIALIZER.deserialize(item.getByteArray()[item.getStartOffset()]).isDerivedType()) {
- throw new RuntimeDataException(ErrorCode.CANNOT_COMPARE_COMPLEX, sourceLoc);
- }
- }
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPositionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPositionDescriptor.java
index 884136e..e5443ef 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPositionDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPositionDescriptor.java
@@ -47,9 +47,8 @@
* It returns (or throws an error at runtime) in order:
* 1. missing, if any argument is missing.
* 2. null, if any argument is null.
- * 3. an error if the value is of a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 4. null, if the input list is not a list.
- * 5. otherwise, returns the position of the value in the list or -1 if not found.
+ * 3. null, if the input list is not a list.
+ * 4. otherwise, returns the position of the value in the list or -1 if not found.
*
* </pre>
*/
@@ -95,11 +94,12 @@
public class ArrayPositionEval extends AbstractArraySearchEval {
private final ISerializerDeserializer intSerde;
- public ArrayPositionEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, sourceLoc, argTypes);
+ ArrayPositionEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ super(args, ctx, argTypes);
intSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT32);
}
+ @SuppressWarnings("unchecked") // unchecked call
@Override
public void processResult(AMutableInt32 intValue, IPointable result) throws HyracksDataException {
storage.reset();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPrependDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPrependDescriptor.java
index fa56fb1..39e272e 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPrependDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPrependDescriptor.java
@@ -19,13 +19,12 @@
package org.apache.asterix.runtime.evaluators.functions;
import org.apache.asterix.om.functions.BuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.functions.IFunctionTypeInferer;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -53,17 +52,8 @@
private static final long serialVersionUID = 1L;
private IAType[] argTypes;
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new ArrayPrependDescriptor();
- }
-
- @Override
- public IFunctionTypeInferer createFunctionTypeInferer() {
- return FunctionTypeInferers.SET_ARGUMENTS_TYPE;
- }
- };
+ public static final IFunctionDescriptorFactory FACTORY =
+ DescriptorFactoryUtil.createFactory(ArrayPrependDescriptor::new, FunctionTypeInferers.SET_ARGUMENTS_TYPE);
@Override
public FunctionIdentifier getIdentifier() {
@@ -90,13 +80,12 @@
public class ArrayPrependEval extends AbstractArrayAddRemoveEval {
- public ArrayPrependEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, args.length - 1, 0, args.length - 1, argTypes, false, sourceLoc, true, true);
+ ArrayPrependEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ super(args, ctx, args.length - 1, 0, args.length - 1, argTypes, true, true);
}
@Override
- protected int getPosition(IFrameTupleReference tuple, IPointable listArg, ATypeTag listTag)
- throws HyracksDataException {
+ protected int getPosition(IFrameTupleReference tuple, IPointable listArg, ATypeTag listTag) {
return 0;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPutDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPutDescriptor.java
index e6cd489..c1c9149 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPutDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPutDescriptor.java
@@ -21,18 +21,15 @@
import java.io.IOException;
import org.apache.asterix.builders.IAsterixListBuilder;
-import org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
-import org.apache.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
import org.apache.asterix.om.functions.BuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.functions.IFunctionTypeInferer;
-import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.evaluators.common.ListAccessor;
import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -43,7 +40,6 @@
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
* <pre>
@@ -56,8 +52,7 @@
* It returns (or throws an error at runtime) in order:
* 1. missing, if any argument is missing.
* 2. null, if any argument is null.
- * 3. an error if any value arg is of a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 4. otherwise, a new list.
+ * 3. otherwise, a new list.
*
* </pre>
*/
@@ -65,17 +60,8 @@
private static final long serialVersionUID = 1L;
private IAType[] argTypes;
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new ArrayPutDescriptor();
- }
-
- @Override
- public IFunctionTypeInferer createFunctionTypeInferer() {
- return FunctionTypeInferers.SET_ARGUMENTS_TYPE;
- }
- };
+ public static final IFunctionDescriptorFactory FACTORY =
+ DescriptorFactoryUtil.createFactory(ArrayPutDescriptor::new, FunctionTypeInferers.SET_ARGUMENTS_TYPE);
@Override
public FunctionIdentifier getIdentifier() {
@@ -106,29 +92,17 @@
private final IBinaryComparator comp;
private final boolean[] add;
- public ArrayPutEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, 0, 1, args.length - 1, argTypes, true, sourceLoc, true, false);
- comp = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(null, null, true)
- .createBinaryComparator();
+ ArrayPutEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ super(args, ctx, 0, 1, args.length - 1, argTypes, true, false);
+ // input list will be opened since makeOpen=true. all values will be opened, too. hence ANY for comp.
+ comp = BinaryComparatorFactoryProvider.INSTANCE
+ .getBinaryComparatorFactory(BuiltinType.ANY, BuiltinType.ANY, true).createBinaryComparator();
storage = new ArrayBackedValueStorage();
item = new VoidPointable();
add = new boolean[args.length - 1];
}
@Override
- protected int getPosition(IFrameTupleReference tuple, IPointable l, ATypeTag listTag)
- throws HyracksDataException {
- // l = list
- if (listTag == ATypeTag.ARRAY) {
- return AOrderedListSerializerDeserializer.getNumberOfItems(l.getByteArray(), l.getStartOffset());
- } else if (listTag == ATypeTag.MULTISET) {
- return AUnorderedListSerializerDeserializer.getNumberOfItems(l.getByteArray(), l.getStartOffset());
- } else {
- return RETURN_NULL;
- }
- }
-
- @Override
protected void processList(ListAccessor listAccessor, IAsterixListBuilder listBuilder, IPointable[] values,
int position) throws IOException {
markAllToBeAdded();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRemoveDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRemoveDescriptor.java
index 07d8255..fbf04aa 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRemoveDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRemoveDescriptor.java
@@ -23,14 +23,15 @@
import org.apache.asterix.builders.IAsterixListBuilder;
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
import org.apache.asterix.om.functions.BuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.functions.IFunctionTypeInferer;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.evaluators.common.ListAccessor;
import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -53,8 +54,7 @@
* It returns (or throws an error at runtime) in order:
* 1. missing, if any argument is missing.
* 2. null, if any argument is null.
- * 3. an error if any value arg is of a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 4. otherwise, a new list that has the same type as the input list.
+ * 3. otherwise, a new list that has the same type as the input list.
*
* </pre>
*/
@@ -62,17 +62,8 @@
private static final long serialVersionUID = 1L;
private IAType[] argTypes;
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new ArrayRemoveDescriptor();
- }
-
- @Override
- public IFunctionTypeInferer createFunctionTypeInferer() {
- return FunctionTypeInferers.SET_ARGUMENTS_TYPE;
- }
- };
+ public static final IFunctionDescriptorFactory FACTORY =
+ DescriptorFactoryUtil.createFactory(ArrayRemoveDescriptor::new, FunctionTypeInferers.SET_ARGUMENTS_TYPE);
@Override
public FunctionIdentifier getIdentifier() {
@@ -87,7 +78,7 @@
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
- return new ArrayRemoveEval(args, ctx);
+ return new ArrayRemoveEval(args, ctx, argTypes);
}
};
}
@@ -97,22 +88,21 @@
argTypes = (IAType[]) states;
}
- public class ArrayRemoveEval extends AbstractArrayAddRemoveEval {
+ public static class ArrayRemoveEval extends AbstractArrayAddRemoveEval {
private final ArrayBackedValueStorage storage;
private final IPointable item;
- private final IBinaryComparator comp;
+ private final IBinaryComparator[] comp;
- public ArrayRemoveEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, 0, 1, args.length - 1, argTypes, true, sourceLoc, false, false);
+ ArrayRemoveEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, IAType[] argTypes)
+ throws HyracksDataException {
+ super(args, ctx, 0, 1, args.length - 1, argTypes, false, false);
storage = new ArrayBackedValueStorage();
item = new VoidPointable();
- comp = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(null, null, true)
- .createBinaryComparator();
+ comp = createValuesComparators(argTypes);
}
@Override
- protected int getPosition(IFrameTupleReference tuple, IPointable listArg, ATypeTag listTag)
- throws HyracksDataException {
+ protected int getPosition(IFrameTupleReference tuple, IPointable listArg, ATypeTag listTag) {
return 0;
}
@@ -125,7 +115,7 @@
listAccessor.getOrWriteItem(i, item, storage);
addItem = true;
for (int j = 0; j < removed.length; j++) {
- if (comp.compare(item.getByteArray(), item.getStartOffset(), item.getLength(),
+ if (comp[j].compare(item.getByteArray(), item.getStartOffset(), item.getLength(),
removed[j].getByteArray(), removed[j].getStartOffset(), removed[j].getLength()) == 0) {
addItem = false;
break;
@@ -136,5 +126,18 @@
}
}
}
+
+ private static IBinaryComparator[] createValuesComparators(IAType[] argTypes) {
+ // one comparator for each value since the values will not be opened (they won't be added to a list).
+ // for the list item, it's either the item type if input list is determined to be a list or ANY if not.
+ IAType itemType = argTypes[0].getTypeTag().isListType()
+ ? ((AbstractCollectionType) argTypes[0]).getItemType() : BuiltinType.ANY;
+ IBinaryComparator[] comparators = new IBinaryComparator[argTypes.length - 1];
+ for (int i = 1; i < argTypes.length; i++) {
+ comparators[i - 1] = BinaryComparatorFactoryProvider.INSTANCE
+ .getBinaryComparatorFactory(itemType, argTypes[i], true).createBinaryComparator();
+ }
+ return comparators;
+ }
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReplaceDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReplaceDescriptor.java
index ced6fa9..86691f9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReplaceDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReplaceDescriptor.java
@@ -25,21 +25,19 @@
import org.apache.asterix.builders.IAsterixListBuilder;
import org.apache.asterix.builders.OrderedListBuilder;
import org.apache.asterix.builders.UnorderedListBuilder;
-import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.exceptions.RuntimeDataException;
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
import org.apache.asterix.om.functions.BuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.functions.IFunctionTypeInferer;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.evaluators.common.ListAccessor;
import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -70,27 +68,18 @@
* - any argument is null (except for val2).
* - input list is not a list.
* - num_times is not numeric or it's a floating-point number with decimals, e.g, 3.2 (3.0 is OK).
- * 3. an error if val1 is a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 4. otherwise, a new list.
+ * 3. otherwise, a new list.
*
* </pre>
*/
public class ArrayReplaceDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
private IAType inputListType;
+ private IAType targetValueType;
private IAType newValueType;
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new ArrayReplaceDescriptor();
- }
-
- @Override
- public IFunctionTypeInferer createFunctionTypeInferer() {
- return FunctionTypeInferers.SET_ARGUMENTS_TYPE;
- }
- };
+ public static final IFunctionDescriptorFactory FACTORY =
+ DescriptorFactoryUtil.createFactory(ArrayReplaceDescriptor::new, FunctionTypeInferers.SET_ARGUMENTS_TYPE);
@Override
public FunctionIdentifier getIdentifier() {
@@ -100,6 +89,7 @@
@Override
public void setImmutableStates(Object... states) {
inputListType = (IAType) states[0];
+ targetValueType = (IAType) states[1];
newValueType = (IAType) states[2];
}
@@ -135,7 +125,7 @@
private IAsterixListBuilder orderedListBuilder;
private IAsterixListBuilder unorderedListBuilder;
- public ArrayReplaceEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ ArrayReplaceEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
storage = new ArrayBackedValueStorage();
listEval = args[0].createScalarEvaluator(ctx);
targetValEval = args[1].createScalarEvaluator(ctx);
@@ -154,8 +144,9 @@
caster = new CastTypeEvaluator();
orderedListBuilder = null;
unorderedListBuilder = null;
- comp = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(null, null, true)
- .createBinaryComparator();
+ // the input list will be opened, therefore, the type of left (item type) is ANY
+ comp = BinaryComparatorFactoryProvider.INSTANCE
+ .getBinaryComparatorFactory(BuiltinType.ANY, targetValueType, true).createBinaryComparator();
}
@Override
@@ -192,16 +183,10 @@
PointableHelper.setNull(result);
return;
}
-
- if (targetTag.isDerivedType()) {
- throw new RuntimeDataException(ErrorCode.CANNOT_COMPARE_COMPLEX, sourceLoc);
- }
-
try {
IAType defaultOpenType = DefaultOpenFieldType.getDefaultOpenFieldType(listType);
caster.resetAndAllocate(defaultOpenType, inputListType, listEval);
caster.cast(tempList, list);
-
defaultOpenType = DefaultOpenFieldType.getDefaultOpenFieldType(newValTag);
if (defaultOpenType != null) {
caster.resetAndAllocate(defaultOpenType, newValueType, newValEval);
@@ -209,7 +194,6 @@
} else {
newVal.set(tempVal);
}
-
int max = (int) maxDouble;
// create list
IAsterixListBuilder listBuilder;
@@ -224,10 +208,8 @@
}
listBuilder = unorderedListBuilder;
}
-
listBuilder.reset((AbstractCollectionType) DefaultOpenFieldType.getDefaultOpenFieldType(listType));
listAccessor.reset(list.getByteArray(), list.getStartOffset());
-
int counter = 0;
byte[] targetBytes = target.getByteArray();
int offset = target.getStartOffset();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySortDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySortDescriptor.java
index 73976f3..bbfbb36 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySortDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySortDescriptor.java
@@ -18,20 +18,18 @@
*/
package org.apache.asterix.runtime.evaluators.functions;
-import static org.apache.asterix.om.types.EnumDeserializer.ATYPETAGDESERIALIZER;
-
import java.io.IOException;
import java.util.Comparator;
import java.util.PriorityQueue;
import org.apache.asterix.builders.IAsterixListBuilder;
-import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.exceptions.RuntimeDataException;
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.functions.IFunctionTypeInferer;
+import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.evaluators.common.ListAccessor;
@@ -43,7 +41,6 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -58,8 +55,7 @@
* It returns (or throws an error at runtime) in order:
* 1. missing, if any argument is missing.
* 2. null, if the list arg is null or it's not a list.
- * 3. an error if any list item is a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 4. otherwise, a new list.
+ * 3. otherwise, a new list.
*
* </pre>
*/
@@ -98,14 +94,18 @@
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
- return new ArraySortEval(args, ctx, sourceLoc);
+ return new ArraySortEval(args, ctx);
}
};
}
protected class ArraySortComparator implements Comparator<IPointable> {
- private final IBinaryComparator comp = BinaryComparatorFactoryProvider.INSTANCE
- .getBinaryComparatorFactory(null, null, true).createBinaryComparator();
+ private final IBinaryComparator comp;
+
+ ArraySortComparator(IAType itemType) {
+ comp = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(itemType, itemType, true)
+ .createBinaryComparator();
+ }
@Override
public int compare(IPointable val1, IPointable val2) {
@@ -119,16 +119,15 @@
}
public class ArraySortEval extends AbstractArrayProcessEval {
- private final SourceLocation sourceLoc;
private final PriorityQueue<IPointable> sortedList;
private IPointable item;
private ArrayBackedValueStorage storage;
- public ArraySortEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLoc)
- throws HyracksDataException {
+ ArraySortEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
super(args, ctx, inputListType);
- this.sourceLoc = sourceLoc;
- sortedList = new PriorityQueue<>(new ArraySortComparator());
+ IAType itemType = inputListType.getTypeTag().isListType()
+ ? ((AbstractCollectionType) inputListType).getItemType() : BuiltinType.ANY;
+ sortedList = new PriorityQueue<>(new ArraySortComparator(itemType));
}
@Override
@@ -139,9 +138,6 @@
storage = (ArrayBackedValueStorage) storageAllocator.allocate(null);
for (int i = 0; i < listAccessor.size(); i++) {
itemInStorage = listAccessor.getOrWriteItem(i, item, storage);
- if (ATYPETAGDESERIALIZER.deserialize(item.getByteArray()[item.getStartOffset()]).isDerivedType()) {
- throw new RuntimeDataException(ErrorCode.CANNOT_COMPARE_COMPLEX, sourceLoc);
- }
sortedList.add(item);
if (itemInStorage) {
storage = (ArrayBackedValueStorage) storageAllocator.allocate(null);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffEval.java
index 8737c11..ee7b0e7 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffEval.java
@@ -25,6 +25,7 @@
import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
import org.apache.asterix.formats.nontagged.BinaryHashFunctionFactoryProvider;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.util.container.IObjectFactory;
import org.apache.asterix.om.util.container.IObjectPool;
@@ -50,16 +51,17 @@
private final IBinaryComparator comp;
private final IntArrayList intHashes;
- public ArraySymDiffEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLocation,
+ ArraySymDiffEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx, SourceLocation sourceLocation,
IAType[] argTypes) throws HyracksDataException {
- super(args, ctx, true, sourceLocation, argTypes);
+ super(args, ctx, sourceLocation, argTypes);
arrayListAllocator = new ListObjectPool<>(new ArrayListFactory<>());
valueCounterAllocator = new ListObjectPool<>(new ValueCounterFactory());
hashes = new Int2ObjectOpenHashMap<>();
- comp = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(null, null, true)
- .createBinaryComparator();
+ // for functions that accept multiple lists arguments, they will be casted to open, hence item is ANY
+ comp = BinaryComparatorFactoryProvider.INSTANCE
+ .getBinaryComparatorFactory(BuiltinType.ANY, BuiltinType.ANY, true).createBinaryComparator();
intHashes = new IntArrayList(50, 10);
- binaryHashFunction = BinaryHashFunctionFactoryProvider.INSTANCE.getBinaryHashFunctionFactory(null)
+ binaryHashFunction = BinaryHashFunctionFactoryProvider.INSTANCE.getBinaryHashFunctionFactory(BuiltinType.ANY)
.createBinaryHashFunction();
}
@@ -68,7 +70,7 @@
private int listIndex;
private int counter;
- protected ValueCounter() {
+ ValueCounter() {
}
protected void reset(IPointable value, int listIndex, int counter) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffnDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffnDescriptor.java
index 0cafb1b..c19a911 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffnDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffnDescriptor.java
@@ -45,8 +45,7 @@
* 1. missing, if any argument is missing.
* 2. an error if the input lists are not of the same type (one is an ordered list while the other is unordered).
* 3. null, if any input list is null or is not a list.
- * 4. an error if any list item is a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 5. otherwise, a new list.
+ * 4. otherwise, a new list.
*
* </pre>
*/
@@ -91,7 +90,7 @@
public class ArraySymDiffnEval extends ArraySymDiffEval {
- public ArraySymDiffnEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ ArraySymDiffnEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
super(args, ctx, sourceLoc, argTypes);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayUnionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayUnionDescriptor.java
index d61e636..6fdf358 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayUnionDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayUnionDescriptor.java
@@ -29,6 +29,7 @@
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.functions.IFunctionTypeInferer;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.util.container.IObjectPool;
import org.apache.asterix.om.util.container.ListObjectPool;
@@ -60,8 +61,7 @@
* 1. missing, if any argument is missing.
* 2. an error if the input lists are not of the same type (one is an ordered list while the other is unordered).
* 3. null, if any input list is null or is not a list.
- * 4. an error if any list item is a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 5. otherwise, a new list.
+ * 4. otherwise, a new list.
*
* </pre>
*/
@@ -110,14 +110,15 @@
private final Int2ObjectMap<List<IPointable>> hashes;
private final IBinaryComparator comp;
- public ArrayUnionEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
- super(args, ctx, true, sourceLoc, argTypes);
+ ArrayUnionEval(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException {
+ super(args, ctx, sourceLoc, argTypes);
pointableListAllocator = new ListObjectPool<>(new ArrayListFactory<>());
hashes = new Int2ObjectOpenHashMap<>();
- comp = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(null, null, true)
- .createBinaryComparator();
- binaryHashFunction = BinaryHashFunctionFactoryProvider.INSTANCE.getBinaryHashFunctionFactory(null)
- .createBinaryHashFunction();
+ // for functions that accept multiple lists arguments, they will be casted to open, hence item is ANY
+ comp = BinaryComparatorFactoryProvider.INSTANCE
+ .getBinaryComparatorFactory(BuiltinType.ANY, BuiltinType.ANY, true).createBinaryComparator();
+ binaryHashFunction = BinaryHashFunctionFactoryProvider.INSTANCE
+ .getBinaryHashFunctionFactory(BuiltinType.ANY).createBinaryHashFunction();
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/DescriptorFactoryUtil.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/DescriptorFactoryUtil.java
new file mode 100644
index 0000000..ce522f2
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/DescriptorFactoryUtil.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.utils;
+
+import java.util.function.Supplier;
+
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.functions.IFunctionTypeInferer;
+
+public class DescriptorFactoryUtil {
+
+ private DescriptorFactoryUtil() {
+ }
+
+ public static IFunctionDescriptorFactory createFactory(Supplier<IFunctionDescriptor> descriptorSupplier,
+ IFunctionTypeInferer typeInferer) {
+ return new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return descriptorSupplier.get();
+ }
+
+ @Override
+ public IFunctionTypeInferer createFunctionTypeInferer() {
+ return typeInferer;
+ }
+ };
+ }
+}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/IsomorphismVariableMappingVisitor.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/IsomorphismVariableMappingVisitor.java
index eca2508..ed2152c 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/IsomorphismVariableMappingVisitor.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/visitors/IsomorphismVariableMappingVisitor.java
@@ -140,6 +140,9 @@
@Override
public Void visitNestedTupleSourceOperator(NestedTupleSourceOperator op, ILogicalOperator arg)
throws AlgebricksException {
+ if (op.getOperatorTag() != arg.getOperatorTag()) {
+ return null;
+ }
ILogicalOperator inputToCreator1 = op.getSourceOperator();
NestedTupleSourceOperator nts = (NestedTupleSourceOperator) arg;
ILogicalOperator inputToCreator2 = nts.getSourceOperator();