You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/09/09 16:34:01 UTC

svn commit: r1521136 - in /hive/trunk/serde/src: java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java

Author: hashutosh
Date: Mon Sep  9 14:34:01 2013
New Revision: 1521136

URL: http://svn.apache.org/r1521136
Log:
HIVE-5239 : LazyDate goes into irretrievable NULL mode once inited with NULL once (Jason Dere via Ashutosh Chauhan)

Modified:
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java?rev=1521136&r1=1521135&r2=1521136&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java (original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java Mon Sep  9 14:34:01 2013
@@ -62,6 +62,7 @@ public class LazyDate extends LazyPrimit
     try {
       s = Text.decode(bytes.getData(), start, length);
       data.set(Date.valueOf(s));
+      isNull = false;
     } catch (Exception e) {
       isNull = true;
       logExceptionMessage(bytes, start, length, "DATE");

Modified: hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java?rev=1521136&r1=1521135&r2=1521136&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java (original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java Mon Sep  9 14:34:01 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.serde2.lazy;
 
+import java.sql.Date;
 import java.sql.Timestamp;
 
 import junit.framework.TestCase;
@@ -408,6 +409,25 @@ public class TestLazyPrimitive extends T
     assertEquals(true, t.isNull);
   }
 
+  public void testLazyDate() throws Throwable {
+    LazyDate t = new LazyDate(LazyPrimitiveObjectInspectorFactory.LAZY_DATE_OBJECT_INSPECTOR);
+    String nullDate = "NULL";
+    byte[] nullBytes = nullDate.getBytes();
+    initLazyObject(t, nullBytes, 0, nullBytes.length);
+    assertEquals(true, t.isNull);
+    String sampleDate = "2013-02-12";
+    byte[] good2013 = sampleDate.getBytes();
+    initLazyObject(t, good2013, 0, good2013.length);
+    assertEquals(false, t.isNull);
+    assertEquals(Date.valueOf(sampleDate),
+        t.getWritableObject().get());
+    String badDate = "X013-02-12";
+    byte[] bad2013 = badDate.getBytes();
+    initLazyObject(t, bad2013, 0, bad2013.length);
+    assertEquals(true, t.isNull);
+
+  }
+
   public void testLazyIntegerWrite() throws Throwable {
     try {
       ByteStream.Output out = new ByteStream.Output();