Skip to content
Snippets Groups Projects
Commit 894a7245 authored by Xiangrui Meng's avatar Xiangrui Meng Committed by Michael Armbrust
Browse files

[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)
parent bd86cb17
No related branches found
No related tags found
No related merge requests found
......@@ -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)
}
}
......
......@@ -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))
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment