Quanlong Huang has submitted this change and it was merged. ( 
http://gerrit.cloudera.org:8080/19422 )

Change subject: IMPALA-11843: Fix IndexOutOfBoundsException in analytic limit 
pushdown
......................................................................

IMPALA-11843: Fix IndexOutOfBoundsException in analytic limit pushdown

When finding analytic conjuncts for analytic limit pushdown, the
following conditions are checked:
 - The conjunct should be a binary predicate
 - Left hand side is a SlotRef referencing the analytic expression, e.g.
   "rn" of "row_number() as rn"
 - The underlying analytic function is rank(), dense_rank() or row_number()
 - The window frame is UNBOUNDED PRECEDING to CURRENT ROW
 - Right hand side is a valid numeric limit
 - The op is =, <, or <=
See more details in AnalyticPlanner.inferPartitionLimits().

While checking the 2nd and 3rd condition, we get the source exprs of the
SlotRef. The source exprs could be empty if the SlotRef is actually
referencing a column of the table, i.e. a column materialized by the
scan node. Currently, we check the first source expr directly regardless
whether the list is empty, which causes the IndexOutOfBoundsException.

This patch fixes it by augmenting the check to consider an empty list.
Also fixes a similar code in AnalyticEvalNode.

Tests:
 - Add FE and e2e regression tests

Change-Id: I26d6bd58be58d09a29b8b81972e76665f41cf103
Reviewed-on: http://gerrit.cloudera.org:8080/19422
Reviewed-by: Aman Sinha <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
M fe/src/main/java/org/apache/impala/planner/AnalyticEvalNode.java
M fe/src/main/java/org/apache/impala/planner/AnalyticPlanner.java
M 
testdata/workloads/functional-planner/queries/PlannerTest/limit-pushdown-partitioned-top-n.test
M testdata/workloads/functional-query/queries/QueryTest/partitioned-top-n.test
4 files changed, 46 insertions(+), 2 deletions(-)

Approvals:
  Aman Sinha: Looks good to me, approved
  Impala Public Jenkins: Verified

--
To view, visit http://gerrit.cloudera.org:8080/19422
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I26d6bd58be58d09a29b8b81972e76665f41cf103
Gerrit-Change-Number: 19422
Gerrit-PatchSet: 2
Gerrit-Owner: Quanlong Huang <[email protected]>
Gerrit-Reviewer: Aman Sinha <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Quanlong Huang <[email protected]>

Reply via email to