[
https://issues.apache.org/jira/browse/HIVE-16924?focusedWorklogId=203604&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-203604
]
ASF GitHub Bot logged work on HIVE-16924:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 25/Feb/19 12:04
Start Date: 25/Feb/19 12:04
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_r259763434
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
##########
@@ -3730,7 +3697,9 @@ private RelNode genGBLogicalPlan(QB qb, RelNode srcRel)
throws SemanticException
ASTNode node = (ASTNode) selExprList.getChild(0).getChild(0);
if (node.getToken().getType() == HiveParser.TOK_ALLCOLREF) {
// As we said before, here we use genSelectLogicalPlan to rewrite
AllColRef
- srcRel = genSelectLogicalPlan(qb, srcRel, srcRel, null, null,
true).getKey();
+ if (!(isSelectDistinct(selExprList) && isGroupBy(selExprList))) {
Review comment:
`isSelectDistinct(selExprList)` is always true here; condition could be
changed to `!isGroupBy`
I'm not sure if I understand why we would "skip" rewrite `TOK_ALLCOLREF` in
case it's not in groupby; I don't think the below statements make sense:
```
create table t (c1 integer,c2 integer);
select distinct * from t group by c1;
```
I might be missing something here..
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 203604)
Time Spent: 40m (was: 0.5h)
> 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: 40m
> 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)