aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorXiangrui Meng <meng@databricks.com>2014-11-10 11:04:12 -0800
committerMichael Armbrust <michael@databricks.com>2014-11-10 11:04:12 -0800
commit894a7245c379b2e823ae7d81cc9228e60ba47c78 (patch)
treee139978f76376820425b04b8e801c23f5a30d8cf /sql/hive
parentbd86cb1738800a0aa4c88b9afdba2f97ac6cbf25 (diff)
downloadspark-894a7245c379b2e823ae7d81cc9228e60ba47c78.tar.gz
spark-894a7245c379b2e823ae7d81cc9228e60ba47c78.tar.bz2
spark-894a7245c379b2e823ae7d81cc9228e60ba47c78.zip
[SQL] support udt to hive types conversion (hive->udt is not supported)
marmbrus Author: Xiangrui Meng <meng@databricks.com> Closes #3164 from mengxr/hive-udt and squashes the following commits: 57c7519 [Xiangrui Meng] support udt->hive types (hive->udt is not supported)
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala1
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreCatalogSuite.scala9
2 files changed, 9 insertions, 1 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
index 0baf4c9f8c..9ae0198422 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
@@ -390,6 +390,7 @@ object HiveMetastoreTypes extends RegexParsers {
case d: DecimalType => HiveShim.decimalMetastoreString(d)
case TimestampType => "timestamp"
case NullType => "void"
+ case udt: UserDefinedType[_] => toMetastoreType(udt.sqlType)
}
}
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreCatalogSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreCatalogSuite.scala
index 4a64b5f5eb..86535f8dd4 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreCatalogSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreCatalogSuite.scala
@@ -19,7 +19,8 @@ package org.apache.spark.sql.hive
import org.scalatest.FunSuite
-import org.apache.spark.sql.catalyst.types.{DataType, StructType}
+import org.apache.spark.sql.catalyst.types.StructType
+import org.apache.spark.sql.test.ExamplePointUDT
class HiveMetastoreCatalogSuite extends FunSuite {
@@ -29,4 +30,10 @@ class HiveMetastoreCatalogSuite extends FunSuite {
val datatype = HiveMetastoreTypes.toDataType(metastr)
assert(datatype.isInstanceOf[StructType])
}
+
+ test("udt to metastore type conversion") {
+ val udt = new ExamplePointUDT
+ assert(HiveMetastoreTypes.toMetastoreType(udt) ===
+ HiveMetastoreTypes.toMetastoreType(udt.sqlType))
+ }
}