guojingfeng has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/17781


Change subject: IMPALA-10865: Fix initialize SelectStmt's groupingExprs_ in 
analyzeGroupingExprs
......................................................................

IMPALA-10865: Fix initialize SelectStmt's groupingExprs_ in analyzeGroupingExprs

This patch rollback some changes of IMPALA-9620 which initialize
SelectStmt's groupingExprs_ to ensure that group-by and cnf exprs are
analyzed. Since i noticed that IMPALA-9693 explicit analyze exprs
which is not analyzed yet. So this rollback is safe here.

Another reason why this patch is submitted is that re-initialize
SelectStmt's groupingExprs_ will cause other problems. IMPALA-10096 is
a typical case.

Here is a reproduce case that is similar to IMPALA-10096:
```
EXPLAIN
SELECT ss_item_sk ss_item_sk_group,
       ss_item_sk+300 ss_item_sk,
       count(ss_ticket_number)
FROM store_sales a
WHERE ss_sold_date_sk > cast('245263' AS INT)
GROUP BY ss_item_sk_group,
         ss_item_sk;
```
1. Expr cast('245263' AS INT) will hit expr rewrite logic
2. GroupBy exprs will substitude to SlotRef or FunctionCallExpr
3. ReAnalyze phase repeate step above

The problem is that if we change the groupingExprs_ of SelectStmt,
in re-analyze phase ss_item_sk alias ss_item_sk_group will be
substitude to Expr that duplicate with ss_item_sk which will be
removed in `buildAggregateExprs`. AnalyzeException
"select list expression not produced by aggregation output
(missing from GROUP BY clause?): ss_item_sk ss_item_sk_group" will
threw to client side.

This patch just remove the re-initialize groupingExprs_ of SelectStmt.

As a side effect, this patch modify ExtractCompundVerticalBarExprRule
to do a explicit analyze to ensure expr are rewritted.

Test:
- Add new test into aggregation.test and passed
- Ran all fe tests and passed

Change-Id: I9d1779e6c282d9fd02beacf5ddfafcc5c0baf3b0
---
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M 
fe/src/main/java/org/apache/impala/rewrite/ExtractCompoundVerticalBarExprRule.java
M testdata/workloads/functional-planner/queries/PlannerTest/aggregation.test
3 files changed, 26 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/81/17781/2
--
To view, visit http://gerrit.cloudera.org:8080/17781
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d1779e6c282d9fd02beacf5ddfafcc5c0baf3b0
Gerrit-Change-Number: 17781
Gerrit-PatchSet: 2
Gerrit-Owner: guojingfeng <guojingf...@tencent.com>

Reply via email to