You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jd...@apache.org on 2014/10/15 03:59:09 UTC
svn commit: r1631931 - in /hive/branches/branch-0.14/ql/src:
java/org/apache/hadoop/hive/ql/exec/ test/org/apache/hadoop/hive/ql/exec/
test/queries/clientpositive/ test/results/clientpositive/
Author: jdere
Date: Wed Oct 15 01:59:09 2014
New Revision: 1631931
URL: http://svn.apache.org/r1631931
Log:
HIVE-8391: Comparion between TIMESTAMP and Integer types goes to STRING as "common comparison denominator" instead of a numeric type (Jason Dere, reviewed by Sergey Shelukhin)
Added:
hive/branches/branch-0.14/ql/src/test/queries/clientpositive/timestamp_comparison2.q
hive/branches/branch-0.14/ql/src/test/results/clientpositive/timestamp_comparison2.q.out
Modified:
hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/TestFunctionRegistry.java
Modified: hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java?rev=1631931&r1=1631930&r2=1631931&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (original)
+++ hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java Wed Oct 15 01:59:09 2014
@@ -954,6 +954,12 @@ public final class FunctionRegistry {
(PrimitiveTypeInfo)a, (PrimitiveTypeInfo)b,PrimitiveCategory.STRING);
}
+ // Another special case, because timestamp is not implicitly convertible to numeric types.
+ if ((pgA == PrimitiveGrouping.NUMERIC_GROUP || pgB == PrimitiveGrouping.NUMERIC_GROUP)
+ && (pcA == PrimitiveCategory.TIMESTAMP || pcB == PrimitiveCategory.TIMESTAMP)) {
+ return TypeInfoFactory.doubleTypeInfo;
+ }
+
for (PrimitiveCategory t : numericTypeList) {
if (FunctionRegistry.implicitConvertible(pcA, t)
&& FunctionRegistry.implicitConvertible(pcB, t)) {
Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/TestFunctionRegistry.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/TestFunctionRegistry.java?rev=1631931&r1=1631930&r2=1631931&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/TestFunctionRegistry.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/TestFunctionRegistry.java Wed Oct 15 01:59:09 2014
@@ -256,6 +256,11 @@ public class TestFunctionRegistry extend
comparison(TypeInfoFactory.stringTypeInfo, TypeInfoFactory.dateTypeInfo,
TypeInfoFactory.stringTypeInfo);
+ comparison(TypeInfoFactory.intTypeInfo, TypeInfoFactory.timestampTypeInfo,
+ TypeInfoFactory.doubleTypeInfo);
+ comparison(TypeInfoFactory.timestampTypeInfo, TypeInfoFactory.intTypeInfo,
+ TypeInfoFactory.doubleTypeInfo);
+
comparison(TypeInfoFactory.stringTypeInfo, varchar10, TypeInfoFactory.stringTypeInfo);
comparison(varchar10, TypeInfoFactory.stringTypeInfo, TypeInfoFactory.stringTypeInfo);
comparison(varchar5, varchar10, varchar10);
Added: hive/branches/branch-0.14/ql/src/test/queries/clientpositive/timestamp_comparison2.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/timestamp_comparison2.q?rev=1631931&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/timestamp_comparison2.q (added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/timestamp_comparison2.q Wed Oct 15 01:59:09 2014
@@ -0,0 +1,23 @@
+-- Test timestamp-to-numeric comparison
+select count(*)
+FROM alltypesorc
+WHERE
+((ctinyint != 0)
+ AND
+ (((ctimestamp1 <= 0)
+ OR ((ctinyint = cint) OR (cstring2 LIKE 'ss')))
+ AND ((988888 < cdouble)
+ OR ((ctimestamp2 > -29071) AND (3569 >= cdouble)))))
+;
+
+-- Should have same result as previous query
+select count(*)
+FROM alltypesorc
+WHERE
+((ctinyint != 0)
+ AND
+ (((ctimestamp1 <= timestamp('1969-12-31 16:00:00'))
+ OR ((ctinyint = cint) OR (cstring2 LIKE 'ss')))
+ AND ((988888 < cdouble)
+ OR ((ctimestamp2 > timestamp('1969-12-31 07:55:29')) AND (3569 >= cdouble)))))
+;
Added: hive/branches/branch-0.14/ql/src/test/results/clientpositive/timestamp_comparison2.q.out
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/results/clientpositive/timestamp_comparison2.q.out?rev=1631931&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/results/clientpositive/timestamp_comparison2.q.out (added)
+++ hive/branches/branch-0.14/ql/src/test/results/clientpositive/timestamp_comparison2.q.out Wed Oct 15 01:59:09 2014
@@ -0,0 +1,54 @@
+PREHOOK: query: -- Test timestamp-to-numeric comparison
+select count(*)
+FROM alltypesorc
+WHERE
+((ctinyint != 0)
+ AND
+ (((ctimestamp1 <= 0)
+ OR ((ctinyint = cint) OR (cstring2 LIKE 'ss')))
+ AND ((988888 < cdouble)
+ OR ((ctimestamp2 > -29071) AND (3569 >= cdouble)))))
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: -- Test timestamp-to-numeric comparison
+select count(*)
+FROM alltypesorc
+WHERE
+((ctinyint != 0)
+ AND
+ (((ctimestamp1 <= 0)
+ OR ((ctinyint = cint) OR (cstring2 LIKE 'ss')))
+ AND ((988888 < cdouble)
+ OR ((ctimestamp2 > -29071) AND (3569 >= cdouble)))))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+1826
+PREHOOK: query: -- Should have same result as previous query
+select count(*)
+FROM alltypesorc
+WHERE
+((ctinyint != 0)
+ AND
+ (((ctimestamp1 <= timestamp('1969-12-31 16:00:00'))
+ OR ((ctinyint = cint) OR (cstring2 LIKE 'ss')))
+ AND ((988888 < cdouble)
+ OR ((ctimestamp2 > timestamp('1969-12-31 07:55:29')) AND (3569 >= cdouble)))))
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: -- Should have same result as previous query
+select count(*)
+FROM alltypesorc
+WHERE
+((ctinyint != 0)
+ AND
+ (((ctimestamp1 <= timestamp('1969-12-31 16:00:00'))
+ OR ((ctinyint = cint) OR (cstring2 LIKE 'ss')))
+ AND ((988888 < cdouble)
+ OR ((ctimestamp2 > timestamp('1969-12-31 07:55:29')) AND (3569 >= cdouble)))))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+1826