diff options
author | Cheng Lian <lian.cs.zju@gmail.com> | 2014-06-25 00:14:34 -0700 |
---|---|---|
committer | Reynold Xin <rxin@apache.org> | 2014-06-25 00:15:13 -0700 |
commit | a31def10af2287d4b54941f1098d3ed4eadf4509 (patch) | |
tree | 6918b788a528f1d271346c86bc8b64207d962fd3 /sql/hive/src/main | |
parent | d3dbaf5a788af77c3d253e7dc6ea7ce54fe6fbe0 (diff) | |
download | spark-a31def10af2287d4b54941f1098d3ed4eadf4509.tar.gz spark-a31def10af2287d4b54941f1098d3ed4eadf4509.tar.bz2 spark-a31def10af2287d4b54941f1098d3ed4eadf4509.zip |
[SPARK-2263][SQL] Support inserting MAP<K, V> to Hive tables
JIRA issue: [SPARK-2263](https://issues.apache.org/jira/browse/SPARK-2263)
Map objects were not converted to Hive types before inserting into Hive tables.
Author: Cheng Lian <lian.cs.zju@gmail.com>
Closes #1205 from liancheng/spark-2263 and squashes the following commits:
c7a4373 [Cheng Lian] Addressed @concretevitamin's comment
784940b [Cheng Lian] SARPK-2263: support inserting MAP<K, V> to Hive tables
(cherry picked from commit 8fade8973e5fc97f781de5344beb66b90bd6e524)
Signed-off-by: Reynold Xin <rxin@apache.org>
Diffstat (limited to 'sql/hive/src/main')
-rw-r--r-- | sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala index 594a803806..c2b0b00aa5 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala @@ -19,6 +19,8 @@ package org.apache.spark.sql.hive.execution import scala.collection.JavaConversions._ +import java.util.{HashMap => JHashMap} + import org.apache.hadoop.hive.common.`type`.{HiveDecimal, HiveVarchar} import org.apache.hadoop.hive.metastore.MetaStoreUtils import org.apache.hadoop.hive.ql.Context @@ -88,6 +90,12 @@ case class InsertIntoHiveTable( val wrappedSeq = s.map(wrap(_, oi.getListElementObjectInspector)) seqAsJavaList(wrappedSeq) + case (m: Map[_, _], oi: MapObjectInspector) => + val keyOi = oi.getMapKeyObjectInspector + val valueOi = oi.getMapValueObjectInspector + val wrappedMap = m.map { case (key, value) => wrap(key, keyOi) -> wrap(value, valueOi) } + mapAsJavaMap(wrappedMap) + case (obj, _) => obj } |