You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Victoria Markman (JIRA)" <ji...@apache.org> on 2015/02/11 20:09:11 UTC

[jira] [Created] (DRILL-2214) Aggregate function documentation needs to be corrected

Victoria Markman created DRILL-2214:
---------------------------------------

             Summary: Aggregate function documentation needs to be corrected
                 Key: DRILL-2214
                 URL: https://issues.apache.org/jira/browse/DRILL-2214
             Project: Apache Drill
          Issue Type: Bug
          Components: Documentation
    Affects Versions: 0.8.0
            Reporter: Victoria Markman
            Assignee: Bridget Bevens


It turns out that all of our basic aggregate functions (MIN, MAX, COUNT, AVG, SUM) accept ALL and DISTINCT keywords.
If none specified, ALL is the default.

For example,
{code}
0: jdbc:drill:schema=dfs> select a2 from t2;
+------------+
|     a2     |
+------------+
| 0          |
| 1          |
| 2          |
| 2          |
| 2          |
| 3          |
| 4          |
| 5          |
| 6          |
| 7          |
| 7          |
| 8          |
| 9          |
+------------+
13 rows selected (0.056 seconds)

0: jdbc:drill:schema=dfs> select avg(all a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 4.3076923076923075 |
+------------+
1 row selected (0.084 seconds)

0: jdbc:drill:schema=dfs> select avg(distinct a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 4.5        |
+------------+
1 row selected (0.079 seconds)

0: jdbc:drill:schema=dfs> select sum(all a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 56         |
+------------+
1 row selected (0.086 seconds)
0: jdbc:drill:schema=dfs> select sum(distinct a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 45         |
+------------+
1 row selected (0.078 seconds)

+------------+
|   EXPR$0   |
+------------+
| 13         |
+------------+
1 row selected (0.056 seconds)

0: jdbc:drill:schema=dfs> select count(all a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 13         |
+------------+
1 row selected (0.056 seconds)

0: jdbc:drill:schema=dfs> select count(distinct a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 10         |
+------------+
1 row selected (0.074 seconds)
{code}

Including MIN/MAX:
{code}

0: jdbc:drill:schema=dfs> select min(distinct a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 0          |
+------------+
1 row selected (0.095 seconds)

0: jdbc:drill:schema=dfs> select min(all a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 0          |
+------------+
1 row selected (0.065 seconds)
0: jdbc:drill:schema=dfs> select max(all a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 9          |
+------------+
1 row selected (0.094 seconds)

0: jdbc:drill:schema=dfs> select max(distinct a2) from t2;
+------------+
|   EXPR$0   |
+------------+
| 9          |
+------------+
1 row selected (0.067 seconds)
{code}

I don't know if we should mention MIN/MAX, but SUM and AVG we should.





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)