You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2016/05/04 09:56:00 UTC
hive git commit: HIVE-13677:
org.apache.hive.com.esotericsoftware.kryo.KryoException:
java.lang.NullPointerException when folding CASE expression (Jesus Camacho
Rodriguez, reviewed by Prasanth Jayachandran)
Repository: hive
Updated Branches:
refs/heads/branch-1 91c83f39d -> ad1ceb861
HIVE-13677: org.apache.hive.com.esotericsoftware.kryo.KryoException: java.lang.NullPointerException when folding CASE expression (Jesus Camacho Rodriguez, reviewed by Prasanth Jayachandran)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/ad1ceb86
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ad1ceb86
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ad1ceb86
Branch: refs/heads/branch-1
Commit: ad1ceb861def8505001bc0daedf2c1e4673848f8
Parents: 91c83f3
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Wed May 4 10:54:40 2016 +0100
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Wed May 4 10:55:46 2016 +0100
----------------------------------------------------------------------
.../optimizer/ConstantPropagateProcFactory.java | 19 +++++---
ql/src/test/queries/clientpositive/fold_case2.q | 13 ++++++
.../results/clientpositive/fold_case2.q.out | 46 ++++++++++++++++++++
3 files changed, 71 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/ad1ceb86/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java
index 70cdc95..064e304 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java
@@ -577,7 +577,7 @@ public final class ConstantPropagateProcFactory {
} else if (op instanceof FilterOperator) {
// we can still fold, since here null is equivalent to false.
return Boolean.TRUE.equals(elseVal) ?
- ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNot(), newExprs.subList(0, 1)) : Boolean.FALSE.equals(elseVal) ?
+ ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNot(), Lists.newArrayList(whenExpr)) : Boolean.FALSE.equals(elseVal) ?
elseExpr : null;
} else {
// can't do much, expression is not in context of filter, so we can't treat null as equivalent to false here.
@@ -589,7 +589,7 @@ public final class ConstantPropagateProcFactory {
return thenExpr;
} else if (thenVal instanceof Boolean && elseVal instanceof Boolean) {
return Boolean.TRUE.equals(thenVal) ? whenExpr :
- ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNot(), newExprs.subList(0, 1));
+ ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNot(), Lists.newArrayList(whenExpr));
} else {
return null;
}
@@ -617,19 +617,24 @@ public final class ConstantPropagateProcFactory {
if (null == elseVal) {
return thenExpr;
} else if (op instanceof FilterOperator) {
- return Boolean.TRUE.equals(elseVal) ? ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNotEqual(), newExprs.subList(0, 2)) :
+ return Boolean.TRUE.equals(elseVal) ?
+ ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNotEqual(),
+ Lists.newArrayList(newExprs.subList(0, 2))) :
Boolean.FALSE.equals(elseVal) ? elseExpr : null;
} else {
return null;
}
} else if (null == elseVal && op instanceof FilterOperator) {
- return Boolean.TRUE.equals(thenVal) ? ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPEqual(), newExprs.subList(0, 2)) :
- Boolean.FALSE.equals(thenVal) ? thenExpr : null;
+ return Boolean.TRUE.equals(thenVal) ? ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPEqual(),
+ Lists.newArrayList(newExprs.subList(0, 2))) :
+ Boolean.FALSE.equals(thenVal) ? thenExpr : null;
} else if(thenVal.equals(elseVal)){
return thenExpr;
} else if (thenVal instanceof Boolean && elseVal instanceof Boolean) {
- return Boolean.TRUE.equals(thenVal) ? ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPEqual(), newExprs.subList(0, 2)) :
- ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNotEqual(), newExprs.subList(0, 2));
+ return Boolean.TRUE.equals(thenVal) ? ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPEqual(),
+ Lists.newArrayList(newExprs.subList(0, 2))) :
+ ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNotEqual(),
+ Lists.newArrayList(newExprs.subList(0, 2)));
} else {
return null;
}
http://git-wip-us.apache.org/repos/asf/hive/blob/ad1ceb86/ql/src/test/queries/clientpositive/fold_case2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/fold_case2.q b/ql/src/test/queries/clientpositive/fold_case2.q
new file mode 100644
index 0000000..71c5bb8
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/fold_case2.q
@@ -0,0 +1,13 @@
+drop table test1;
+drop table test2;
+
+create table test1 (id int, desc string) stored as orc;
+create table test2 (id int, desc string) stored as orc;
+
+select
+case
+when (case when a.desc='test' then 1 else 0 end)=0 then 'test'
+else null
+end as val
+FROM test1 a
+JOIN test2 b ON a.id=b.id;
http://git-wip-us.apache.org/repos/asf/hive/blob/ad1ceb86/ql/src/test/results/clientpositive/fold_case2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/fold_case2.q.out b/ql/src/test/results/clientpositive/fold_case2.q.out
new file mode 100644
index 0000000..f87a097
--- /dev/null
+++ b/ql/src/test/results/clientpositive/fold_case2.q.out
@@ -0,0 +1,46 @@
+PREHOOK: query: drop table test1
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: drop table test1
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: drop table test2
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: drop table test2
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: create table test1 (id int, desc string) stored as orc
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@test1
+POSTHOOK: query: create table test1 (id int, desc string) stored as orc
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@test1
+PREHOOK: query: create table test2 (id int, desc string) stored as orc
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@test2
+POSTHOOK: query: create table test2 (id int, desc string) stored as orc
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@test2
+PREHOOK: query: select
+case
+when (case when a.desc='test' then 1 else 0 end)=0 then 'test'
+else null
+end as val
+FROM test1 a
+JOIN test2 b ON a.id=b.id
+PREHOOK: type: QUERY
+PREHOOK: Input: default@test1
+PREHOOK: Input: default@test2
+#### A masked pattern was here ####
+POSTHOOK: query: select
+case
+when (case when a.desc='test' then 1 else 0 end)=0 then 'test'
+else null
+end as val
+FROM test1 a
+JOIN test2 b ON a.id=b.id
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@test1
+POSTHOOK: Input: default@test2
+#### A masked pattern was here ####