diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentImpl.java b/ql/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentImpl.java index 9673b1a..055567c 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentImpl.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentImpl.java @@ -444,6 +444,10 @@ private static String getColumnName(ExprNodeGenericFuncDesc expr, } private static Object boxLiteral(ExprNodeConstantDesc lit) { + Object val = lit.getValue(); + if (val == null) { + return null; + } switch (getType(lit)) { case INTEGER: return ((Number) lit.getValue()).intValue(); diff --git a/ql/src/test/queries/clientpositive/orc_ppd_date.q b/ql/src/test/queries/clientpositive/orc_ppd_date.q index 3d21d41..3606854 100644 --- a/ql/src/test/queries/clientpositive/orc_ppd_date.q +++ b/ql/src/test/queries/clientpositive/orc_ppd_date.q @@ -1,6 +1,7 @@ SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat; SET mapred.min.split.size=1000; SET mapred.max.split.size=5000; +SET hive.cbo.enable=false; create table newtypesorc(c char(10), v varchar(10), d decimal(5,3), da date) stored as orc tblproperties("orc.stripe.size"="16777216"); @@ -9,6 +10,18 @@ insert overwrite table newtypesorc select * from (select cast("apple" as char(10 -- date data types (EQUAL, NOT_EQUAL, LESS_THAN, LESS_THAN_EQUALS, IN, BETWEEN tests) select sum(hash(*)) from newtypesorc where da='1970-02-20'; +set hive.optimize.index.filter=false; +select sum(hash(*)) from newtypesorc where da is null or da = null; + +set hive.optimize.index.filter=true; +select sum(hash(*)) from newtypesorc where da is null or da = null; + +set hive.optimize.index.filter=false; +select sum(hash(*)) from newtypesorc where da is not null or da != null or da <> null; + +set hive.optimize.index.filter=true; +select sum(hash(*)) from newtypesorc where da is not null or da != null or da <> null; + set hive.optimize.index.filter=true; select sum(hash(*)) from newtypesorc where da='1970-02-20'; diff --git a/ql/src/test/results/clientpositive/orc_ppd_date.q.out b/ql/src/test/results/clientpositive/orc_ppd_date.q.out index e07739d..da15a42 100644 --- a/ql/src/test/results/clientpositive/orc_ppd_date.q.out +++ b/ql/src/test/results/clientpositive/orc_ppd_date.q.out @@ -29,6 +29,42 @@ POSTHOOK: type: QUERY POSTHOOK: Input: default@newtypesorc #### A masked pattern was here #### -252951929000 +PREHOOK: query: select sum(hash(*)) from newtypesorc where da is null or da = null +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypesorc +#### A masked pattern was here #### +POSTHOOK: query: select sum(hash(*)) from newtypesorc where da is null or da = null +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypesorc +#### A masked pattern was here #### +NULL +PREHOOK: query: select sum(hash(*)) from newtypesorc where da is null or da = null +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypesorc +#### A masked pattern was here #### +POSTHOOK: query: select sum(hash(*)) from newtypesorc where da is null or da = null +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypesorc +#### A masked pattern was here #### +NULL +PREHOOK: query: select sum(hash(*)) from newtypesorc where da is not null or da != null or da <> null +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypesorc +#### A masked pattern was here #### +POSTHOOK: query: select sum(hash(*)) from newtypesorc where da is not null or da != null or da <> null +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypesorc +#### A masked pattern was here #### +81475875500 +PREHOOK: query: select sum(hash(*)) from newtypesorc where da is not null or da != null or da <> null +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypesorc +#### A masked pattern was here #### +POSTHOOK: query: select sum(hash(*)) from newtypesorc where da is not null or da != null or da <> null +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypesorc +#### A masked pattern was here #### +81475875500 PREHOOK: query: select sum(hash(*)) from newtypesorc where da='1970-02-20' PREHOOK: type: QUERY PREHOOK: Input: default@newtypesorc