Author: thejas
Date: Fri Sep 13 21:46:25 2013
New Revision: 1523119
URL: http://svn.apache.org/r1523119
Log:
HIVE-5239 : LazyDate goes into irretrievable NULL mode once inited with NULL
once (Jason Dere via Ashutosh Chauhan)
Modified:
hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java
hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java
Modified:
hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java
URL:
http://svn.apache.org/viewvc/hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java?rev=1523119&r1=1523118&r2=1523119&view=diff
==============================================================================
---
hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java
(original)
+++
hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyDate.java
Fri Sep 13 21:46:25 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/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java
URL:
http://svn.apache.org/viewvc/hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java?rev=1523119&r1=1523118&r2=1523119&view=diff
==============================================================================
---
hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java
(original)
+++
hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/lazy/TestLazyPrimitive.java
Fri Sep 13 21:46:25 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();