asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dl...@apache.org
Subject asterixdb git commit: [NO ISSUE][COMP][DOC] Distinct aggregates cleanup, documentation
Date Mon, 30 Oct 2017 19:27:51 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 9e8f3bfa3 -> 5bd23630c


[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>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/5bd23630
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/5bd23630
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/5bd23630

Branch: refs/heads/master
Commit: 5bd23630c4ccbd443fae5744e7826acee6bb199e
Parents: 9e8f3bf
Author: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
Authored: Fri Oct 20 14:16:32 2017 -0700
Committer: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
Committed: Mon Oct 30 12:27:17 2017 -0700

----------------------------------------------------------------------
 .../asterix-doc/src/main/markdown/sqlpp/3_query.md     | 13 +++++++++++++
 .../visitor/SqlppDistinctAggregationSugarVisitor.java  |  8 +++++---
 2 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5bd23630/asterixdb/asterix-doc/src/main/markdown/sqlpp/3_query.md
----------------------------------------------------------------------
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 @@ Notice how the query forms groups where each group involves a message
author and
 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 @@ The same sort of rewritings apply to the function symbols `SUM`, `MAX`,
`MIN`, a
 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:

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5bd23630/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppDistinctAggregationSugarVisitor.java
----------------------------------------------------------------------
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.SelectElement;
 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 @@ import org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo;
  * {@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


Mime
View raw message