You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mh...@apache.org on 2018/07/29 01:18:55 UTC
asterixdb git commit: [NO ISSUE][FUN] Add docs for array functions,
handle FP.
Repository: asterixdb
Updated Branches:
refs/heads/master e2c8afe90 -> afadf2cad
[NO ISSUE][FUN] Add docs for array functions, handle FP.
- user model changes: no
- storage format changes: no
- interface changes: no
details:
Add docs for array functions and remove error codes from
error messages in test suite.
This patch also includes handling of floating-point number
arguments for array_range(), array_insert(), array_repeat().
Change-Id: I908338a7db9c0aa0b30acc6f9810327604a8368c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2794
Reviewed-by: Till Westmann <ti...@apache.org>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/afadf2ca
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/afadf2ca
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/afadf2ca
Branch: refs/heads/master
Commit: afadf2cadeb90c372265989abae4acf9a6ec2e68
Parents: e2c8afe
Author: Ali Alsuliman <al...@gmail.com>
Authored: Thu Jul 26 21:22:25 2018 -0700
Committer: Murtadha Hubail <mh...@apache.org>
Committed: Sat Jul 28 18:18:41 2018 -0700
----------------------------------------------------------------------
.../array_insert/array_insert.3.query.sqlpp | 7 +++--
.../array_range/array_range.3.query.sqlpp | 5 +++-
.../array_repeat/array_repeat.1.query.sqlpp | 9 ++++--
.../array_fun/array_insert/array_insert.3.adm | 2 +-
.../array_fun/array_range/array_range.3.adm | 2 +-
.../array_fun/array_repeat/array_repeat.1.adm | 2 +-
.../resources/runtimets/testsuite_sqlpp.xml | 4 +--
.../functions/ArrayAppendDescriptor.java | 4 +--
.../functions/ArrayConcatDescriptor.java | 4 +--
.../functions/ArrayContainsDescriptor.java | 5 ++--
.../functions/ArrayDistinctDescriptor.java | 18 ++++++++++++
.../functions/ArrayFlattenDescriptor.java | 4 +--
.../functions/ArrayInsertDescriptor.java | 18 ++++++------
.../functions/ArrayIntersectDescriptor.java | 18 ++++++++++++
.../functions/ArrayPositionDescriptor.java | 2 +-
.../functions/ArrayPrependDescriptor.java | 4 +--
.../functions/ArrayPutDescriptor.java | 4 +--
.../functions/ArrayRangeDescriptor.java | 25 +++++++++++++++--
.../functions/ArrayRemoveDescriptor.java | 8 +++---
.../functions/ArrayRepeatDescriptor.java | 28 ++++++++++++++++---
.../functions/ArrayReplaceDescriptor.java | 21 ++++++++++++++
.../functions/ArrayReverseDescriptor.java | 14 ++++++++--
.../functions/ArraySortDescriptor.java | 16 +++++++++++
.../functions/ArrayStarDescriptor.java | 29 ++++++++++++++++++++
.../functions/ArraySymDiffDescriptor.java | 18 ++++++++++++
.../functions/ArraySymDiffnDescriptor.java | 18 ++++++++++++
.../functions/ArrayUnionDescriptor.java | 6 ++--
27 files changed, 249 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp
index fdc35cc..c0b65e7 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_insert/array_insert.3.query.sqlpp
@@ -33,12 +33,15 @@ use TinySocial;
"t11": (array_insert([], 0, 10, 12.0, "sth")), // OK
"t12": (array_insert([6], "a", 9)), // null, position non-numeric
"t13": (array_insert([6], 1.0, 9)), // OK
- "t14": (array_insert([6], 1.5, 9)), // OK
+ "t14": (array_insert([6], 1.5, 9)), // null, position with decimals
"t15": (array_insert(null, 3, 9)), // null
"t16": (array_insert(missing, 3, 9)), // missing
"t17": (array_insert([6], 1, null, 9, null)), // OK to insert nulls
"t18": (array_insert([6], null, 5, 9, null)), // null
"t19": (array_insert([6], 3, null, missing, 9, null)), // missing
"t20": (select array_insert(t.`referred-topics`, 0, 5) from TweetMessages t order by t.tweetid),
- "t21": (select array_insert(d.followers, 0, 5, 3) from d1 d)
+ "t21": (select array_insert(d.followers, 0, 5, 3) from d1 d),
+ "t22": (array_insert([1,2,3], float("NaN"), "a", "b")),
+ "t23": (array_insert([1,2,3], float("INF"), "a", "b")),
+ "t24": (array_insert([1,2,3], float("-INF"), "a", "b"))
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_range/array_range.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_range/array_range.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_range/array_range.3.query.sqlpp
index f189fc1..d36a9f1 100755
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_range/array_range.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_range/array_range.3.query.sqlpp
@@ -36,5 +36,8 @@ use TinySocial;
"t14": (array_range(2, missing)),
"t15": (array_range(2, 7, "a")),
"t16": (array_range(2, "a", 1)),
- "t17": (array_range("a", 7, 1))
+ "t17": (array_range("a", 7, 1)),
+ "t18": (array_range(5, 10, float("NaN"))),
+ "t19": (array_range(5, float("INF"), 1)),
+ "t20": (array_range(5, float("-INF"), -2))
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_repeat/array_repeat.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_repeat/array_repeat.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_repeat/array_repeat.1.query.sqlpp
index 50a0d7b..a5ebb4c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_repeat/array_repeat.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/array_fun/array_repeat/array_repeat.1.query.sqlpp
@@ -22,12 +22,17 @@
"t1": (select value array_repeat("a", 3)),
"t2": (array_repeat("a", 3)),
"t3": (array_repeat("a", 0)),
- "t4": (array_repeat("a", -3)),
+ "t4": (array_repeat("a", -3)), // null
"t5": (array_repeat("a", "a")),
"t6": (array_repeat("a", missing)),
"t7": (array_repeat(missing, 3)),
"t8": (array_repeat("a", null)),
"t9": (array_repeat(null, 3)),
"t10": (array_repeat({ "a": 1 }, 3)),
- "t11": (array_repeat([1, 2], 3))
+ "t11": (array_repeat([1, 2], 3)),
+ "t12": (array_repeat("a", 4.0)), // OK
+ "t13": (array_repeat("a", 4.1)), // null
+ "t14": (array_repeat("a", double("INF"))), // null
+ "t15": (array_repeat("a", double("-INF"))), // null
+ "t16": (array_repeat("a", double("NaN"))) // null
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm
index 8e136ca..0acb072 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_insert/array_insert.3.adm
@@ -1 +1 @@
-{ "t1": [ "a", "b", 1, 2, 3 ], "t2": [ 1, 2, 3, "a", "b" ], "t3": [ 1, 1, 2, "a", "b", 4 ], "t4": [ 1, 1, 2, 7, "a", 7, "one more", 4 ], "t5": null, "t6": [ 1, 2, "a", "b", 3 ], "t7": null, "t8": null, "t10": null, "t11": [ 10, 12.0, "sth" ], "t12": null, "t13": [ 6, 9 ], "t14": [ 6, 9 ], "t15": null, "t17": [ 6, null, 9, null ], "t18": null, "t20": [ { "$1": {{ 5, "t-mobile", "customization" }} }, { "$1": {{ 5, "verizon", "voice-clarity" }} }, { "$1": {{ 5, "iphone", "platform" }} }, { "$1": {{ 5, "samsung", "voice-command" }} }, { "$1": {{ 5, "verizon", "shortcut-menu" }} }, { "$1": {{ 5, "motorola", "speed" }} }, { "$1": {{ 5, "sprint", "voice-command" }} }, { "$1": {{ 5, "motorola", "speed" }} }, { "$1": {{ 5, "iphone", "voice-clarity" }} }, { "$1": {{ 5, "samsung", "platform" }} }, { "$1": {{ 5, "t-mobile", "shortcut-menu" }} }, { "$1": {{ 5, "verizon", "voicemail-service" }} } ], "t21": [ { }, { "$2": [ 5, 3, "John Green", "Emily Jones" ] } ] }
+{ "t1": [ "a", "b", 1, 2, 3 ], "t2": [ 1, 2, 3, "a", "b" ], "t3": [ 1, 1, 2, "a", "b", 4 ], "t4": [ 1, 1, 2, 7, "a", 7, "one more", 4 ], "t5": null, "t6": [ 1, 2, "a", "b", 3 ], "t7": null, "t8": null, "t10": null, "t11": [ 10, 12.0, "sth" ], "t12": null, "t13": [ 6, 9 ], "t14": null, "t15": null, "t17": [ 6, null, 9, null ], "t18": null, "t20": [ { "$1": {{ 5, "t-mobile", "customization" }} }, { "$1": {{ 5, "verizon", "voice-clarity" }} }, { "$1": {{ 5, "iphone", "platform" }} }, { "$1": {{ 5, "samsung", "voice-command" }} }, { "$1": {{ 5, "verizon", "shortcut-menu" }} }, { "$1": {{ 5, "motorola", "speed" }} }, { "$1": {{ 5, "sprint", "voice-command" }} }, { "$1": {{ 5, "motorola", "speed" }} }, { "$1": {{ 5, "iphone", "voice-clarity" }} }, { "$1": {{ 5, "samsung", "platform" }} }, { "$1": {{ 5, "t-mobile", "shortcut-menu" }} }, { "$1": {{ 5, "verizon", "voicemail-service" }} } ], "t21": [ { }, { "$2": [ 5, 3, "John Green", "Emily Jones" ] } ], "t22": null, "t23": null, "t24": nul
l }
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_range/array_range.3.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_range/array_range.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_range/array_range.3.adm
index e04c673..362debf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_range/array_range.3.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_range/array_range.3.adm
@@ -1 +1 @@
-{ "t1": [ 1, 2, 3, 4, 5 ], "t2": [ 0, 5, 10, 15, 20 ], "t3": [ 0.1, 1.1 ], "t4": [ 10, 7, 4 ], "t5": [ -1, -4, -7 ], "t6": [ ], "t7": [ ], "t8": [ ], "t9": [ ], "t10": [ 2 ], "t11": [ 2.0, 3.1, 4.2, 5.300000000000001, 6.4, 7.5, 8.6 ], "t12": null, "t15": null, "t16": null, "t17": null }
+{ "t1": [ 1, 2, 3, 4, 5 ], "t2": [ 0, 5, 10, 15, 20 ], "t3": [ 0.1, 1.1 ], "t4": [ 10, 7, 4 ], "t5": [ -1, -4, -7 ], "t6": [ ], "t7": [ ], "t8": [ ], "t9": [ ], "t10": [ 2 ], "t11": [ 2.0, 3.1, 4.2, 5.300000000000001, 6.4, 7.5, 8.6 ], "t12": null, "t15": null, "t16": null, "t17": null, "t18": null, "t19": null, "t20": null }
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_repeat/array_repeat.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_repeat/array_repeat.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_repeat/array_repeat.1.adm
index 183211f..963aeac 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_repeat/array_repeat.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/array_fun/array_repeat/array_repeat.1.adm
@@ -1 +1 @@
-{ "t1": [ [ "a", "a", "a" ] ], "t2": [ "a", "a", "a" ], "t3": [ ], "t4": [ ], "t5": null, "t8": null, "t9": null, "t10": [ { "a": 1 }, { "a": 1 }, { "a": 1 } ], "t11": [ [ 1, 2 ], [ 1, 2 ], [ 1, 2 ] ] }
+{ "t1": [ [ "a", "a", "a" ] ], "t2": [ "a", "a", "a" ], "t3": [ ], "t4": null, "t5": null, "t8": null, "t9": null, "t10": [ { "a": 1 }, { "a": 1 }, { "a": 1 } ], "t11": [ [ 1, 2 ], [ 1, 2 ], [ 1, 2 ] ], "t12": [ "a", "a", "a", "a" ], "t13": null, "t14": null, "t15": null, "t16": null }
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
----------------------------------------------------------------------
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 ada210e..9ca1fbd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -1089,8 +1089,8 @@
<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>ASX1087: Invalid number of arguments for function array-replace (in line 27, at column 8)</expected-error>
- <expected-error>ASX1087: 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>
+ <expected-error>Invalid number of arguments for function array-replace (in line 27, at column 8)</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="array_fun">
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayAppendDescriptor.java
----------------------------------------------------------------------
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 6d636ed..009d7b3 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
@@ -39,7 +39,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
* <pre>
- * array_append(list, val1, val2, ...) returns a new open list with all the values appended to the input list items.
+ * array_append(list, val1, val2, ...) returns a new list with all the values appended to the input list items.
* Values can be null (i.e., one can append nulls)
*
* It throws an error at compile time if the number of arguments < 2
@@ -47,7 +47,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
* It returns in order:
* 1. missing, if any argument is missing.
* 2. null, if the list arg is null or it's not a list.
- * 3. otherwise, a new open list.
+ * 3. otherwise, a new list.
*
* </pre>
*/
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayConcatDescriptor.java
----------------------------------------------------------------------
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 9af159c..c808ec5 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
@@ -36,7 +36,7 @@ import org.apache.hyracks.data.std.api.IPointable;
/**
* <pre>
- * array_concat(list1, list2, ...) returns a new open list with all the values of all lists appended in order into the
+ * array_concat(list1, list2, ...) returns a new list with all the values of all lists appended in order into the
* new list. Items of the lists can be null or missing (both are added as a null value).
*
* It throws an error at compile time if the number of arguments < 2
@@ -45,7 +45,7 @@ import org.apache.hyracks.data.std.api.IPointable;
* 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. otherwise, a new open list.
+ * 4. otherwise, a new list.
*
* </pre>
*/
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayContainsDescriptor.java
----------------------------------------------------------------------
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 16bb0c9..5443834 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
@@ -37,14 +37,15 @@ import org.apache.hyracks.data.std.api.IPointable;
/**
* <pre>
- * array_contains(list, val) returns true if the the input list contains the value argument.
+ * array_contains(list, val) returns true if the the input list contains the value argument. It's case-sensitive to
+ * string value argument.
*
* It throws an error at compile time if the number of arguments != 2
*
* 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.
+ * 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.
*
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayDistinctDescriptor.java
----------------------------------------------------------------------
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 4ac1f8dc..648132c 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
@@ -52,6 +52,24 @@ import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+/**
+ * <pre>
+ * array_distinct(list) returns a new list with distinct items of the input list. The returned list has the same type as
+ * the input list. The list can contain null and missing items. Null and missing are considered to be the same.
+ * It's case-sensitive to string items.
+ *
+ * array_distinct([1,2,null,4,missing,2,1]) will output [1,2,null,4]
+ *
+ * It throws an error at compile time if the number of arguments != 1
+ *
+ * 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.
+ *
+ * </pre>
+ */
public class ArrayDistinctDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
private IAType inputListType;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayFlattenDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayFlattenDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayFlattenDescriptor.java
index af55eea..06381b5 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayFlattenDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayFlattenDescriptor.java
@@ -57,7 +57,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
* <pre>
- * array_flatten(list, depth) returns a new open list with any nested list (all types) flattened up to the specified
+ * array_flatten(list, depth) returns a new list with any nested list (all types) flattened up to the specified
* depth. The returned list type is the same as the input list type. Null and missing items are preserved.
* If the depth < 0, then it flattens the input list all the way deep.
*
@@ -73,7 +73,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
* - the input list is not a list.
* - the depth arg is not numeric or
* - it's a floating-point number with decimals (e.g. 1.2 will produce null, 1.0 is OK).
- * 3. otherwise, a new open list.
+ * 3. otherwise, a new list.
*
* </pre>
*/
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayInsertDescriptor.java
----------------------------------------------------------------------
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 634f114..969e1d7 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
@@ -43,11 +43,10 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
* <pre>
- * array_insert(list, pos, val1, val2, ...) returns a new open list with all values inserted at the specified position.
+ * array_insert(list, pos, val1, val2, ...) returns a new list with all values inserted at the specified position.
* Values can be null (i.e., one can insert nulls). Position can be negative where the last position = -1. When position
* is positive then the first position = 0. Input list can be empty where the only valid position is 0.
* For the list [5,6], the valid positions are 0, 1, 2, -1, -2. If position is floating-point, it's casted to integer.
- * TODO: should decide on what to do for floating-point positions.
*
* It throws an error at compile time if the number of arguments < 3
*
@@ -55,8 +54,8 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
* 1. missing, if any argument is missing.
* 2. null, if
* - the list arg is null or it's not a list
- * - the position is not numeric or the position is out of bound.
- * 3. otherwise, a new open list.
+ * - the position is not numeric or the position is out of bound or it's a floating-point with decimals or NaN or +-INF.
+ * 3. otherwise, a new list.
*
* </pre>
*/
@@ -117,14 +116,17 @@ public class ArrayInsertDescriptor extends AbstractScalarFunctionDynamicDescript
return RETURN_MISSING;
}
- int position;
- if (!ATypeHierarchy.isCompatible(ATypeTag.INTEGER, ATYPETAGDESERIALIZER.deserialize(positionArg.getTag()))
+ double position;
+ if (!ATypeHierarchy.isCompatible(ATypeTag.DOUBLE, ATYPETAGDESERIALIZER.deserialize(positionArg.getTag()))
|| !listTag.isListType()) {
return RETURN_NULL;
} else {
String name = getIdentifier().getName();
- position = ATypeHierarchy.getIntegerValue(name, 1, positionArg.getByteArray(),
+ position = ATypeHierarchy.getDoubleValue(name, 1, positionArg.getByteArray(),
positionArg.getStartOffset());
+ if (Double.isNaN(position) || Double.isInfinite(position) || Math.floor(position) < position) {
+ return RETURN_NULL;
+ }
// list size
int size;
if (listTag == ATypeTag.ARRAY) {
@@ -140,7 +142,7 @@ public class ArrayInsertDescriptor extends AbstractScalarFunctionDynamicDescript
if (position < 0 || position > size) {
return RETURN_NULL;
}
- return position;
+ return (int) position;
}
}
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayIntersectDescriptor.java
----------------------------------------------------------------------
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 706cb53..52335a0 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
@@ -67,6 +67,24 @@ 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>
+ * array_intersect(list1, list2, ...) returns a new list containing items that are present in all of the input
+ * lists. Null and missing items are ignored. It's case-sensitive to string items.
+ *
+ * array_intersect([null, 2, missing], [3,missing,2,null]) will result in [2].
+ *
+ * It throws an error at compile time if the number of arguments < 2
+ *
+ * It returns (or throws an error at runtime) in order:
+ * 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.
+ *
+ * </pre>
+ */
public class ArrayIntersectDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
private IAType[] argTypes;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPositionDescriptor.java
----------------------------------------------------------------------
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 e4e54f1..411e846 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
@@ -37,7 +37,7 @@ import org.apache.hyracks.data.std.api.IPointable;
/**
* <pre>
* array_position(list, val) returns the 0-based position (as integer) of the value argument in the input list. If the
- * value does not exists, it returns -1
+ * value does not exists, it returns -1. It's case-sensitive to string value argument.
*
* It throws an error at compile time if the number of arguments != 2
*
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPrependDescriptor.java
----------------------------------------------------------------------
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 dcb6ad8..fa56fb1 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
@@ -37,7 +37,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
* <pre>
- * array_prepend(val1, val2, ..., list) returns a new open list with all the values prepended to the input list items.
+ * array_prepend(val1, val2, ..., list) returns a new list with all the values prepended to the input list items.
* Values can be null (i.e., one can append nulls)
*
* It throws an error at compile time if the number of arguments < 2
@@ -45,7 +45,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
* It returns in order:
* 1. missing, if any argument is missing.
* 2. null, if the list arg is null or it's not a list.
- * 3. otherwise, a new open list.
+ * 3. otherwise, a new list.
*
* </pre>
*/
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayPutDescriptor.java
----------------------------------------------------------------------
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 fc17e99..86321da 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
@@ -46,7 +46,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
* <pre>
- * array_put(list, val1, val2, ...) returns a new open list with all the values appended to the input list items only if
+ * array_put(list, val1, val2, ...) returns a new list with all the values appended to the input list items only if
* the list does not already have the value. Values cannot be null (i.e., one cannot append nulls).
* array_put([2, 3], 2, 2, 9, 9) will result in [2, 3, 9, 9].
*
@@ -56,7 +56,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
* 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 open list.
+ * 4. otherwise, a new list.
*
* </pre>
*/
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRangeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRangeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRangeDescriptor.java
index 4068101..902ec7a 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRangeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRangeDescriptor.java
@@ -44,6 +44,22 @@ import org.apache.hyracks.data.std.primitive.TaggedValuePointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+/**
+ * <pre>
+ * array_range(start_num, end_num, step_num?) returns a new ordered list, list of long items or double items
+ * depending on the supplied arguments. One floating-point arg will make it a list of double items. step_num is optional
+ * where the default is 1. It returns an empty list for arguments like:
+ * array_range(2, 20, -2), array_range(10, 3, 4) and array_range(1,6,0) where it cannot determine a proper sequence.
+ *
+ * It throws an error at compile time if the number of arguments < 2 or > 3
+ *
+ * It returns in order:
+ * 1. missing, if any argument is missing.
+ * 2. null, if any argument is null or they are not numeric or they are NaN +-INF.
+ * 3. otherwise, a new list.
+ *
+ * </pre>
+ */
public class ArrayRangeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
@@ -118,8 +134,8 @@ public class ArrayRangeDescriptor extends AbstractScalarFunctionDynamicDescripto
stepNum = ATypeHierarchy.getDoubleValue(n, 2, step.getByteArray(), step.getStartOffset());
}
- if (!ATypeHierarchy.isCompatible(ATypeTag.DOUBLE, startTag)
- || !ATypeHierarchy.isCompatible(ATypeTag.DOUBLE, endTag)) {
+ if (!ATypeHierarchy.isCompatible(ATypeTag.DOUBLE, startTag) || Double.isNaN(stepNum)
+ || !ATypeHierarchy.isCompatible(ATypeTag.DOUBLE, endTag) || Double.isInfinite(stepNum)) {
PointableHelper.setNull(result);
return;
}
@@ -145,6 +161,11 @@ public class ArrayRangeDescriptor extends AbstractScalarFunctionDynamicDescripto
serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADOUBLE);
double startNum = ATypeHierarchy.getDoubleValue(n, 0, start.getByteArray(), start.getStartOffset());
double endNum = ATypeHierarchy.getDoubleValue(n, 1, end.getByteArray(), end.getStartOffset());
+ if (Double.isNaN(startNum) || Double.isInfinite(startNum) || Double.isNaN(endNum)
+ || Double.isInfinite(endNum)) {
+ PointableHelper.setNull(result);
+ return;
+ }
listBuilder.reset(ArrayRangeTypeComputer.DOUBLE_LIST);
while ((startNum < endNum && stepNum > 0) || (startNum > endNum && stepNum < 0)) {
aDouble.setValue(startNum);
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRemoveDescriptor.java
----------------------------------------------------------------------
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 ea27017..a5afa5f 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
@@ -44,16 +44,16 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
* <pre>
- * array_remove(list, val1, val2, ...) returns a new (open or closed) list with all the values removed from the input
- * list. Values cannot be null (i.e., one cannot remove nulls).
+ * array_remove(list, val1, val2, ...) returns a new list with all the values removed from the input
+ * list. Values cannot be null (i.e., one cannot remove nulls). It's case-sensitive to string value arguments.
*
* It throws an error at compile time if the number of arguments < 2
*
* It returns (or throws an error at runtime) in order:
* 1. missing, if any argument is missing.
* 2. null, if any argument is null.
- * 4. an error if any value arg is of a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 3. otherwise, a new list that has the same type as the input list.
+ * 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.
*
* </pre>
*/
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRepeatDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRepeatDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRepeatDescriptor.java
index ce9d3cc..5e50fe0 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRepeatDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayRepeatDescriptor.java
@@ -43,10 +43,25 @@ 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>
+ * array_repeat(val, num_times) returns a new ordered list with the same item type as the input value.
+ *
+ * It throws an error at compile time if the number of arguments != 2
+ *
+ * It returns in order:
+ * 1. missing, if any argument is missing.
+ * 2. null, if:
+ * - any argument is null
+ * - num_times is not numeric or it's a floating-point with decimals (3.2) or it's NaN/+-INF or it's negative.
+ * 3. otherwise, a new ordered list.
+ *
+ * </pre>
+ */
public class ArrayRepeatDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
- AbstractCollectionType repeatedValueListType;
+ private AbstractCollectionType repeatedValueListType;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
@@ -110,14 +125,19 @@ public class ArrayRepeatDescriptor extends AbstractScalarFunctionDynamicDescript
// 2nd arg: number of repetitions
repeatEval.evaluate(tuple, repeatArg);
repeatArgValue.set(repeatArg);
- if (!ATypeHierarchy.isCompatible(ATypeTag.INTEGER, ATypeTag.VALUE_TYPE_MAPPING[repeatArgValue.getTag()])) {
+ if (!ATypeHierarchy.isCompatible(ATypeTag.DOUBLE, ATypeTag.VALUE_TYPE_MAPPING[repeatArgValue.getTag()])) {
PointableHelper.setNull(result);
return;
}
final String name = getIdentifier().getName();
- final int repetitions =
- ATypeHierarchy.getIntegerValue(name, 1, repeatArg.getByteArray(), repeatArg.getStartOffset());
+ final double repetitions =
+ ATypeHierarchy.getDoubleValue(name, 1, repeatArg.getByteArray(), repeatArg.getStartOffset());
+ if (Double.isNaN(repetitions) || Double.isInfinite(repetitions) || Math.floor(repetitions) < repetitions
+ || repetitions < 0) {
+ PointableHelper.setNull(result);
+ return;
+ }
// create list
listBuilder.reset(repeatedValueListType);
for (int i = 0; i < repetitions; ++i) {
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReplaceDescriptor.java
----------------------------------------------------------------------
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 e8d77a8..032ef32 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
@@ -54,6 +54,27 @@ 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>
+ * array_replace(list, val1, val2, max_num_times?) returns a new list with the occurrences of val1 replaced with
+ * val2. max_num_times arg is optional. If supplied, it replaces val1 as many as max_num_times. Any negative number for
+ * max_num_times means "replace all occurrences". val2 can be null meaning you can replace existing items with nulls.
+ *
+ * array_replace([2,3,3,3,1], 3, 8, 0) will do nothing and result in [2,3,3,3,1].
+ *
+ * It throws an error at compile time if the number of arguments < 3 or > 4
+ *
+ * It returns (or throws an error at runtime) in order:
+ * 1. missing, if any argument is missing.
+ * 2. null, if:
+ * - 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.
+ *
+ * </pre>
+ */
public class ArrayReplaceDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
private IAType inputListType;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReverseDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReverseDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReverseDescriptor.java
index 331c9a4..05a5c39 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReverseDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayReverseDescriptor.java
@@ -40,8 +40,18 @@ import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
/**
- * array_reverse(list) returns a new list with the entries of the original input list in reverse order. If the input is
- * not a list, it returns "null".
+ * <pre>
+ * array_reverse(list) returns a new list with the entries of the original input list in reverse order.
+ * The returned list has the same type as the input list. The list can contain null/missing items. Both are preserved.
+ *
+ * It throws an error at compile time if the number of arguments != 1
+ *
+ * It returns in order:
+ * 1. missing, if any argument is missing.
+ * 2. null, if the list arg is null or it's not a list.
+ * 3. otherwise, a new list.
+ *
+ * </pre>
*/
public class ArrayReverseDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySortDescriptor.java
----------------------------------------------------------------------
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 12ae2fd..1d8db47 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
@@ -47,6 +47,22 @@ import org.apache.hyracks.api.exceptions.SourceLocation;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+/**
+ * <pre>
+ * array_sort(list) returns a new list with the items sorted in ascending order. The returned list has the same type as
+ * the input list. The list can contain null and missing items, and both are preserved. It's case-sensitive to string
+ * items.
+ *
+ * It throws an error at compile time if the number of arguments != 1
+ *
+ * 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.
+ *
+ * </pre>
+ */
public class ArraySortDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
private IAType inputListType;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java
index 2c4c308..4bc885c 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayStarDescriptor.java
@@ -54,6 +54,35 @@ 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>
+ * array_star(ordered_list) returns a new object. The input ordered list is supposed to be a list of objects:
+ * [{"id":1, "dept":"CS"}, {"id":2, "dept":"FIN"}, {"id":3, "dept":"CS"}]
+ * For the returned object, each field has a value = list of values of that specific field taken from each object in the
+ * input list.
+ *
+ * Ex1: array_star([{"a":1, "b":2}, {"a":9, "b":4}]) will produce: {"a":[1, 9], "b":[2, 4]}
+ * Ex2: array_star([{"a":1}, {"a":9, "b":4}]) will produce: {"a":[1, 9], "b":[null, 4]}
+ * Ex3: array_star([{"a":1, "c":5}, {"a":9, "b":4}]) will produce: {"a":[1, 9], "b":[null, 4], "c":[5,null]}
+ * Ex4: array_star([{"c":5, "a":1}, "non_object"]) will produce: {"a":[1, null], "c":[5,null]}
+ * Ex5: array_star(["non_object1", "non_object2"]) will produce: {} (i.e., missing)
+ *
+ * Note that in the final object result, the fields are ordered by their names regardless of their original order in the
+ * object items in the input list. "a" comes before "c". However, for every field, all the items in each list must not
+ * be ordered. They should appear in the sequence they appear in the input list.
+ * For Ex1, "a":[1,9] in the final result, item at index 0 comes from object at index 0 (which is 1).
+ *
+ * It throws an error at compile time if the number of arguments != 1
+ *
+ * It returns in order:
+ * 1. missing, if any argument is missing.
+ * 2. null, if the list arg is null or it's not an ordered list.
+ * 3. missing, if input list is missing the notion of fields.
+ * E.g., the input list contains no object items (e.g., list of int), or all objects have no fields.
+ * 4. otherwise, a new object.
+ *
+ * </pre>
+ */
public class ArrayStarDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffDescriptor.java
index 4dce4df..f9e68df 100755
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffDescriptor.java
@@ -32,6 +32,24 @@ import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;
+/**
+ * <pre>
+ * array_symdiff(list1, list2, ...) returns a new list based on the set symmetric difference, or disjunctive union,
+ * of the input. The new list contains only those items that appear in exactly one of the input lists.
+ * array_symdiff([null, 2,3], [missing, 3]) will result in [2, null, null] where one null is for the missing item
+ * and the second null for the null item.
+ *
+ * It throws an error at compile time if the number of arguments < 2
+ *
+ * It returns (or throws an error at runtime) in order:
+ * 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.
+ *
+ * </pre>
+ */
public class ArraySymDiffDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
private IAType[] argTypes;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArraySymDiffnDescriptor.java
----------------------------------------------------------------------
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 26c438d..0cafb1b 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
@@ -32,6 +32,24 @@ import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;
+/**
+ * <pre>
+ * array_symdiffn(list1, list2, ...) returns a new list based on the set symmetric difference, or disjunctive
+ * union, of the input lists. The new list contains only those items that appear in an odd number of input lists.
+ * array_symdiffn([null, 2,3], [missing, 3]) will result in [2, null, null] where one null is for the missing item
+ * and the second null for the null item.
+ *
+ * It throws an error at compile time if the number of arguments < 2
+ *
+ * It returns (or throws an error at runtime) in order:
+ * 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.
+ *
+ * </pre>
+ */
public class ArraySymDiffnDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
private IAType[] argTypes;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/afadf2ca/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/ArrayUnionDescriptor.java
----------------------------------------------------------------------
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 0a0a6ef..d6a2f1f 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
@@ -49,7 +49,7 @@ import org.apache.hyracks.data.std.api.IPointable;
/**
* <pre>
- * array_union(list1, list2, ...) returns a new open list with the set union of the input lists (no duplicates).
+ * array_union(list1, list2, ...) returns a new list with the set union of the input lists (no duplicates).
* Items of the lists can be null or missing (both are added as a null value).
* array_union([null, 2], [missing, 3, null]) will result in [null, 2, null, 3] where one null is for the missing item
* and the second null for the null item.
@@ -60,8 +60,8 @@ import org.apache.hyracks.data.std.api.IPointable;
* 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 of a list/object type (i.e. derived type) since deep equality is not yet supported.
- * 5. otherwise, a new open 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.
*
* </pre>
*/