hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aihu...@apache.org
Subject hive git commit: HIVE-12196 NPE when converting bad timestamp value (Aihua Xu, reviewed by Chaoyu Tang)
Date Mon, 16 Nov 2015 15:35:37 GMT
Repository: hive
Updated Branches:
  refs/heads/master 3d8df7444 -> 78b74277a


HIVE-12196 NPE when converting bad timestamp value (Aihua Xu, reviewed by Chaoyu Tang)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/78b74277
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/78b74277
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/78b74277

Branch: refs/heads/master
Commit: 78b74277a8634aa1c107cd501560c0d9b7a46093
Parents: 3d8df74
Author: aihuaxu <aihuaxu@apache.org>
Authored: Tue Nov 3 13:49:20 2015 -0500
Committer: aihuaxu <aihuaxu@apache.org>
Committed: Mon Nov 16 10:34:41 2015 -0500

----------------------------------------------------------------------
 .../ql/udf/generic/GenericUDFFromUtcTimestamp.java     | 11 +++++++----
 .../queries/clientpositive/udf_from_utc_timestamp.q    |  5 +++++
 .../clientpositive/udf_from_utc_timestamp.q.out        | 13 +++++++++++++
 3 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/78b74277/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java
b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java
index 30ef5ab..331ee6b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java
@@ -77,12 +77,15 @@ public class GenericUDFFromUtcTimestamp extends GenericUDF {
       return null;
     }
 
-    String tzStr = textConverter.convert(o1).toString();
-    TimeZone timezone = TimeZone.getTimeZone(tzStr);
+    Object converted_o0 = timestampConverter.convert(o0);
+    if (converted_o0 == null) {
+      return null;
+    }
 
-    Timestamp timestamp = ((TimestampWritable) timestampConverter.convert(o0))
-        .getTimestamp();
+    Timestamp timestamp = ((TimestampWritable) converted_o0).getTimestamp();
 
+    String tzStr = textConverter.convert(o1).toString();
+    TimeZone timezone = TimeZone.getTimeZone(tzStr);
     int offset = timezone.getOffset(timestamp.getTime());
     if (invert()) {
       offset = -offset;

http://git-wip-us.apache.org/repos/asf/hive/blob/78b74277/ql/src/test/queries/clientpositive/udf_from_utc_timestamp.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/udf_from_utc_timestamp.q b/ql/src/test/queries/clientpositive/udf_from_utc_timestamp.q
index b113eec..ca0a6a8 100644
--- a/ql/src/test/queries/clientpositive/udf_from_utc_timestamp.q
+++ b/ql/src/test/queries/clientpositive/udf_from_utc_timestamp.q
@@ -22,3 +22,8 @@ from_utc_timestamp(cast('2012-02-11 04:30:00' as timestamp), ''),
 from_utc_timestamp(cast('2012-02-11 04:30:00' as timestamp), '---'),
 from_utc_timestamp(cast(null as timestamp), 'PST'),
 from_utc_timestamp(cast('2012-02-11 04:30:00' as timestamp), cast(null as string));
+
+select
+from_utc_timestamp('2012-02-11-04:30:00', 'UTC'),
+from_utc_timestamp('2012-02-11-04:30:00', 'PST');
+

http://git-wip-us.apache.org/repos/asf/hive/blob/78b74277/ql/src/test/results/clientpositive/udf_from_utc_timestamp.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/udf_from_utc_timestamp.q.out b/ql/src/test/results/clientpositive/udf_from_utc_timestamp.q.out
index 5b4bc35..be2cb1a 100644
--- a/ql/src/test/results/clientpositive/udf_from_utc_timestamp.q.out
+++ b/ql/src/test/results/clientpositive/udf_from_utc_timestamp.q.out
@@ -80,3 +80,16 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: _dummy_database@_dummy_table
 #### A masked pattern was here ####
 2012-02-10 20:30:00	2012-02-11 08:30:00	2012-02-11 12:30:00	2012-02-11 04:30:00	2012-02-11
04:30:00	2012-02-11 04:30:00	NULL	NULL
+PREHOOK: query: select
+from_utc_timestamp('2012-02-11-04:30:00', 'UTC'),
+from_utc_timestamp('2012-02-11-04:30:00', 'PST')
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+POSTHOOK: query: select
+from_utc_timestamp('2012-02-11-04:30:00', 'UTC'),
+from_utc_timestamp('2012-02-11-04:30:00', 'PST')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+#### A masked pattern was here ####
+NULL	NULL


Mime
View raw message