Skip to content

Commit 57c7519

Browse files
committed
support udt->hive types (hive->udt is not supported)
1 parent 5923dd9 commit 57c7519

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ object HiveMetastoreTypes extends RegexParsers {
390390
case d: DecimalType => HiveShim.decimalMetastoreString(d)
391391
case TimestampType => "timestamp"
392392
case NullType => "void"
393+
case udt: UserDefinedType[_] => toMetastoreType(udt.sqlType)
393394
}
394395
}
395396

sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveMetastoreCatalogSuite.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ package org.apache.spark.sql.hive
1919

2020
import org.scalatest.FunSuite
2121

22-
import org.apache.spark.sql.catalyst.types.{DataType, StructType}
22+
import org.apache.spark.sql.catalyst.types.StructType
23+
import org.apache.spark.sql.test.ExamplePointUDT
2324

2425
class HiveMetastoreCatalogSuite extends FunSuite {
2526

@@ -29,4 +30,10 @@ class HiveMetastoreCatalogSuite extends FunSuite {
2930
val datatype = HiveMetastoreTypes.toDataType(metastr)
3031
assert(datatype.isInstanceOf[StructType])
3132
}
33+
34+
test("udt to metastore type conversion") {
35+
val udt = new ExamplePointUDT
36+
assert(HiveMetastoreTypes.toMetastoreType(udt) ===
37+
HiveMetastoreTypes.toMetastoreType(udt.sqlType))
38+
}
3239
}

0 commit comments

Comments
 (0)