Hello Vincent Tran, Tim Armstrong,

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/10605

to look at the new patch set (#3).

Change subject: IMPALA-7108: IllegalStateException hit during 
CardinalityCheckNode.<init>
......................................................................

IMPALA-7108: IllegalStateException hit during CardinalityCheckNode.<init>

Since IMPALA-6314 on runtime scalar subqueries we set LIMIT 2
in StmtRewriter.mergeExpr(). We do that because later we add a
CardinalityCheckNode on top of such subqueries and with
LIMIT 2 we can still check if they return more than one row.

In the constructor of CardinalityCheckNode there is a
precondition that checks if the child node has LIMIT 2 to
be certain that we've set the limit for all the necessary
cases.

However, some subqueries will get a LIMIT 1 later breaking the
precondition in CardinalityCheckNode. An example to these
subqueries is a select stmt that selects from an inline view
that returns a single row:

select * from functional.alltypes
where int_col = (select f.id from (
                 select * from functional.alltypes limit 1) f);

Note that we shouldn't add a CardinalityCheckNode to the plan
of this query in the first place. To generate a proper plan I
updated SelectStmt.returnsSingleRow() because this method didn't
handle this case well.

I also changed
the precondition from
Preconditions.checkState(child.getLimit() == 2);
to
Preconditions.checkState(child.getLimit() <= 2);
in order to be more permissive.

I added tests for the aforementioned query.

Change-Id: I82a7a3fe26db3e12131c030c4ad055a9c4955407
---
M fe/src/main/java/org/apache/impala/analysis/SelectStmt.java
M fe/src/main/java/org/apache/impala/planner/CardinalityCheckNode.java
M 
testdata/workloads/functional-planner/queries/PlannerTest/subquery-rewrite.test
M testdata/workloads/functional-query/queries/QueryTest/subquery.test
4 files changed, 66 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/05/10605/3
--
To view, visit http://gerrit.cloudera.org:8080/10605
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I82a7a3fe26db3e12131c030c4ad055a9c4955407
Gerrit-Change-Number: 10605
Gerrit-PatchSet: 3
Gerrit-Owner: Zoltan Borok-Nagy <borokna...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <tarmstr...@cloudera.com>
Gerrit-Reviewer: Vincent Tran <vtt...@cloudera.com>
Gerrit-Reviewer: Zoltan Borok-Nagy <borokna...@cloudera.com>

Reply via email to