[NO ISSUE][COMP][DOC] Distinct aggregates cleanup, documentation

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

Details:
- changed SqlppDistinctAggregationSugarVisitor superclass to
  AbstractSqlppSimpleExpressionVisitor
- Added documentation for distinct aggregates

Change-Id: I3f974a0c1adb7eca492a6011401cc54fea74cd8e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2086
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Xikui Wang <xkkwww@gmail.com>
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 5d94ea4..bcf3094 100644
--- a/asterixdb/asterix-doc/src/main/markdown/sqlpp/3_query.md
+++ b/asterixdb/asterix-doc/src/main/markdown/sqlpp/3_query.md
@@ -1128,6 +1128,17 @@
 The query then uses the collection aggregate function ARRAY_COUNT to get the cardinality of each
 group of messages.
 
+Each aggregation function in SQL++ supports DISTINCT modifier that removes duplicate values from
+the input collection.
+
+##### Example
+
+    ARRAY_SUM(DISTINCT [1, 1, 2, 2, 3])
+
+This query returns:
+
+    6
+
 ### <a id="SQL-92_aggregation_functions">SQL-92 Aggregation Functions</a>
 For compatibility with the traditional SQL aggregation functions, SQL++ also offers SQL-92's
 aggregation function symbols (`COUNT`, `SUM`, `MAX`, `MIN`, and `AVG`) as supported syntactic sugar.
@@ -1155,6 +1166,8 @@
 In contrast to the SQL++ collection aggregate functions, 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.
+
 ### <a id="SQL-92_compliant_gby">SQL-92 Compliant GROUP BY Aggregations</a>
 SQL++ provides full support for SQL-92 `GROUP BY` aggregation queries.
 The following query is such an example:
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
index e9b8334..c56bb9d 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
@@ -39,7 +39,7 @@
 import org.apache.asterix.lang.sqlpp.clause.SelectSetOperation;
 import org.apache.asterix.lang.sqlpp.expression.SelectExpression;
 import org.apache.asterix.lang.sqlpp.struct.SetOperationInput;
-import org.apache.asterix.lang.sqlpp.visitor.base.AbstractSqlppExpressionScopingVisitor;
+import org.apache.asterix.lang.sqlpp.visitor.base.AbstractSqlppSimpleExpressionVisitor;
 import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo;
@@ -49,9 +49,11 @@
  * {@code agg-distinct(expr) -> agg((FROM expr AS i SELECT DISTINCT VALUE i))} <br/>
  * where {@code agg-distinct} is a distinct aggregate function, {@code agg} - a regular aggregate function
  */
-public class SqlppDistinctAggregationSugarVisitor extends AbstractSqlppExpressionScopingVisitor {
+public class SqlppDistinctAggregationSugarVisitor extends AbstractSqlppSimpleExpressionVisitor {
+    protected final LangRewritingContext context;
+
     public SqlppDistinctAggregationSugarVisitor(LangRewritingContext context) {
-        super(context);
+        this.context = context;
     }
 
     @Override