You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jp...@apache.org on 2015/05/18 22:19:03 UTC
hive git commit: HIVE-10686: CBO -
java.lang.IndexOutOfBoundsException for query with rank() over(partition ...)
(Jesus Camacho Rodriguez via Laljo John Pullokkaran)
Repository: hive
Updated Branches:
refs/heads/master 5818a4a20 -> 129c496bd
HIVE-10686: CBO - java.lang.IndexOutOfBoundsException for query with rank() over(partition ...) (Jesus Camacho Rodriguez via Laljo John Pullokkaran)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/129c496b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/129c496b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/129c496b
Branch: refs/heads/master
Commit: 129c496bdf0f16a16e82d6978187319781c16e3d
Parents: 5818a4a
Author: jpullokk <jp...@apache.org>
Authored: Mon May 18 13:17:19 2015 -0700
Committer: jpullokk <jp...@apache.org>
Committed: Mon May 18 13:18:51 2015 -0700
----------------------------------------------------------------------
.../calcite/translator/PlanModifierUtil.java | 47 +++++++++++++-------
1 file changed, 30 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/129c496b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierUtil.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierUtil.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierUtil.java
index 2c820f0..3e2fae9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierUtil.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierUtil.java
@@ -68,23 +68,9 @@ public class PlanModifierUtil {
if (collationInputRefs.contains(i)) {
RexNode obyExpr = obChild.getChildExps().get(i);
if (obyExpr instanceof RexCall) {
- int a = -1;
- List<RexNode> operands = new ArrayList<>();
- for (int k = 0; k< ((RexCall) obyExpr).operands.size(); k++) {
- RexNode rn = ((RexCall) obyExpr).operands.get(k);
- for (int j = 0; j < resultSchema.size(); j++) {
- if( obChild.getChildExps().get(j).toString().equals(rn.toString())) {
- a = j;
- break;
- }
- } if (a != -1) {
- operands.add(new RexInputRef(a, rn.getType()));
- } else {
- operands.add(rn);
- }
- a = -1;
- }
- obyExpr = obChild.getCluster().getRexBuilder().makeCall(((RexCall)obyExpr).getOperator(), operands);
+ LOG.debug("Old RexCall : " + obyExpr);
+ obyExpr = adjustOBSchema((RexCall) obyExpr, obChild, resultSchema);
+ LOG.debug("New RexCall : " + obyExpr);
}
inputRefToCallMapBldr.put(i, obyExpr);
}
@@ -106,6 +92,33 @@ public class PlanModifierUtil {
obRel.setInputRefToCallMap(inputRefToCallMap);
}
+ private static RexCall adjustOBSchema(RexCall obyExpr, Project obChild,
+ List<FieldSchema> resultSchema) {
+ int a = -1;
+ List<RexNode> operands = new ArrayList<>();
+ for (int k = 0; k < obyExpr.operands.size(); k++) {
+ RexNode rn = obyExpr.operands.get(k);
+ for (int j = 0; j < resultSchema.size(); j++) {
+ if( obChild.getChildExps().get(j).toString().equals(rn.toString())) {
+ a = j;
+ break;
+ }
+ }
+ if (a != -1) {
+ operands.add(new RexInputRef(a, rn.getType()));
+ } else {
+ if (rn instanceof RexCall) {
+ operands.add(adjustOBSchema((RexCall)rn, obChild, resultSchema));
+ } else {
+ operands.add(rn);
+ }
+ }
+ a = -1;
+ }
+ return (RexCall) obChild.getCluster().getRexBuilder().makeCall(
+ obyExpr.getType(), obyExpr.getOperator(), operands);
+ }
+
protected static String generateInvalidSchemaMessage(Project topLevelProj,
List<FieldSchema> resultSchema, int fieldsForOB) {
String errorDesc = "Result Schema didn't match Calcite Optimized Op Tree; schema: ";