This is an automated email from the ASF dual-hosted git repository.

dlych pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 593204d  [NO ISSUE][FUN] Add ARRAY_AGG() SQL aggregate function
593204d is described below

commit 593204d12e42f77e5b00e389534d2d0a2984e71e
Author: Dmitry Lychagin <[email protected]>
AuthorDate: Fri May 10 14:15:05 2019 -0700

    [NO ISSUE][FUN] Add ARRAY_AGG() SQL aggregate function
    
    - user model changes: yes
    - storage format changes: no
    - interface changes: no
    
    Details:
    - Implement support for ARRAY_AGG() aggregate function.
    - Add new testcases and update documentation
    - Add AbstractScalarDistinctAggregateDescriptor.createDescriptorFactory()
      to uniformly set required type inferer for all distinct scalar aggregates
    - Propagate correct item type to GenericScalarDistinctAggregateFunction
    
    Change-Id: I704e031a1252493e83ad8d45c38b75e0b15c1896
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/3390
    Contrib: Jenkins <[email protected]>
    Tested-by: Jenkins <[email protected]>
    Integration-Tests: Jenkins <[email protected]>
    Reviewed-by: Ali Alsuliman <[email protected]>
---
 .../array_agg/array_agg.1.query.sqlpp              | 25 +++++++++++
 .../array_agg/array_agg.2.query.sqlpp              | 26 +++++++++++
 .../array_agg/array_agg.3.query.sqlpp              | 25 +++++++++++
 .../array_agg/array_agg.4.query.sqlpp              | 25 +++++++++++
 .../array_agg/array_agg.5.query.sqlpp              | 25 +++++++++++
 .../array_agg/array_agg.6.query.sqlpp              | 27 +++++++++++
 .../array_agg_negative.1.query.sqlpp               | 24 ++++++++++
 .../aggregate-sql-sugar/array_agg/array_agg.1.adm  |  1 +
 .../aggregate-sql-sugar/array_agg/array_agg.2.adm  |  1 +
 .../aggregate-sql-sugar/array_agg/array_agg.3.adm  |  1 +
 .../aggregate-sql-sugar/array_agg/array_agg.4.adm  |  1 +
 .../aggregate-sql-sugar/array_agg/array_agg.5.adm  |  1 +
 .../aggregate-sql-sugar/array_agg/array_agg.6.adm  |  1 +
 .../test/resources/runtimets/testsuite_sqlpp.xml   | 11 +++++
 .../asterix-doc/src/main/markdown/sqlpp/3_query.md | 12 ++---
 .../ScalarSTUnionDistinctAggregateDescriptor.java  |  6 +--
 .../lang/common/util/CommonFunctionMapUtil.java    |  8 ++--
 .../asterix/lang/sqlpp/util/FunctionMapUtil.java   | 32 +++++++++----
 .../asterix/om/functions/BuiltinFunctions.java     | 24 ++++++++--
 .../impl/ScalarArrayAggTypeComputer.java           | 52 ++++++++++++++++++++++
 .../om/typecomputer/impl/TypeComputeUtils.java     | 13 ++++++
 .../asterix/om/typecomputer/TypeComputerTest.java  |  1 +
 .../scalar/AbstractScalarAggregateDescriptor.java  |  8 ++++
 .../AbstractScalarDistinctAggregateDescriptor.java | 15 +++++--
 ...java => ScalarArrayAggAggregateDescriptor.java} | 24 ++++++----
 ...ScalarArrayAggDistinctAggregateDescriptor.java} | 24 +++++-----
 .../ScalarAvgDistinctAggregateDescriptor.java      |  6 +--
 .../ScalarCountDistinctAggregateDescriptor.java    |  6 +--
 .../ScalarKurtosisDistinctAggregateDescriptor.java |  6 +--
 .../ScalarMaxDistinctAggregateDescriptor.java      |  6 +--
 .../ScalarMinDistinctAggregateDescriptor.java      |  6 +--
 .../ScalarSkewnessDistinctAggregateDescriptor.java |  6 +--
 .../ScalarSqlAvgDistinctAggregateDescriptor.java   |  6 +--
 .../ScalarSqlCountDistinctAggregateDescriptor.java |  6 +--
 ...alarSqlKurtosisDistinctAggregateDescriptor.java |  6 +--
 .../ScalarSqlMaxDistinctAggregateDescriptor.java   |  6 +--
 .../ScalarSqlMinDistinctAggregateDescriptor.java   |  6 +--
 ...ScalarSqlStddevDistinctAggregateDescriptor.java |  6 +--
 ...larSqlStddevPopDistinctAggregateDescriptor.java |  6 +--
 .../ScalarSqlSumDistinctAggregateDescriptor.java   |  6 +--
 .../ScalarSqlVarDistinctAggregateDescriptor.java   |  6 +--
 ...ScalarSqlVarPopDistinctAggregateDescriptor.java |  6 +--
 .../ScalarStddevDistinctAggregateDescriptor.java   |  6 +--
 ...ScalarStddevPopDistinctAggregateDescriptor.java |  6 +--
 .../ScalarSumDistinctAggregateDescriptor.java      |  6 +--
 .../ScalarVarDistinctAggregateDescriptor.java      |  6 +--
 .../ScalarVarPopDistinctAggregateDescriptor.java   |  6 +--
 .../runtime/functions/FunctionCollection.java      |  4 ++
 48 files changed, 411 insertions(+), 132 deletions(-)

diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.1.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.1.query.sqlpp
new file mode 100644
index 0000000..991db37
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.1.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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  : array_agg()
+ * Expected Res : Success
+ */
+
+from range(1, 4) x
+select value array_sort(array_agg(x))
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.2.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.2.query.sqlpp
new file mode 100644
index 0000000..04db6d1
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.2.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * 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  : array_agg() preserves NULLs
+ * Expected Res : Success
+ */
+
+from range(1, 5) x
+let y = case when x % 2 = 0 then null else x end
+select value array_sort(array_agg(y))
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.3.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.3.query.sqlpp
new file mode 100644
index 0000000..b0b2499
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.3.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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  : array_agg() with another aggregate
+ * Expected Res : Success
+ */
+
+from range(1, 3) x, range(4, 6) y
+select array_sort(array_agg(x)) as array_agg, sum(y) as sum
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.4.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.4.query.sqlpp
new file mode 100644
index 0000000..76b2468
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.4.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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  : array_agg() with distinct
+ * Expected Res : Success
+ */
+
+from range(1, 4) x, range(1, 2) y
+select value array_sort(array_agg(distinct x))
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.5.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.5.query.sqlpp
new file mode 100644
index 0000000..bffe863
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.5.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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  : array_agg() with complex datatypes
+ * Expected Res : Success
+ */
+
+from range(1, 4) x
+select value array_sort(array_agg({"x": [x]}))
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.6.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.6.query.sqlpp
new file mode 100644
index 0000000..d270f15
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg/array_agg.6.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description  : SQL++ core aggregate for array_agg()
+ * Expected Res : Success
+ */
+
+{
+  "t1": array_sort(strict_arrayagg([1, null, 2, [3], {"a": 4}])),
+  "t2": array_sort(strict_arrayagg(distinct [10, null, 11, 10, 11, [12], {"a": 
13}, [12], {"a": 13}]))
+}
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg_negative/array_agg_negative.1.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg_negative/array_agg_negative.1.query.sqlpp
new file mode 100644
index 0000000..4e8f2e9
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql-sugar/array_agg_negative/array_agg_negative.1.query.sqlpp
@@ -0,0 +1,24 @@
+/*
+ * 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  : array_agg()
+ * Expected Res : Failure: wrong context for SQL-92 aggregate function
+ */
+
+array_agg([1,2])
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.1.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.1.adm
new file mode 100644
index 0000000..243bc25
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.1.adm
@@ -0,0 +1 @@
+[ 1, 2, 3, 4 ]
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.2.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.2.adm
new file mode 100644
index 0000000..d121386
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.2.adm
@@ -0,0 +1 @@
+[ null, null, 1, 3, 5 ]
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.3.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.3.adm
new file mode 100644
index 0000000..5467499
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.3.adm
@@ -0,0 +1 @@
+{ "array_agg": [ 1, 1, 1, 2, 2, 2, 3, 3, 3 ], "sum": 45 }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.4.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.4.adm
new file mode 100644
index 0000000..243bc25
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.4.adm
@@ -0,0 +1 @@
+[ 1, 2, 3, 4 ]
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.5.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.5.adm
new file mode 100644
index 0000000..3dec9b4
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.5.adm
@@ -0,0 +1 @@
+[ { "x": [ 1 ] }, { "x": [ 2 ] }, { "x": [ 3 ] }, { "x": [ 4 ] } ]
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.6.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.6.adm
new file mode 100644
index 0000000..00d55fd
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql-sugar/array_agg/array_agg.6.adm
@@ -0,0 +1 @@
+{ "t1": [ null, 1, 2, [ 3 ], { "a": 4 } ], "t2": [ null, 10, 11, [ 12 ], { 
"a": 13 } ] }
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index f580896..8e96fc5 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -2626,6 +2626,17 @@
   </test-group>
   <test-group name="aggregate-sql-sugar">
     <test-case FilePath="aggregate-sql-sugar">
+      <compilation-unit name="array_agg">
+        <output-dir compare="Text">array_agg</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql-sugar">
+      <compilation-unit name="array_agg_negative">
+        <output-dir compare="Text">array_agg</output-dir>
+        <expected-error>ASX1079: Compilation error: array_agg is a SQL-92 
aggregate function. The SQL++ core aggregate function strict_arrayagg could 
potentially express the intent.</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="aggregate-sql-sugar">
       <compilation-unit name="distinct_mixed">
         <output-dir compare="Text">distinct_mixed</output-dir>
       </compilation-unit>
diff --git a/asterixdb/asterix-doc/src/main/markdown/sqlpp/3_query.md 
b/asterixdb/asterix-doc/src/main/markdown/sqlpp/3_query.md
index c266d40..17d935a 100644
--- a/asterixdb/asterix-doc/src/main/markdown/sqlpp/3_query.md
+++ b/asterixdb/asterix-doc/src/main/markdown/sqlpp/3_query.md
@@ -1238,8 +1238,8 @@ This query returns:
 
 ### <a id="SQL-92_aggregation_functions">SQL-92 Aggregation Functions</a>
 For compatibility with the traditional SQL aggregation functions, the query 
language also offers SQL-92's
-aggregation function symbols (`COUNT`, `SUM`, `MAX`, `MIN`, `AVG`, 
`STDDEV_SAMP`, `STDDEV_POP`, `VAR_SAMP`, `VAR_POP`) 
-as supported syntactic sugar.
+aggregation function symbols (`COUNT`, `SUM`, `MAX`, `MIN`, `AVG`, 
`ARRAY_AGG`, `STDDEV_SAMP`, `STDDEV_POP`, `VAR_SAMP`,
+`VAR_POP`) as supported syntactic sugar.
 The query compiler rewrites queries that utilize these function symbols into 
queries that only
 use the collection aggregate functions of the query language. The following 
example uses the SQL-92 syntax approach
 to compute a result that is identical to that of the more explicit example 
above:
@@ -1260,16 +1260,16 @@ will rewrite as follows:
     GROUP AS `$1`(msg AS msg);
 
 
-The same sort of rewritings apply to the function symbols `SUM`, `MAX`, `MIN`, 
`AVG`, `STDDEV_SAMP`, `STDDEV_POP`, 
-`VAR_SAMP`, and `VAR_POP`. 
+The same sort of rewritings apply to the function symbols `SUM`, `MAX`, `MIN`, 
`AVG`, `ARRAY_AGG`,`STDDEV_SAMP`,
+`STDDEV_POP`, `VAR_SAMP`, and `VAR_POP`.
 In contrast to the collection aggregate functions of the query language, these 
special SQL-92 function symbols
 can only be used in the same way they are in standard SQL (i.e., with the same 
restrictions).
 
 DISTINCT modifier is also supported for these aggregate functions.
 
 The following aggregate function aliases are supported
- 
-| Function       | Aliases                 | 
+
+| Function       | Aliases                 |
 |----------------|-------------------------|
 | STDDEV_SAMP    | STDDEV                  |
 | VAR_SAMP       | VARIANCE, VARIANCE_SAMP |
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 49231ea..def797f 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,8 +22,6 @@ package org.apache.asterix.geo.aggregates;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSTUnionDistinctAggregateDescriptor extends 
AbstractScalarDist
 
     public final static FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_ST_UNION_AGG_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSTUnionDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSTUnionDistinctAggregateDescriptor::new);
 
     private ScalarSTUnionDistinctAggregateDescriptor() {
         super(STUnionAggregateDescriptor.FACTORY);
diff --git 
a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
 
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
index e2e259e..202fe4e 100644
--- 
a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
+++ 
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
@@ -22,7 +22,6 @@ package org.apache.asterix.lang.common.util;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.functions.FunctionSignature;
 import org.apache.asterix.om.functions.BuiltinFunctions;
 
@@ -113,6 +112,8 @@ public class CommonFunctionMapUtil {
         addFunctionMapping("record-remove-fields", "object-remove-fields");
 
         // Array/Mutliset functions
+        addFunctionMapping("array_agg", "arrayagg");
+        addFunctionMapping("array_agg-distinct", "arrayagg-distinct");
         addFunctionMapping("array_length", "len");
 
         // Aggregate functions
@@ -132,10 +133,9 @@ public class CommonFunctionMapUtil {
      * @param fs,
      *            the signature of an user typed function.
      * @return the corresponding system internal function signature if it 
exists, otherwise
-     *         the input function synature.
+     *         the input function signature.
      */
-    public static FunctionSignature 
normalizeBuiltinFunctionSignature(FunctionSignature fs)
-            throws CompilationException {
+    public static FunctionSignature 
normalizeBuiltinFunctionSignature(FunctionSignature fs) {
         String name = fs.getName();
         String lowerCaseName = name.toLowerCase();
         String mappedName = getFunctionMapping(lowerCaseName);
diff --git 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
index daecabb..8df2616 100644
--- 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
+++ 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/util/FunctionMapUtil.java
@@ -21,7 +21,9 @@ package org.apache.asterix.lang.sqlpp.util;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.exceptions.ErrorCode;
@@ -46,10 +48,20 @@ public class FunctionMapUtil {
     private final static String CORE_SQL_AGGREGATE_PREFIX = "array_";
     private final static String INTERNAL_SQL_AGGREGATE_PREFIX = "sql-";
 
+    /**
+     * SQL-92 aggregate functions for which {@link #CORE_AGGREGATE_PREFIX} 
should be used instead of
+     * {@link #CORE_SQL_AGGREGATE_PREFIX} when mapping to a core SQL++ 
function.
+     * (i.e. SQL-92 aggregate functions that preserve NULLs)
+     */
+    private final static Set<String> CORE_AGGREGATE_PREFIX_FUNCTIONS = new 
HashSet<>();
+
     // Maps from a variable-arg SQL function names to an internal list-arg 
function name.
     private static final Map<String, String> LIST_INPUT_FUNCTION_MAP = new 
HashMap<>();
 
     static {
+        
CORE_AGGREGATE_PREFIX_FUNCTIONS.add(BuiltinFunctions.SCALAR_ARRAYAGG.getName());
+        
CORE_AGGREGATE_PREFIX_FUNCTIONS.add(BuiltinFunctions.SCALAR_ARRAYAGG_DISTINCT.getName());
+
         LIST_INPUT_FUNCTION_MAP.put(CONCAT, 
BuiltinFunctions.STRING_CONCAT.getName());
         LIST_INPUT_FUNCTION_MAP.put("greatest", CORE_SQL_AGGREGATE_PREFIX + 
"max");
         LIST_INPUT_FUNCTION_MAP.put("least", CORE_SQL_AGGREGATE_PREFIX + 
"min");
@@ -86,7 +98,9 @@ public class FunctionMapUtil {
             return fs;
         }
         String name = 
applySql92AggregateNameMapping(fs.getName().toLowerCase());
-        return new FunctionSignature(FunctionConstants.ASTERIX_NS, 
CORE_SQL_AGGREGATE_PREFIX + name, fs.getArity());
+        String prefix =
+                CORE_AGGREGATE_PREFIX_FUNCTIONS.contains(name) ? 
CORE_AGGREGATE_PREFIX : CORE_SQL_AGGREGATE_PREFIX;
+        return new FunctionSignature(FunctionConstants.ASTERIX_NS, prefix + 
name, fs.getArity());
     }
 
     /**
@@ -122,25 +136,25 @@ public class FunctionMapUtil {
      */
     public static FunctionSignature 
normalizeBuiltinFunctionSignature(FunctionSignature fs, boolean 
checkSql92Aggregate,
             SourceLocation sourceLoc) throws CompilationException {
-        String internalName = getInternalCoreAggregateFunctionName(fs);
+        FunctionSignature ns = 
CommonFunctionMapUtil.normalizeBuiltinFunctionSignature(fs);
+        String internalName = getInternalCoreAggregateFunctionName(ns);
         if (internalName != null) {
-            FunctionIdentifier fi = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, internalName, fs.getArity());
+            FunctionIdentifier fi = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, internalName, ns.getArity());
             IFunctionInfo finfo = FunctionUtil.getFunctionInfo(fi);
             if (finfo != null && 
BuiltinFunctions.getAggregateFunction(finfo.getFunctionIdentifier()) != null) {
-                return new FunctionSignature(FunctionConstants.ASTERIX_NS, 
internalName, fs.getArity());
+                return new FunctionSignature(FunctionConstants.ASTERIX_NS, 
internalName, ns.getArity());
             }
         } else if (checkSql92Aggregate) {
-            if (isSql92AggregateFunction(fs)) {
+            if (isSql92AggregateFunction(ns)) {
                 throw new CompilationException(ErrorCode.COMPILATION_ERROR, 
sourceLoc,
                         fs.getName() + " is a SQL-92 aggregate function. The 
SQL++ core aggregate function "
-                                + CORE_SQL_AGGREGATE_PREFIX + 
fs.getName().toLowerCase()
+                                + sql92ToCoreAggregateFunction(ns).getName()
                                 + " could potentially express the intent.");
-            } else if (getInternalWindowFunction(fs) != null) {
+            } else if (getInternalWindowFunction(ns) != null) {
                 throw new 
CompilationException(ErrorCode.COMPILATION_UNEXPECTED_WINDOW_EXPRESSION, 
sourceLoc);
             }
         }
-        String mappedName = 
CommonFunctionMapUtil.normalizeBuiltinFunctionSignature(fs).getName();
-        return new FunctionSignature(fs.getNamespace(), mappedName, 
fs.getArity());
+        return new FunctionSignature(ns.getNamespace(), ns.getName(), 
ns.getArity());
     }
 
     /**
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
index df2a868..23ef0ca 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
@@ -115,6 +115,7 @@ import 
org.apache.asterix.om.typecomputer.impl.PropagateTypeComputer;
 import org.apache.asterix.om.typecomputer.impl.RecordAddFieldsTypeComputer;
 import org.apache.asterix.om.typecomputer.impl.RecordMergeTypeComputer;
 import org.apache.asterix.om.typecomputer.impl.RecordRemoveFieldsTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.ScalarArrayAggTypeComputer;
 import 
org.apache.asterix.om.typecomputer.impl.ScalarVersionOfAggregateResultType;
 import org.apache.asterix.om.typecomputer.impl.SleepTypeComputer;
 import org.apache.asterix.om.typecomputer.impl.StringBooleanTypeComputer;
@@ -187,7 +188,6 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-item", 
2);
     public static final FunctionIdentifier ANY_COLLECTION_MEMBER =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, 
"any-collection-member", 1);
-    public static final FunctionIdentifier LISTIFY = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "listify", 1);
     public static final FunctionIdentifier LEN = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "len", 1);
     public static final FunctionIdentifier CONCAT_NON_NULL =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, 
"concat-non-null", FunctionIdentifier.VARARGS);
@@ -472,6 +472,7 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, 
"make-field-name-handle", 1);
 
     // aggregate functions
+    public static final FunctionIdentifier LISTIFY = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "listify", 1);
     public static final FunctionIdentifier AVG = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-avg", 1);
     public static final FunctionIdentifier COUNT = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-count", 1);
     public static final FunctionIdentifier SUM = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sum", 1);
@@ -554,6 +555,8 @@ public class BuiltinFunctions {
     public static final FunctionIdentifier NULL_WRITER =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, 
"agg-null-writer", 1);
 
+    public static final FunctionIdentifier SCALAR_ARRAYAGG =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "arrayagg", 
1);
     public static final FunctionIdentifier SCALAR_AVG = new 
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "avg", 1);
     public static final FunctionIdentifier SCALAR_COUNT =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "count", 1);
@@ -676,6 +679,10 @@ public class BuiltinFunctions {
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, 
"intermediate-kurtosis-serial", 1);
 
     // distinct aggregate functions
+    public static final FunctionIdentifier LISTIFY_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, 
"listify-distinct", 1);
+    public static final FunctionIdentifier SCALAR_ARRAYAGG_DISTINCT =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, 
"arrayagg-distinct", 1);
     public static final FunctionIdentifier COUNT_DISTINCT =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, 
"agg-count-distinct", 1);
     public static final FunctionIdentifier SCALAR_COUNT_DISTINCT =
@@ -1628,7 +1635,6 @@ public class BuiltinFunctions {
         addFunction(INT64_CONSTRUCTOR, AInt64TypeComputer.INSTANCE, true);
         addFunction(LEN, AInt64TypeComputer.INSTANCE, true);
         addFunction(LINE_CONSTRUCTOR, ALineTypeComputer.INSTANCE, true);
-        addPrivateFunction(LISTIFY, 
OrderedListConstructorTypeComputer.INSTANCE, true);
         addPrivateFunction(MAKE_FIELD_INDEX_HANDLE, null, true);
         addPrivateFunction(MAKE_FIELD_NAME_HANDLE, null, true);
 
@@ -1749,6 +1755,8 @@ public class BuiltinFunctions {
         addFunction(NEGINF_IF, DoubleIfTypeComputer.INSTANCE, true);
 
         // Aggregate Functions
+        addPrivateFunction(LISTIFY, 
OrderedListConstructorTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_ARRAYAGG, ScalarArrayAggTypeComputer.INSTANCE, 
true);
         addFunction(MAX, MinMaxAggTypeComputer.INSTANCE, true);
         addPrivateFunction(LOCAL_MAX, MinMaxAggTypeComputer.INSTANCE, true);
         addFunction(MIN, MinMaxAggTypeComputer.INSTANCE, true);
@@ -1961,6 +1969,8 @@ public class BuiltinFunctions {
         addPrivateFunction(SERIAL_INTERMEDIATE_KURTOSIS, 
LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
 
         // Distinct aggregate functions
+        addFunction(LISTIFY_DISTINCT, 
OrderedListConstructorTypeComputer.INSTANCE, true);
+        addFunction(SCALAR_ARRAYAGG_DISTINCT, 
ScalarArrayAggTypeComputer.INSTANCE, true);
 
         addFunction(COUNT_DISTINCT, AInt64TypeComputer.INSTANCE, true);
         addFunction(SCALAR_COUNT_DISTINCT, AInt64TypeComputer.INSTANCE, true);
@@ -2631,13 +2641,19 @@ public class BuiltinFunctions {
         addIntermediateAgg(SERIAL_GLOBAL_SUM, SERIAL_INTERMEDIATE_SUM);
         addGlobalAgg(SERIAL_SUM, SERIAL_GLOBAL_SUM);
 
-        // SUM Distinct
+        // SUM DISTINCT
         addDistinctAgg(SUM_DISTINCT, SUM);
         addScalarAgg(SUM_DISTINCT, SCALAR_SUM_DISTINCT);
 
-        // LISTIFY
+        // LISTIFY/ARRAY_AGG
 
         addAgg(LISTIFY);
+        addScalarAgg(LISTIFY, SCALAR_ARRAYAGG);
+
+        // LISTIFY/ARRAY_AGG DISTINCT
+
+        addDistinctAgg(LISTIFY_DISTINCT, LISTIFY);
+        addScalarAgg(LISTIFY_DISTINCT, SCALAR_ARRAYAGG_DISTINCT);
 
         // SQL Aggregate Functions
 
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarArrayAggTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarArrayAggTypeComputer.java
new file mode 100644
index 0000000..cd713ed
--- /dev/null
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarArrayAggTypeComputer.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.exceptions.TypeMismatchException;
+import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import 
org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import 
org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class ScalarArrayAggTypeComputer implements IResultTypeComputer {
+
+    public static final IResultTypeComputer INSTANCE = new 
ScalarArrayAggTypeComputer();
+
+    private ScalarArrayAggTypeComputer() {
+    }
+
+    @Override
+    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
+        AbstractFunctionCallExpression fun = (AbstractFunctionCallExpression) 
expression;
+        IAType argType = (IAType) 
env.getType(fun.getArguments().get(0).getValue());
+        IAType itemType = TypeComputeUtils.extractListItemType(argType);
+        if (itemType == null) {
+            throw new TypeMismatchException(fun.getSourceLocation(), 
fun.getFunctionIdentifier(), 0,
+                    argType.getTypeTag(), ATypeTag.MULTISET, ATypeTag.ARRAY);
+        }
+        return new AOrderedListType(itemType, null);
+    }
+}
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
index 4330767..94fb998 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
@@ -25,6 +25,7 @@ import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AUnionType;
+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.utils.RecordUtil;
@@ -237,6 +238,18 @@ public class TypeComputeUtils {
         return null;
     }
 
+    public static IAType extractListItemType(IAType t) {
+        IAType primeType = getActualType(t);
+        ATypeTag primeTypeTag = primeType.getTypeTag();
+        if (primeTypeTag.isListType()) {
+            return ((AbstractCollectionType) primeType).getItemType();
+        } else if (primeTypeTag == ATypeTag.ANY) {
+            return primeType;
+        } else {
+            return null;
+        }
+    }
+
     // this is for complex types. it will return null when asking for a 
default type for a primitive tag
     public static IAType getActualTypeOrOpen(IAType type, ATypeTag tag) {
         IAType actualType = TypeComputeUtils.getActualType(type);
diff --git 
a/asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
 
b/asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
index bd77580..5f5af65 100644
--- 
a/asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
+++ 
b/asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
@@ -100,6 +100,7 @@ public class TypeComputerTest {
         exceptionalTypeComputers.add("RecordMergeTypeComputer");
         exceptionalTypeComputers.add("BooleanOrMissingTypeComputer");
         exceptionalTypeComputers.add("LocalSingleVarStatisticsTypeComputer");
+        exceptionalTypeComputers.add("ScalarArrayAggTypeComputer");
 
         // Tests all usual type computers.
         Reflections reflections = new 
Reflections("org.apache.asterix.om.typecomputer", new SubTypesScanner(false));
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/AbstractScalarAggregateDescriptor.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/AbstractScalarAggregateDescriptor.java
index 2a311fb..a220e67 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/AbstractScalarAggregateDescriptor.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/AbstractScalarAggregateDescriptor.java
@@ -19,6 +19,9 @@
 package org.apache.asterix.runtime.aggregates.scalar;
 
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
 import 
org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
 import 
org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import 
org.apache.asterix.runtime.unnestingfunctions.std.ScanCollectionDescriptor.ScanCollectionUnnestingFunctionFactory;
@@ -77,4 +80,9 @@ public abstract class AbstractScalarAggregateDescriptor 
extends AbstractScalarFu
             throws HyracksDataException {
         return new GenericScalarAggregateFunction(aggEval, 
scanCollectionFactory, ctx, sourceLoc);
     }
+
+    static IAType getItemType(IAType listType) {
+        IAType itemType = TypeComputeUtils.extractListItemType(listType);
+        return itemType != null ? itemType : BuiltinType.ANY;
+    }
 }
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 23c4e89..2059a2b 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
@@ -19,9 +19,14 @@
 
 package org.apache.asterix.runtime.aggregates.scalar;
 
+import java.util.function.Supplier;
+
+import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
 import 
org.apache.asterix.runtime.unnestingfunctions.std.ScanCollectionDescriptor;
+import org.apache.asterix.runtime.utils.DescriptorFactoryUtil;
 import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -30,7 +35,7 @@ import org.apache.hyracks.api.exceptions.HyracksDataException;
 public abstract class AbstractScalarDistinctAggregateDescriptor extends 
AbstractScalarAggregateDescriptor {
 
     private static final long serialVersionUID = 1L;
-    private IAType aggFieldType;
+    protected IAType itemType;
 
     public 
AbstractScalarDistinctAggregateDescriptor(IFunctionDescriptorFactory 
aggFuncDescFactory) {
         super(aggFuncDescFactory);
@@ -38,13 +43,17 @@ public abstract class 
AbstractScalarDistinctAggregateDescriptor extends Abstract
 
     @Override
     public void setImmutableStates(Object... states) {
-        aggFieldType = (IAType) states[0];
+        itemType = getItemType((IAType) states[0]);
     }
 
     @Override
     protected IScalarEvaluator 
createScalarAggregateEvaluator(IAggregateEvaluator aggEval,
             ScanCollectionDescriptor.ScanCollectionUnnestingFunctionFactory 
scanCollectionFactory,
             IHyracksTaskContext ctx) throws HyracksDataException {
-        return new GenericScalarDistinctAggregateFunction(aggEval, 
scanCollectionFactory, ctx, sourceLoc, aggFieldType);
+        return new GenericScalarDistinctAggregateFunction(aggEval, 
scanCollectionFactory, ctx, sourceLoc, itemType);
+    }
+
+    public static IFunctionDescriptorFactory 
createDescriptorFactory(Supplier<IFunctionDescriptor> descriptorSupplier) {
+        return DescriptorFactoryUtil.createFactory(descriptorSupplier, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
     }
 }
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/ScalarArrayAggAggregateDescriptor.java
similarity index 62%
copy from 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarCountDistinctAggregateDescriptor.java
copy to 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarArrayAggAggregateDescriptor.java
index cabd3fe..8d99d4d 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/ScalarArrayAggAggregateDescriptor.java
@@ -21,26 +21,34 @@ package org.apache.asterix.runtime.aggregates.scalar;
 
 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.om.types.AOrderedListType;
+import org.apache.asterix.om.types.IAType;
+import 
org.apache.asterix.runtime.aggregates.collections.ListifyAggregateDescriptor;
 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 {
+public final class ScalarArrayAggAggregateDescriptor extends 
AbstractScalarAggregateDescriptor {
 
     private static final long serialVersionUID = 1L;
 
-    public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_COUNT_DISTINCT;
-
     public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarCountDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+            .createFactory(ScalarArrayAggAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+
+    private ScalarArrayAggAggregateDescriptor() {
+        super(ListifyAggregateDescriptor.FACTORY);
+    }
 
-    private ScalarCountDistinctAggregateDescriptor() {
-        super(CountAggregateDescriptor.FACTORY);
+    @Override
+    public void setImmutableStates(Object... states) {
+        super.setImmutableStates(states);
+        // listify() needs an ordered list type for its output
+        IAType itemType = getItemType((IAType) states[0]);
+        aggFuncDesc.setImmutableStates(new AOrderedListType(itemType, null));
     }
 
     @Override
     public FunctionIdentifier getIdentifier() {
-        return FID;
+        return BuiltinFunctions.SCALAR_ARRAYAGG;
     }
 }
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/ScalarArrayAggDistinctAggregateDescriptor.java
similarity index 59%
copy from 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarCountDistinctAggregateDescriptor.java
copy to 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarArrayAggDistinctAggregateDescriptor.java
index cabd3fe..ec7c547 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/ScalarArrayAggDistinctAggregateDescriptor.java
@@ -21,26 +21,30 @@ package org.apache.asterix.runtime.aggregates.scalar;
 
 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.asterix.om.types.AOrderedListType;
+import 
org.apache.asterix.runtime.aggregates.collections.ListifyAggregateDescriptor;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 
-public class ScalarCountDistinctAggregateDescriptor extends 
AbstractScalarDistinctAggregateDescriptor {
+public final class ScalarArrayAggDistinctAggregateDescriptor extends 
AbstractScalarDistinctAggregateDescriptor {
 
     private static final long serialVersionUID = 1L;
 
-    public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_COUNT_DISTINCT;
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarArrayAggDistinctAggregateDescriptor::new);
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarCountDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    private ScalarArrayAggDistinctAggregateDescriptor() {
+        super(ListifyAggregateDescriptor.FACTORY);
+    }
 
-    private ScalarCountDistinctAggregateDescriptor() {
-        super(CountAggregateDescriptor.FACTORY);
+    @Override
+    public void setImmutableStates(Object... states) {
+        super.setImmutableStates(states);
+        // listify() needs an ordered list type for its output
+        aggFuncDesc.setImmutableStates(new AOrderedListType(itemType, null));
     }
 
     @Override
     public FunctionIdentifier getIdentifier() {
-        return FID;
+        return BuiltinFunctions.SCALAR_ARRAYAGG_DISTINCT;
     }
 }
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 81ba967..8a3dd11 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarAvgDistinctAggregateDescriptor extends 
AbstractScalarDistinct
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_AVG_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarAvgDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            createDescriptorFactory(ScalarAvgDistinctAggregateDescriptor::new);
 
     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 cabd3fe..667c244 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarCountDistinctAggregateDescriptor extends 
AbstractScalarDistin
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_COUNT_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarCountDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarCountDistinctAggregateDescriptor::new);
 
     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 c7cfcdd..0c18957 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarKurtosisDistinctAggregateDescriptor 
extends AbstractScalarDis
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_KURTOSIS_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarKurtosisDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarKurtosisDistinctAggregateDescriptor::new);
 
     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 702da0b..77b462b 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarMaxDistinctAggregateDescriptor extends 
AbstractScalarDistinct
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_MAX_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarMaxDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            createDescriptorFactory(ScalarMaxDistinctAggregateDescriptor::new);
 
     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 1c193c8..2affa37 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarMinDistinctAggregateDescriptor extends 
AbstractScalarDistinct
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_MIN_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarMinDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            createDescriptorFactory(ScalarMinDistinctAggregateDescriptor::new);
 
     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 4f96b9b..f80f8d2 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSkewnessDistinctAggregateDescriptor 
extends AbstractScalarDis
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SKEWNESS_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSkewnessDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSkewnessDistinctAggregateDescriptor::new);
 
     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 726a18e..8f1251f 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlAvgDistinctAggregateDescriptor extends 
AbstractScalarDisti
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_AVG_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlAvgDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlAvgDistinctAggregateDescriptor::new);
 
     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 417f698..6095cc7 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlCountDistinctAggregateDescriptor 
extends AbstractScalarDis
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_COUNT_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlCountDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlCountDistinctAggregateDescriptor::new);
 
     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 dbe3d26..07af039 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlKurtosisDistinctAggregateDescriptor 
extends AbstractScalar
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_KURTOSIS_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlKurtosisDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlKurtosisDistinctAggregateDescriptor::new);
 
     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 bb772c6..3f73592 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlMaxDistinctAggregateDescriptor extends 
AbstractScalarDisti
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_MAX_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlMaxDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlMaxDistinctAggregateDescriptor::new);
 
     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 6a8413b..25d69c3 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlMinDistinctAggregateDescriptor extends 
AbstractScalarDisti
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_MIN_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlMinDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlMinDistinctAggregateDescriptor::new);
 
     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 ff9ce3f..459b203 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlStddevDistinctAggregateDescriptor 
extends AbstractScalarDi
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_STDDEV_SAMP_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlStddevDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlStddevDistinctAggregateDescriptor::new);
 
     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 359c037..5e8b2a2 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlStddevPopDistinctAggregateDescriptor 
extends AbstractScala
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_STDDEV_POP_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlStddevPopDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlStddevPopDistinctAggregateDescriptor::new);
 
     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 2df817c..fb55cf7 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlSumDistinctAggregateDescriptor extends 
AbstractScalarDisti
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_SUM_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlSumDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlSumDistinctAggregateDescriptor::new);
 
     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 0f4ea43..948e161 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlVarDistinctAggregateDescriptor extends 
AbstractScalarDisti
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_VAR_SAMP_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlVarDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlVarDistinctAggregateDescriptor::new);
 
     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 f1e1fbb..8dbb0a4 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSqlVarPopDistinctAggregateDescriptor 
extends AbstractScalarDi
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SQL_VAR_POP_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSqlVarPopDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarSqlVarPopDistinctAggregateDescriptor::new);
 
     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 1253f7c..1352bf1 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarStddevDistinctAggregateDescriptor extends 
AbstractScalarDisti
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_STDDEV_SAMP_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarStddevDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarStddevDistinctAggregateDescriptor::new);
 
     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 5a91482..97bc0e2 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarStddevPopDistinctAggregateDescriptor 
extends AbstractScalarDi
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_STDDEV_POP_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarStddevPopDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarStddevPopDistinctAggregateDescriptor::new);
 
     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 04b8547..fa15e54 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarSumDistinctAggregateDescriptor extends 
AbstractScalarDistinct
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_SUM_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarSumDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            createDescriptorFactory(ScalarSumDistinctAggregateDescriptor::new);
 
     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 a414580..7466e44 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarVarDistinctAggregateDescriptor extends 
AbstractScalarDistinct
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_VAR_SAMP_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarVarDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            createDescriptorFactory(ScalarVarDistinctAggregateDescriptor::new);
 
     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 c71a976..9d8a400 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,8 +22,6 @@ package org.apache.asterix.runtime.aggregates.scalar;
 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 {
@@ -32,8 +30,8 @@ public class ScalarVarPopDistinctAggregateDescriptor extends 
AbstractScalarDisti
 
     public static final FunctionIdentifier FID = 
BuiltinFunctions.SCALAR_VAR_POP_DISTINCT;
 
-    public static final IFunctionDescriptorFactory FACTORY = 
DescriptorFactoryUtil
-            .createFactory(ScalarVarPopDistinctAggregateDescriptor::new, 
FunctionTypeInferers.SET_ARGUMENT_TYPE);
+    public static final IFunctionDescriptorFactory FACTORY =
+            
createDescriptorFactory(ScalarVarPopDistinctAggregateDescriptor::new);
 
     private ScalarVarPopDistinctAggregateDescriptor() {
         super(VarPopAggregateDescriptor.FACTORY);
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
index 6269582..2aed755 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
@@ -33,6 +33,8 @@ import 
org.apache.asterix.runtime.aggregates.collections.LastElementAggregateDes
 import 
org.apache.asterix.runtime.aggregates.collections.ListifyAggregateDescriptor;
 import 
org.apache.asterix.runtime.aggregates.collections.LocalFirstElementAggregateDescriptor;
 import 
org.apache.asterix.runtime.aggregates.collections.NullWriterAggregateDescriptor;
+import 
org.apache.asterix.runtime.aggregates.scalar.ScalarArrayAggAggregateDescriptor;
+import 
org.apache.asterix.runtime.aggregates.scalar.ScalarArrayAggDistinctAggregateDescriptor;
 import 
org.apache.asterix.runtime.aggregates.scalar.ScalarAvgAggregateDescriptor;
 import 
org.apache.asterix.runtime.aggregates.scalar.ScalarAvgDistinctAggregateDescriptor;
 import 
org.apache.asterix.runtime.aggregates.scalar.ScalarCountAggregateDescriptor;
@@ -663,6 +665,8 @@ public final class FunctionCollection implements 
IFunctionCollection {
         fc.add(SerializableGlobalSkewnessAggregateDescriptor.FACTORY);
 
         // scalar aggregates
+        fc.add(ScalarArrayAggAggregateDescriptor.FACTORY);
+        fc.add(ScalarArrayAggDistinctAggregateDescriptor.FACTORY);
         fc.add(ScalarCountAggregateDescriptor.FACTORY);
         fc.add(ScalarCountDistinctAggregateDescriptor.FACTORY);
         fc.add(ScalarAvgAggregateDescriptor.FACTORY);

Reply via email to