@@ -86,13 +86,41 @@ private[hive] trait HiveInspectors {
8686 * @param data the data in Hive type
8787 * @param oi the ObjectInspector associated with the Hive Type
8888 * @return convert the data into catalyst type
89+ * TODO return the function of (data => Any) instead for performance consideration
8990 */
9091 def unwrap (data : Any , oi : ObjectInspector ): Any = oi match {
9192 case _ if data == null => null
92- case hvoi : HiveVarcharObjectInspector =>
93- if (data == null ) null else hvoi.getPrimitiveJavaObject(data).getValue
94- case hdoi : HiveDecimalObjectInspector =>
95- if (data == null ) null else HiveShim .toCatalystDecimal(hdoi, data)
93+ case poi : VoidObjectInspector => null
94+ case poi : WritableConstantHiveVarcharObjectInspector =>
95+ poi.getWritableConstantValue.getHiveVarchar.getValue
96+ case poi : WritableConstantHiveDecimalObjectInspector =>
97+ HiveShim .toCatalystDecimal(
98+ PrimitiveObjectInspectorFactory .javaHiveDecimalObjectInspector,
99+ poi.getWritableConstantValue.getHiveDecimal)
100+ case poi : WritableConstantTimestampObjectInspector =>
101+ poi.getWritableConstantValue.getTimestamp.clone()
102+ case poi : WritableConstantIntObjectInspector =>
103+ poi.getWritableConstantValue.get()
104+ case poi : WritableConstantDoubleObjectInspector =>
105+ poi.getWritableConstantValue.get()
106+ case poi : WritableConstantBooleanObjectInspector =>
107+ poi.getWritableConstantValue.get()
108+ case poi : WritableConstantLongObjectInspector =>
109+ poi.getWritableConstantValue.get()
110+ case poi : WritableConstantFloatObjectInspector =>
111+ poi.getWritableConstantValue.get()
112+ case poi : WritableConstantShortObjectInspector =>
113+ poi.getWritableConstantValue.get()
114+ case poi : WritableConstantByteObjectInspector =>
115+ poi.getWritableConstantValue.get()
116+ case poi : WritableConstantBinaryObjectInspector =>
117+ val writable = poi.getWritableConstantValue
118+ val temp = new Array [Byte ](writable.getLength)
119+ System .arraycopy(writable.getBytes, 0 , temp, 0 , temp.length)
120+ temp
121+ case poi : WritableConstantDateObjectInspector => poi.getWritableConstantValue.get()
122+ case hvoi : HiveVarcharObjectInspector => hvoi.getPrimitiveJavaObject(data).getValue
123+ case hdoi : HiveDecimalObjectInspector => HiveShim .toCatalystDecimal(hdoi, data)
96124 // org.apache.hadoop.hive.serde2.io.TimestampWritable.set will reset current time object
97125 // if next timestamp is null, so Timestamp object is cloned
98126 case ti : TimestampObjectInspector => ti.getPrimitiveJavaObject(data).clone()
0 commit comments