[ 
https://issues.apache.org/jira/browse/HIVE-16924?focusedWorklogId=203717&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-203717
 ]

ASF GitHub Bot logged work on HIVE-16924:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 25/Feb/19 15:31
            Start Date: 25/Feb/19 15:31
    Worklog Time Spent: 10m 
      Work Description: kgyrtkirk commented on pull request #544: HIVE-16924 
Support distinct in presence of Group By
URL: https://github.com/apache/hive/pull/544#discussion_r259878502
 
 

 ##########
 File path: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
 ##########
 @@ -4230,6 +4229,34 @@ public static long unsetBit(long bitmap, int bitIdx) {
     }
   }
 
+  protected boolean isGroupBy(ASTNode expr) {
+    boolean isGroupBy = false;
+    if (expr.getParent() != null && expr.getParent() instanceof Node)
+    for (Node sibling : ((Node)expr.getParent()).getChildren()) {
+      isGroupBy |= sibling instanceof ASTNode && ((ASTNode)sibling).getType() 
== HiveParser.TOK_GROUPBY;
+    }
+
+    return isGroupBy;
+  }
+
+  protected boolean isSelectDistinct(ASTNode expr) {
+    return expr.getType() == HiveParser.TOK_SELECTDI;
+  }
+
+  protected boolean isAggregateInSelect(Node node, Collection<ASTNode> 
aggregateFunction) {
+    if (node.getChildren() == null) {
+      return false;
+    }
+
+    for (Node child : node.getChildren()) {
 
 Review comment:
   I was thinking something really odd:
   ```
   select distinct (select count(*) from t where t.a=e.a) from e
   ```
   but in this case (beyond that it might not accept by hive at all) the count 
aggregate is not present at the top level.
   Do you know an example when this method returns false; however there are 
aggreagations being done?
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 203717)
    Time Spent: 2.5h  (was: 2h 20m)

> Support distinct in presence of Group By 
> -----------------------------------------
>
>                 Key: HIVE-16924
>                 URL: https://issues.apache.org/jira/browse/HIVE-16924
>             Project: Hive
>          Issue Type: New Feature
>          Components: Query Planning
>            Reporter: Carter Shanklin
>            Assignee: Miklos Gergely
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-16924.01.patch, HIVE-16924.02.patch, 
> HIVE-16924.03.patch, HIVE-16924.04.patch, HIVE-16924.05.patch, 
> HIVE-16924.06.patch, HIVE-16924.07.patch, HIVE-16924.08.patch
>
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> {code:sql}
> create table e011_01 (c1 int, c2 smallint);
> insert into e011_01 values (1, 1), (2, 2);
> {code}
> These queries should work:
> {code:sql}
> select distinct c1, count(*) from e011_01 group by c1;
> select distinct c1, avg(c2) from e011_01 group by c1;
> {code}
> Currently, you get : 
> FAILED: SemanticException 1:52 SELECT DISTINCT and GROUP BY can not be in the 
> same query. Error encountered near token 'c1'



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to