hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1462874 - in /hive/trunk: ql/src/test/queries/clientpositive/timestamp_null.q ql/src/test/results/clientpositive/timestamp_null.q.out serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyTimestamp.java
Date Sun, 31 Mar 2013 03:45:20 GMT
Author: hashutosh
Date: Sun Mar 31 03:45:19 2013
New Revision: 1462874

URL: http://svn.apache.org/r1462874
Log:
HIVE-4122 : Queries fail if timestamp data not in expected format (Prasad Mujumdar via Ashutosh
Chauhan)

Added:
    hive/trunk/ql/src/test/queries/clientpositive/timestamp_null.q
    hive/trunk/ql/src/test/results/clientpositive/timestamp_null.q.out
Modified:
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyTimestamp.java

Added: hive/trunk/ql/src/test/queries/clientpositive/timestamp_null.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/timestamp_null.q?rev=1462874&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/timestamp_null.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/timestamp_null.q Sun Mar 31 03:45:19 2013
@@ -0,0 +1,7 @@
+DROP TABLE IF EXISTS timestamp_null;
+CREATE TABLE timestamp_null (t1 TIMESTAMP);
+LOAD DATA LOCAL INPATH '../data/files/test.dat' OVERWRITE INTO TABLE timestamp_null;
+
+SELECT * FROM timestamp_null LIMIT 1;
+
+SELECT t1 FROM timestamp_null LIMIT 1;

Added: hive/trunk/ql/src/test/results/clientpositive/timestamp_null.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/timestamp_null.q.out?rev=1462874&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/timestamp_null.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/timestamp_null.q.out Sun Mar 31 03:45:19
2013
@@ -0,0 +1,33 @@
+PREHOOK: query: DROP TABLE IF EXISTS timestamp_null
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: DROP TABLE IF EXISTS timestamp_null
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: CREATE TABLE timestamp_null (t1 TIMESTAMP)
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: CREATE TABLE timestamp_null (t1 TIMESTAMP)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@timestamp_null
+PREHOOK: query: LOAD DATA LOCAL INPATH '../data/files/test.dat' OVERWRITE INTO TABLE timestamp_null
+PREHOOK: type: LOAD
+PREHOOK: Output: default@timestamp_null
+POSTHOOK: query: LOAD DATA LOCAL INPATH '../data/files/test.dat' OVERWRITE INTO TABLE timestamp_null
+POSTHOOK: type: LOAD
+POSTHOOK: Output: default@timestamp_null
+PREHOOK: query: SELECT * FROM timestamp_null LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_null
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT * FROM timestamp_null LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_null
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: SELECT t1 FROM timestamp_null LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_null
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT t1 FROM timestamp_null LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_null
+#### A masked pattern was here ####
+NULL

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyTimestamp.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyTimestamp.java?rev=1462874&r1=1462873&r2=1462874&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyTimestamp.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyTimestamp.java Sun Mar
31 03:45:19 2013
@@ -66,12 +66,17 @@ public class LazyTimestamp extends LazyP
       s = "";
     }
 
-    Timestamp t;
+    Timestamp t = null;
     if (s.compareTo("NULL") == 0) {
-      t = null;
+      isNull = true;
       logExceptionMessage(bytes, start, length, "TIMESTAMP");
     } else {
-      t = Timestamp.valueOf(s);
+      try {
+        t = Timestamp.valueOf(s);
+      } catch (IllegalArgumentException e) {
+        isNull = true;
+        logExceptionMessage(bytes, start, length, "TIMESTAMP");
+      }
     }
     data.set(t);
   }



Mime
View raw message