hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1529053 - in /hive/branches/branch-0.12/serde/src: java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java
Date Fri, 04 Oct 2013 01:12:10 GMT
Author: thejas
Date: Fri Oct  4 01:12:09 2013
New Revision: 1529053

URL: http://svn.apache.org/r1529053
Log:
HIVE-5394 : ObjectInspectorConverters.getConvertedOI() does not return the correct object
inspector for primitive type. (Hari Sankar via Ashutosh Chauhan)

Modified:
    hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
    hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java

Modified: hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java?rev=1529053&r1=1529052&r2=1529053&view=diff
==============================================================================
--- hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
(original)
+++ hive/branches/branch-0.12/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
Fri Oct  4 01:12:09 2013
@@ -177,9 +177,9 @@ public final class ObjectInspectorConver
     // TODO: Add support for UNION once SettableUnionObjectInspector is implemented.
     switch (outputOI.getCategory()) {
     case PRIMITIVE:
-      PrimitiveObjectInspector primInputOI = (PrimitiveObjectInspector) inputOI;
+      PrimitiveObjectInspector primOutputOI = (PrimitiveObjectInspector) outputOI;
       return PrimitiveObjectInspectorFactory.
-          getPrimitiveWritableObjectInspector(primInputOI);
+          getPrimitiveWritableObjectInspector(primOutputOI);
     case STRUCT:
       StructObjectInspector structOutputOI = (StructObjectInspector) outputOI;
       // create a standard settable struct object inspector

Modified: hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java?rev=1529053&r1=1529052&r2=1529053&view=diff
==============================================================================
--- hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java
(original)
+++ hive/branches/branch-0.12/serde/src/test/org/apache/hadoop/hive/serde2/objectinspector/TestObjectInspectorConverters.java
Fri Oct  4 01:12:09 2013
@@ -25,6 +25,9 @@ import org.apache.hadoop.hive.serde2.io.
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams;
 import org.apache.hadoop.io.BooleanWritable;
 import org.apache.hadoop.io.BytesWritable;
 import org.apache.hadoop.io.FloatWritable;
@@ -171,4 +174,22 @@ public class TestObjectInspectorConverte
     }
 
   }
+
+  public void testGetConvertedOI() throws Throwable {
+    // Try with types that have type params
+    PrimitiveTypeInfo varchar5TI =
+        (PrimitiveTypeInfo) TypeInfoFactory.getPrimitiveTypeInfo("varchar(5)");
+    PrimitiveTypeInfo varchar10TI =
+        (PrimitiveTypeInfo) TypeInfoFactory.getPrimitiveTypeInfo("varchar(10)");
+    PrimitiveObjectInspector varchar5OI =
+        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(varchar5TI);
+    PrimitiveObjectInspector varchar10OI =
+        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(varchar10TI);
+
+    // output OI should have varchar type params
+    PrimitiveObjectInspector poi = (PrimitiveObjectInspector)
+        ObjectInspectorConverters.getConvertedOI(varchar10OI, varchar5OI, true);
+    VarcharTypeParams vcParams = (VarcharTypeParams) poi.getTypeParams();
+    assertEquals("varchar length doesn't match", 5, vcParams.length);
+  }
 }



Mime
View raw message