aboutsummaryrefslogtreecommitdiff
path: root/sql/hive/v0.13.1
diff options
context:
space:
mode:
authorCheng Hao <hao.cheng@intel.com>2014-11-10 17:22:57 -0800
committerMichael Armbrust <michael@databricks.com>2014-11-10 17:22:57 -0800
commitfa777833b52b6f339cdc335e8e3935cfe9a2a7eb (patch)
treea91ef53220104ac80faf5961fcbc0a2a20a947f8 /sql/hive/v0.13.1
parentd793d80c8084923ea04dcf7d268eec8ede490127 (diff)
downloadspark-fa777833b52b6f339cdc335e8e3935cfe9a2a7eb.tar.gz
spark-fa777833b52b6f339cdc335e8e3935cfe9a2a7eb.tar.bz2
spark-fa777833b52b6f339cdc335e8e3935cfe9a2a7eb.zip
[SPARK-4250] [SQL] Fix bug of constant null value mapping to ConstantObjectInspector
Author: Cheng Hao <hao.cheng@intel.com> Closes #3114 from chenghao-intel/constant_null_oi and squashes the following commits: e603bda [Cheng Hao] fix the bug of null value for primitive types 50a13ba [Cheng Hao] fix the timezone issue f54f369 [Cheng Hao] fix bug of constant null value for ObjectInspector
Diffstat (limited to 'sql/hive/v0.13.1')
-rw-r--r--sql/hive/v0.13.1/src/main/scala/org/apache/spark/sql/hive/Shim13.scala80
1 files changed, 56 insertions, 24 deletions
diff --git a/sql/hive/v0.13.1/src/main/scala/org/apache/spark/sql/hive/Shim13.scala b/sql/hive/v0.13.1/src/main/scala/org/apache/spark/sql/hive/Shim13.scala
index 0bc330cdbe..e4aee57f0a 100644
--- a/sql/hive/v0.13.1/src/main/scala/org/apache/spark/sql/hive/Shim13.scala
+++ b/sql/hive/v0.13.1/src/main/scala/org/apache/spark/sql/hive/Shim13.scala
@@ -56,54 +56,86 @@ private[hive] object HiveShim {
new TableDesc(inputFormatClass, outputFormatClass, properties)
}
- def getPrimitiveWritableConstantObjectInspector(value: String): ObjectInspector =
+ def getStringWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.stringTypeInfo, new hadoopIo.Text(value))
+ TypeInfoFactory.stringTypeInfo,
+ if (value == null) null else new hadoopIo.Text(value.asInstanceOf[String]))
- def getPrimitiveWritableConstantObjectInspector(value: Int): ObjectInspector =
+ def getIntWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.intTypeInfo, new hadoopIo.IntWritable(value))
+ TypeInfoFactory.intTypeInfo,
+ if (value == null) null else new hadoopIo.IntWritable(value.asInstanceOf[Int]))
- def getPrimitiveWritableConstantObjectInspector(value: Double): ObjectInspector =
+ def getDoubleWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.doubleTypeInfo, new hiveIo.DoubleWritable(value))
+ TypeInfoFactory.doubleTypeInfo, if (value == null) {
+ null
+ } else {
+ new hiveIo.DoubleWritable(value.asInstanceOf[Double])
+ })
- def getPrimitiveWritableConstantObjectInspector(value: Boolean): ObjectInspector =
+ def getBooleanWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.booleanTypeInfo, new hadoopIo.BooleanWritable(value))
+ TypeInfoFactory.booleanTypeInfo, if (value == null) {
+ null
+ } else {
+ new hadoopIo.BooleanWritable(value.asInstanceOf[Boolean])
+ })
- def getPrimitiveWritableConstantObjectInspector(value: Long): ObjectInspector =
+ def getLongWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.longTypeInfo, new hadoopIo.LongWritable(value))
+ TypeInfoFactory.longTypeInfo,
+ if (value == null) null else new hadoopIo.LongWritable(value.asInstanceOf[Long]))
- def getPrimitiveWritableConstantObjectInspector(value: Float): ObjectInspector =
+ def getFloatWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.floatTypeInfo, new hadoopIo.FloatWritable(value))
+ TypeInfoFactory.floatTypeInfo, if (value == null) {
+ null
+ } else {
+ new hadoopIo.FloatWritable(value.asInstanceOf[Float])
+ })
- def getPrimitiveWritableConstantObjectInspector(value: Short): ObjectInspector =
+ def getShortWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.shortTypeInfo, new hiveIo.ShortWritable(value))
+ TypeInfoFactory.shortTypeInfo,
+ if (value == null) null else new hiveIo.ShortWritable(value.asInstanceOf[Short]))
- def getPrimitiveWritableConstantObjectInspector(value: Byte): ObjectInspector =
+ def getByteWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.byteTypeInfo, new hiveIo.ByteWritable(value))
+ TypeInfoFactory.byteTypeInfo,
+ if (value == null) null else new hiveIo.ByteWritable(value.asInstanceOf[Byte]))
- def getPrimitiveWritableConstantObjectInspector(value: Array[Byte]): ObjectInspector =
+ def getBinaryWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.binaryTypeInfo, new hadoopIo.BytesWritable(value))
+ TypeInfoFactory.binaryTypeInfo, if (value == null) {
+ null
+ } else {
+ new hadoopIo.BytesWritable(value.asInstanceOf[Array[Byte]])
+ })
- def getPrimitiveWritableConstantObjectInspector(value: java.sql.Date): ObjectInspector =
+ def getDateWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.dateTypeInfo, new hiveIo.DateWritable(value))
+ TypeInfoFactory.dateTypeInfo,
+ if (value == null) null else new hiveIo.DateWritable(value.asInstanceOf[java.sql.Date]))
- def getPrimitiveWritableConstantObjectInspector(value: java.sql.Timestamp): ObjectInspector =
+ def getTimestampWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
- TypeInfoFactory.timestampTypeInfo, new hiveIo.TimestampWritable(value))
+ TypeInfoFactory.timestampTypeInfo, if (value == null) {
+ null
+ } else {
+ new hiveIo.TimestampWritable(value.asInstanceOf[java.sql.Timestamp])
+ })
- def getPrimitiveWritableConstantObjectInspector(value: BigDecimal): ObjectInspector =
+ def getDecimalWritableConstantObjectInspector(value: Any): ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
TypeInfoFactory.decimalTypeInfo,
- new hiveIo.HiveDecimalWritable(HiveShim.createDecimal(value.underlying())))
+ if (value == null) {
+ null
+ } else {
+ // TODO precise, scale?
+ new hiveIo.HiveDecimalWritable(
+ HiveShim.createDecimal(value.asInstanceOf[Decimal].toBigDecimal.underlying()))
+ })
def getPrimitiveNullWritableConstantObjectInspector: ObjectInspector =
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(