[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)
This commit is contained in:
Xiangrui Meng 2014-11-10 11:04:12 -08:00 committed by Michael Armbrust
parent bd86cb1738
commit 894a7245c3
2 changed files with 9 additions and 1 deletions

View file

@ -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)
}
}

View file

@ -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))
}
}