Github user gvramana commented on a diff in the pull request:
https://github.com/apache/spark/pull/2762#discussion_r18877950
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala ---
@@ -186,6 +230,51 @@ private[hive] trait HiveInspectors {
fields.map(f => f.name), fields.map(f => toInspector(f.dataType)))
}
+ def toInspector(expr: Expression): ObjectInspector = expr match {
+ case Literal(value: String, StringType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.STRING, new hadoopIo.Text(value))
+ case Literal(value: Int, IntegerType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.INT, new hadoopIo.IntWritable(value))
+ case Literal(value: Double, DoubleType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.DOUBLE, new hiveIo.DoubleWritable(value))
+ case Literal(value: Boolean, BooleanType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.BOOLEAN, new hadoopIo.BooleanWritable(value))
+ case Literal(value: Long, LongType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.LONG, new hadoopIo.LongWritable(value))
+ case Literal(value: Float, FloatType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.FLOAT, new hadoopIo.FloatWritable(value))
+ case Literal(value: Short, ShortType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.SHORT, new hiveIo.ShortWritable(value))
+ case Literal(value: Byte, ByteType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.BYTE, new hiveIo.ByteWritable(value))
+ case Literal(value: Array[Byte], BinaryType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.BINARY, new hadoopIo.BytesWritable(value))
+ case Literal(value: java.sql.Date, DateType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.DATE, new hiveIo.DateWritable(value))
+ case Literal(value: java.sql.Timestamp, TimestampType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.TIMESTAMP, new hiveIo.TimestampWritable(value))
+ case Literal(value: BigDecimal, DecimalType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.DECIMAL,
+ new hiveIo.HiveDecimalWritable(new
HiveDecimal(value.underlying())))
+ case Literal(_, NullType) =>
+
PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ PrimitiveCategory.VOID, null)
+ case Literal(_, _) => sys.error("Hive doesn't support the constant
complicated type.")
--- End diff --
Hive supports few complicated types constant. List, Map
StandardConstantListObjectInspector.java
StandardConstantMapObjectInspector.java
This is required for functions like percentile_approx(col, array(0.8,0.9))
to work
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]